在 CentOS 上让 Filebeat 在后台运行,常见有以下几种方式,推荐用 systemd(CentOS 7+ 标准做法)。
systemctl start filebeat
systemctl enable filebeat
systemctl status filebeat
journalctl -u filebeat -f
如果你是通过 RPM 安装的 Filebeat,systemd 服务一般已经自动配置好。
nohup /usr/share/filebeat/bin/filebeat -c /etc/filebeat/filebeat.yml > /var/log/filebeat.log 2>&1 &
查看进程:
ps -ef | grep filebeat
⚠️ 缺点:
screen -S filebeat
/usr/share/filebeat/bin/filebeat -c /etc/filebeat/filebeat.yml
然后 Ctrl + A + D 退出。
确认是否已安装:
rpm -qa | grep filebeat
如未安装:
yum install filebeat
默认:
/etc/filebeat/filebeat.yml
filebeat test config
| 场景 | 推荐方式 |
|---|---|
| 生产环境 | systemctl |
| 临时测试 | nohup |
| 调试 | journalctl |
如果你是 CentOS 6 或 容器环境,可以告诉我,我可以给你对应方案。