FILEBEAT后端运行,自动退出解决

通过nohub方式启动filebeat,运行一段时间后filebeat自动退出,原因是filebeat默认会定期检测文件是否有新的内容,如果超过一定时间检测的文件没有任务新日志写入,那么filebeat会自动退出,解决办法就是将filebeat通过系统后台的方式长期运行。

1、在linux操作系统 /etc/systemd/system目录下创建一个filebeat.service文件,写入如下内容:
[Unit]
Description=Filebeat is a lightweight shipper for metrics.
Documentation=https://www.elastic.co/products/beats/filebeat
Wants=network-online.target
After=network-online.target

[Service]
Environment="LOG_OPTS=-e"
Environment="CONFIG_OPTS=-c /home/soft/filebeat-7.15.2-linux-x86_64/filebeat.yml"
Environment="PATH_OPTS=-path.home /home/soft/filebeat-7.15.2-linux-x86_64/filebeat -path.config /home/soft/filebeat-7.15.2-linux-x86_64 -path.data /home/soft/filebeat-7.15.2-linux-x86_64/data -path.logs /home/soft/filebeat-7.15.2-linux-x86_64/logs"
ExecStart=/home/soft/filebeat-7.15.2-linux-x86_64/filebeat $LOG_OPTS $CONFIG_OPTS $PATH_OPTS
Restart=always

[Install]
WantedBy=multi-user.target

2、给该文件给予可执行的权限:

chmod +x /etc/systemd/system/filebeat.service


3、系统后台服务方式启动:

# 依次执行下列命令
systemctl daemon-reload
systemctl enable filebeat
systemctl start filebeat

posted @ 2022-04-25 08:58  飞鹰之歌  阅读(1411)  评论(0)    收藏  举报