博客
关于我
logstash设置开机自启动
阅读量:798 次
发布时间:2023-02-06

本文共 1102 字,大约阅读时间需要 3 分钟。

在Linux系统中设置Logstash开机自启动

在Linux系统中,Logstash可以通过systemd服务管理器实现开机自启动。以下是具体的操作步骤:

1. 创建Logstash服务文件

/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/路径。

2. 启动Logstash服务

启动服务并设置开机自启动(如果服务已有进程,请先停止它):

systemctl enable --now logstash.service

3. 验证服务状态

启动服务后,日志文件会出现在/etc/logstash/logs/目录下。可以通过以下命令查看服务状态:

systemctl status logstash

4. 常见问题排查

用户权限问题

如果未看到日志输出,请检查以下内容:

  • 查看日志中是否有提示,例如:
  • [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.
    1. 创建logstash用户并赋予权限:
    2. useradd logstashchown -R logstash:logstash /etc/logstash/

      其他问题

      如果服务无法启动,可能是由于配置文件路径错误或依赖缺失导致。请确保以下条件满足:

      • Logstash安装目录为/etc/logstash/
      • 配置文件路径正确
      • Java环境变量配置正确

    转载地址:http://ujufk.baihongyu.com/

    你可能感兴趣的文章
    NMF(非负矩阵分解)
    查看>>
    nmon_x86_64_centos7工具如何使用
    查看>>
    NN&DL4.1 Deep L-layer neural network简介
    查看>>
    NN&DL4.3 Getting your matrix dimensions right
    查看>>
    NN&DL4.7 Parameters vs Hyperparameters
    查看>>
    NN&DL4.8 What does this have to do with the brain?
    查看>>
    nnU-Net 终极指南
    查看>>
    No 'Access-Control-Allow-Origin' header is present on the requested resource.
    查看>>
    No 'Access-Control-Allow-Origin' header is present on the requested resource.
    查看>>
    NO 157 去掉禅道访问地址中的zentao
    查看>>
    no available service ‘default‘ found, please make sure registry config corre seata
    查看>>
    No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    查看>>
    no connection could be made because the target machine actively refused it.问题解决
    查看>>
    No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
    查看>>
    No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
    查看>>
    No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
    查看>>
    No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
    查看>>
    No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
    查看>>
    No module named 'crispy_forms'等使用pycharm开发
    查看>>
    No module named 'pandads'
    查看>>