在 CentOS 下启动 Filebeat,通常有以下几种方式,取决于你的安装方式(RPM 包 / 二进制 / Docker)。下面以 最常见的方式(RPM 安装) 为主说明。
filebeat version
或
rpm -qa | grep filebeat
CentOS 7 / 8 / Stream 默认使用 systemd。
systemctl start filebeat
systemctl enable filebeat
systemctl status filebeat
正常状态应显示:
Active: active (running)
在启动前,建议先测试配置:
filebeat test config
测试输出是否到 Elasticsearch / Logstash:
filebeat test output
适合排查问题:
filebeat -e -c /etc/filebeat/filebeat.yml
-e:输出日志到终端-c:指定配置文件路径| 项目 | 路径 |
|---|---|
| 配置文件 | /etc/filebeat/filebeat.yml |
| 数据目录 | /var/lib/filebeat/ |
| 日志目录 | /var/log/filebeat/ |
| 二进制 | /usr/bin/filebeat |
查看详细日志:
journalctl -u filebeat -xe
或:
tail -f /var/log/filebeat/filebeat
检查:
filebeat.yml 中的 hoststelnet <es或logstashIP> 9200
临时关闭测试:
setenforce 0
docker run -d \
--name filebeat \
-v /var/log:/var/log:ro \
-v /etc/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml \
docker.elastic.co/beats/filebeat:8.x
systemctl start filebeat
systemctl enable filebeat
systemctl status filebeat
如果你愿意,可以贴一下:
filebeat.yml 配置我可以帮你具体排查启动失败或数据不采集的问题。