ELK概述部署和Filebeat 分布式日志管理平台部署
ELK是Elasticsearch、Logstash、Kibana的缩写,这三者是开源日志管理平台Elasticsearch的一部分。Filebeat是一个轻量级日志收集器,设计用于转发日志数据从你的主机到Logstash或Elasticsearch。
以下是部署ELK和Filebeat的基本步骤:
- 部署Elasticsearch
- 部署Kibana
- 部署Logstash
- 部署Filebeat
部署Elasticsearch
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install elasticsearch
sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
部署Kibana
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install kibana
在/etc/kibana/kibana.yml
中配置Elasticsearch的URL。
sudo systemctl start kibana
sudo systemctl enable kibana
部署Logstash
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install logstash
创建Logstash配置文件,例如/etc/logstash/conf.d/myapp.conf
,然后启动Logstash。
sudo systemctl start logstash
sudo systemctl enable logstash
部署Filebeat
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install filebeat
在/etc/filebeat/filebeat.yml
中配置输出到Logstash或Elasticsearch,并设置日志输入源。
sudo systemctl start filebeat
sudo systemctl enable filebeat
以上步骤是在基于Debian/Ubuntu的系统上的部署示例。对于Red Hat/CentOS等系统,需要使用yum
替换apt-get
。
注意:在生产环境中,你可能需要对Elasticsearch进行性能调优,配置集群,以及设置索引生命周期管理等。同时,确保Filebeat部署在所有需要监控的服务器上。
评论已关闭