在 Ubuntu 上让 Filebeat 开机自启动,取决于你使用的 Ubuntu 版本 和 初始化系统(systemd / upstart)。目前绝大多数 Ubuntu(16.04+)都使用 systemd。
which filebeat
filebeat version
sudo systemctl enable filebeat
sudo systemctl start filebeat
sudo systemctl status filebeat
看到 active (running) 且 enabled 即表示成功。
sudo systemctl stop filebeat
sudo systemctl restart filebeat
sudo systemctl disable filebeat # 取消开机启动
官方 Filebeat 的 .deb 包默认已经注册了 systemd 服务,你只需要:
sudo systemctl enable filebeat
sudo systemctl start filebeat
如果 service 不存在,可重新安装:
sudo apt install ./filebeat-*.deb
如果是非常老的 Ubuntu(使用 upstart):
sudo update-rc.d filebeat defaults
sudo service filebeat start
重启测试(谨慎操作):
sudo reboot
重启后检查:
systemctl is-enabled filebeat
# 输出应为 enabled
查看日志:
journalctl -u filebeat -f
sudo filebeat test config
sudo filebeat test output
如果你能告诉我:
lsb_release -a)我可以给你更精确的步骤。