+ PATH=/sbin:/usr/sbin:/bin:/usr/bin
+ export PATH
+ id -u
+ [ 0 -ne 0 ]
+ name=logstash
+ pidfile=/var/run/logstash.pid
+ LS_USER=logstash
+ LS_GROUP=logstash
+ LS_HOME=/var/lib/logstash
+ LS_HEAP_SIZE=1g
+ LS_LOG_DIR=/var/log/logstash
+ LS_LOG_FILE=/var/log/logstash/logstash.log
+ LS_CONF_DIR=/etc/logstash/conf.d
+ LS_OPEN_FILES=16384
+ LS_NICE=19
+ LS_OPTS=
+ [ -r /etc/default/logstash ]
+ . /etc/default/logstash
+ KILL_ON_STOP_TIMEOUT=0
+ [ -r /etc/sysconfig/logstash ]
+ program=/opt/logstash/bin/logstash
+ args=agent -f /etc/logstash/conf.d -l /var/log/logstash/logstash.log
+ status
+ [ -f /var/run/logstash.pid ]
+ cat /var/run/logstash.pid
+ pid=12716
+ kill -0 12716
+ return 2
+ code=2
+ [ 2 -eq 0 ]
+ start
+ LS_JAVA_OPTS= -Djava.io.tmpdir=/var/lib/logstash
+ HOME=/var/lib/logstash
+ export PATH HOME LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING
+ id -Gn logstash
+ + sed s/,$//
tr ,
+ echo
+ SGROUPS=logstash
+ [ ! -z logstash ]
+ EXTRA_GROUPS=--groups logstash
+ ulimit -n 16384
+ echo 22073
+ echo logstash started.
logstash started.
+ return 0
+ code=0
+ exit 0
+ nice -n 19 chroot --userspec logstash:logstash --groups logstash / sh -c
cd /var/lib/logstash
ulimit -n 16384
exec "/opt/logstash/bin/logstash" agent -f /etc/logstash/conf.d -l /var/log/logstash/logstash.log
以上是logstash服务启动时的命令输出。 (通过将-x开关添加到init.d脚本的开头 - #!/ bin / sh -x )来实现此目的
使用Ubuntu 14.04上的DEB软件包安装Logstash v2.2.0
当我运行init脚本使用的exec命令时(如上面的输出所示),logstash启动程序非常好并且运行完美
"/opt/logstash/bin/logstash" agent -f /etc/logstash/conf.d -l /var/log/logstash/logstash.log
init.d服务脚本中存在导致logstash作为服务失败的内容。我怀疑init脚本使用的 nice 命令。
你们看到' nice '在init脚本中使用的命令?
+ nice -n 19 chroot --userspec logstash:logstash --groups logstash / sh -c
cd /var/lib/logstash
ulimit -n 16384
exec "/opt/logstash/bin/logstash" agent -f /etc/logstash/conf.d -l /var/log/logstash/logstash.log
答案 0 :(得分:1)
当您卸载旧版本时,logstash
用户和组也被删除了。现在,在新安装的情况下,使用不同的logstash
和uid
创建了一个新的gid
用户和组。但是,常见logstash目录的所有权属于旧logstash
uid
和gid
。
现在,当您启动新的logstash时,它会尝试读取/写入此目录并因此失败,因此logstash未运行。
尝试更改这些目录的所有权并启动logstash
chown -R logstash:logstash /var/log/logstash
chown -R logstash:logstash /var/lib/logstash
chown -R logstash:logstash /etc/logstash
rm -rf /var/run/logstash.pid
/etc/init.d/logstash start