本文共 1102 字,大约阅读时间需要 3 分钟。
在Linux系统中,Logstash可以通过systemd服务管理器实现开机自启动。以下是具体的操作步骤:
在/etc/systemd/system/
目录下创建名为logstash.service
的文件,文件内容如下:
[Unit]Description=logstash[Service]Type=simpleUser=logstashGroup=logstashExecStart=/etc/logstash/bin/logstash -f /etc/logstash/config/logstash-prod.confRestart=always[Install]WantedBy=multi-user.target
注意事项:
ExecStart
指定了Logstash的启动命令,其中-f
参数指定了配置文件路径。Restart=always
配置了服务重启策略。/etc/logstash/config/
路径。启动服务并设置开机自启动(如果服务已有进程,请先停止它):
systemctl enable --now logstash.service
启动服务后,日志文件会出现在/etc/logstash/logs/
目录下。可以通过以下命令查看服务状态:
systemctl status logstash
如果未看到日志输出,请检查以下内容:
[2024-01-15T10:56:00,726][WARN][deprecation.logstash.runner] NOTICE: Running Logstash as superuser is not recommended and won't be allowed in the future. Set 'allow_superuser' to 'false' to avoid startup errors in future releases.
logstash
用户并赋予权限:useradd logstashchown -R logstash:logstash /etc/logstash/
如果服务无法启动,可能是由于配置文件路径错误或依赖缺失导致。请确保以下条件满足:
/etc/logstash/
转载地址:http://ujufk.baihongyu.com/