在 Debian 里让 Filebeat 开机自启,取决于你的 Debian 版本以及系统初始化方式(systemd 还是 sysVinit)。现在绝大多数 Debian(8+)都是 systemd,下面以 systemd 为主说明。
sudo systemctl enable filebeat
sudo systemctl start filebeat
sudo systemctl status filebeat
sudo systemctl stop filebeat
sudo systemctl restart filebeat
✅ 这样 重启服务器后 Filebeat 会自动启动。
一般通过官方 DEB 包安装后,会自动创建:
/lib/systemd/system/filebeat.service
你可以检查:
systemctl list-unit-files | grep filebeat
如果看到:
filebeat.service enabled
说明已经开机自启。
sudo update-rc.d filebeat defaults
sudo service filebeat start
systemctl 命令不存在说明你用的是非常老的 Debian(<7),建议升级系统。
检查:
journalctl -u filebeat
常见原因:
/etc/filebeat/filebeat.yml)可以模拟重启(谨慎):
sudo reboot
重启后:
ps aux | grep filebeat
如果你愿意,可以告诉我:
cat /etc/debian_version)我可以给你更精确的建议。