nohup启动filebeat会自动退出解决方案

用nohup方式启动filebeat,运行一段时间后,filebeat会自动停止退出,因为filebeat默认会定期检测文件是否有新的内容。

解决办法:将filebeat通过系统后台的方式长期运行。

1,在进入 /etc/systemd/system目录,创建一个filebeat.service文件

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 /root/filebeat-7.17.8-linux-x86_64/filebeat.yml"

Environment="PATH_OPTS=-path.home /root/filebeat-7.17.8-linux-x86_64/filebeat -path.config /root/filebeat-7.17.8-linux-x86_64 -path.data //root/filebeat-7.17.8-linux-x86_64/data -path.logs /root/filebeat-7.17.8-linux-x86_64/logs"

ExecStart=/root/filebeat-7.17.8-linux-x86_64 $LOG_OPTS $CONFIG_OPTS $PATH_OPTS

Restart=always

[Install]

WantedBy=multi-user.target

将上面filebeat目录改成你的filebeat安装目录

2,给予可执行的权限

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

3,后台启动服务

systemctl daemon-reload

systemctl enable filebeat

systemctl start filebeat

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。