版本:filebeat-7.15.2-linux-x86_64.tar.gz
启动方式:nohup ./filebeat -c filebeat.yml &
导致问题:运行一段时候后自动关闭,日志如下
2021-12-09T16:48:57.759+0800 INFO [monitoring] log/log.go:193 Uptime: 34.964941986s
2021-12-09T16:48:57.759+0800 INFO [monitoring] log/log.go:160 Stopping metrics logging.
2021-12-09T16:48:57.760+0800 INFO instance/beat.go:479 filebeat stopped.
vim /usr/lib/systemd/system/filebeat.service #创建文件 文件内容在下边
chmod +x /usr/lib/systemd/system/filebeat.service #给予权限
systemctl daemon-reload 依次执行即可
systemctl enable filebeat
systemctl start filebeat
[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 /usr/local/filebeat/filebeat.yml"
Environment="PATH_OPTS=-path.home /usr/local/filebeat -path.config /usr/local/filebeat -path.data /usr/local/filebeat/data -path.logs /usr/local/filebeat/logs"
ExecStart=/usr/local/filebeat/filebeat $LOG_OPTS $CONFIG_OPTS $PATH_OPTS
Restart=always
[Install]
WantedBy=multi-user.target