在CentOS上部署Filebeat时,以下是一些最佳实践:
选择合适的Filebeat版本:根据你的Elasticsearch版本选择兼容的Filebeat版本。例如,如果你使用的是Elasticsearch 7.8.1,那么你应该选择Filebeat 7.8.1。
下载并解压Filebeat:
wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.3.1-linux-x86_64.tar.gz
tar -zvxf filebeat-6.3.1-linux-x86_64.tar.gz
cd filebeat-6.3.1-linux
配置Filebeat:
filebeat.yml
配置文件:filebeat.inputs:
- type: log
paths:
- /usr/local/nginx/logs/access.log
output.logstash:
hosts: ["192.168.1.8:5044"]
output.elasticsearch:
# hosts: ["localhost:9200"]
启动Filebeat:
nohup ./filebeat -e -c filebeat.yml >/dev/null 2>&1 &
ps aux | grep filebeat
配置防火墙:确保Filebeat使用的端口(默认是5044)在防火墙中开放。
firewall-cmd --permanent --add-port=5044/tcp
firewall-cmd --reload
监控和日志管理:
nohup ./filebeat -e -c filebeat.yml > filebeat.log 2>&1 &
高可用性配置:
安全性:
output.logstash.ssl.enabled: true
output.logstash.ssl.certificate: /path/to/certificate.crt
output.logstash.ssl.key: /path/to/private.key
output.logstash.ssl.certificate_authorities: /path/to/ca.crt
通过以上步骤,你可以在CentOS上成功部署并配置Filebeat,实现高效的日志收集和管理。根据实际需求,你还可以进一步调整和优化配置。