之前在服务器上设置了filebeat采集日志,在ssh远程断开后filebeat会自动挂掉,造成无法继续采集日志。这个解决的方法有很多,比如将fileteat启动命令加入/etc/bashrc,或者用screen等等。这里采用将filebeat加入守护进程的方式:
vi /usr/lib/systemd/system/filebeat.service
[Unit]
Description=filebeat
Wants=network-online.target
After=network-online.target
[Service]
User=root
ExecStart=/opt/beat/filebeat-7.4.0-linux-x86_64/filebeat -e -c /opt/beat/filebeat-7.4.0-linux-x86_64/filebeat.yml
Restart=always
[Install]
WantedBy=multi-user.target
开启服务并设置开机自启。
systemctl start filebeat.service
systemctl enable filebeat.service