在 Debian 系统中,Filebeat 的开机自启方式取决于 Debian 版本 以及 系统初始化方式(systemd / sysVinit)。现在绝大多数 Debian(8 及以上)都使用 systemd。
下面分情况说明。
sudo systemctl enable filebeat
sudo systemctl start filebeat
sudo systemctl status filebeat
sudo systemctl stop filebeat
sudo systemctl restart filebeat
✅ 如果是通过官方 .deb 包安装的 Filebeat,默认已经包含 systemd 服务文件(/lib/systemd/system/filebeat.service)。
sudo update-rc.d filebeat defaults
sudo service filebeat start
systemctl is-enabled filebeat
输出:
enabled ✅ 已开启disabled ❌ 未开启确认安装方式:
which filebeat
filebeat version
如果手动解压安装,需要自己创建 systemd 文件。
[Unit]
Description=Filebeat
After=network.target
[Service]
ExecStart=/usr/share/filebeat/bin/filebeat -c /etc/filebeat/filebeat.yml
Restart=always
User=root
[Install]
WantedBy=multi-user.target
然后:
sudo systemctl daemon-reload
sudo systemctl enable filebeat
sudo systemctl start filebeat
sudo systemctl enable --now filebeat
如果你能告诉我 Debian 版本 和 Filebeat 安装方式(apt / 手动),我可以给你更精确的步骤。