由于权限原因,logstash服务无法启动

先生

我在ubuntu 14 LTS下安装了logstash作为服务,但是启动服务(sudo service logstash start时出现以下错误

{:timestamp=>"2016-04-24T13:10:15.260000+0700", :message=>"The error reported is: \n  Permission denied - /opt/elk-stack/logstash-1.5.3/vendor/bundle/jruby/1.9/gems/addressable-2.3.8/data/unicode.data"}

这是该unicode.data文件的权限

-rwxrwxrwx 1 tuan sudo 115740 Jul 21  2015 /opt/elk-stack/logstash-1.5.3/vendor/bundle/jruby/1.9/gems/addressable-2.3.8/data/unicode.data

运行命令时:

sudo bin/logstash -f logstash.conf

有效!

我的/etc/default/logstash档案:

###############################
# Default settings for logstash
# /etc/default/logstash
###############################

# Override Java location
JAVACMD=/usr/bin/java

# Set a home directory
LS_HOME=/opt/elk-stack/logstash-1.5.3/tmp

# Arguments to pass to logstash agent
LS_OPTS=""
LS_HEAP_SIZE="500m"
LS_JAVA_OPTS="-Djava.io.tmpdir=$HOME"

# pidfiles aren't used for upstart; this is for sysv users.
LS_PIDFILE=/var/run/logstash.pid

# user id to be invoked as; for upstart: edit /etc/init/logstash.conf
LS_USER=root

# logstash logging
LS_LOG_FILE=/var/log/logstash.log
LS_USE_GC_LOGGING="true"

# logstash configuration directory
LS_CONF_DIR=/opt/elk-stack/logstash-1.5.3

# Open file limit; cannot be overridden in upstart
LS_OPEN_FILES=40

# Nice level
LS_NICE=19

# If this is set to 1, then when `stop` is called, if the process has
# not exited within a reasonable time, SIGKILL will be sent next.
# The default behavior is to simply log a message "program stop failed; still running"
KILL_ON_STOP_TIMEOUT=0

这是初始化脚本:

#!/bin/bash
#
# /etc/init.d/logstash -- startup script for LogStash.
#
### BEGIN INIT INFO
# Provides:          logstash
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts logstash
# Description:       Starts logstash using start-stop-daemon
### END INIT INFO

set -e

NAME=logstash
DESC="Logstash Daemon"
DEFAULT=/etc/default/$NAME

if [ `id -u` -ne 0 ]; then
   echo "You need root privileges to run this script"
   exit 1
fi

. /lib/lsb/init-functions

if [ -r /etc/default/rcS ]; then
   . /etc/default/rcS
fi

# The following variables can be overwritten in $DEFAULT
PATH=/bin:/usr/bin:/sbin:/usr/sbin

# overwrite settings from default file
if [ -f "$DEFAULT" ]; then
   . "$DEFAULT"
fi

# Define other required variables
PID_FILE=${LS_PIDFILE}
DAEMON=/opt/elk-stack/logstash-1.5.3/bin/logstash
DAEMON_OPTS="agent -f ${LS_CONF_DIR}/${NAME}.conf -l ${LS_LOG_FILE} ${LS_OPTS}"

# Check DAEMON exists
if ! test -e $DAEMON; then
   log_failure_msg "Script $DAEMON doesn't exist"
   exit 1
fi

case "$1" in
   start)
      if [ -z "$DAEMON" ]; then
         log_failure_msg "no logstash script found - $DAEMON"
         exit 1
      fi

      # Check if a config file exists
      if [ ! "$(ls -A $LS_CONF_DIR/*.conf 2> /dev/null)" ]; then
         log_failure_msg "There aren't any configuration files in $LS_CONF_DIR"
         exit 1
      fi

      log_daemon_msg "Starting $DESC"

      # Parse the actual JAVACMD from the process' environment, we don't care about errors.
      JAVA=$(cat /proc/$(cat "${PID_FILE}" 2>/dev/null)/environ 2>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)
      if start-stop-daemon --test --start --pidfile "$PID_FILE" \
         --user "$LS_USER" --exec "$JAVA" \
      >/dev/null; then
         # Prepare environment
         HOME="${HOME:-$LS_HOME}"
         LS_JAVA_OPTS="${LS_JAVA_OPTS} -Djava.io.tmpdir=${LS_HOME}"
         ulimit -n ${LS_OPEN_FILES}
         cd "${LS_HOME}"
         export PATH HOME JAVACMD LS_HEAP_SIZE LS_JAVA_OPTS LS_USE_GC_LOGGING

         # Start Daemon
         start-stop-daemon --start -b --user "$LS_USER" -c "$LS_USER":"$LS_GROUP" \
           -d "$LS_HOME" --nicelevel "$LS_NICE" --pidfile "$PID_FILE" --make-pidfile \
           --exec $DAEMON -- $DAEMON_OPTS

         sleep 1

         # Parse the actual JAVACMD from the process' environment, we don't care about errors.
         JAVA=$(cat /proc/$(cat "${PID_FILE}" 2>/dev/null)/environ 2>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)
         if start-stop-daemon --test --start --pidfile "$PID_FILE" \
             --user "$LS_USER" --exec "$JAVA" \
         >/dev/null; then

            if [ -f "$PID_FILE" ]; then
               rm -f "$PID_FILE"
            fi

            log_end_msg 1
         else
            log_end_msg 0
         fi
      else
         log_progress_msg "(already running)"
         log_end_msg 0
      fi
   ;;
   stop)
      log_daemon_msg "Stopping $DESC"

      set +e

      if [ -f "$PID_FILE" ]; then
         start-stop-daemon --stop --pidfile "$PID_FILE" \
            --user "$LS_USER" \
            --retry=TERM/20/KILL/5 >/dev/null

         if [ $? -eq 1 ]; then
            log_progress_msg "$DESC is not running but pid file exists, cleaning up"
         elif [ $? -eq 3 ]; then
            PID="`cat $PID_FILE`"
            log_failure_msg "Failed to stop $DESC (pid $PID)"
            exit 1
         fi

         rm -f "$PID_FILE"
      else
         log_progress_msg "(not running)"
      fi

      log_end_msg 0
      set -e
   ;;
   status)
      set +e

      # Parse the actual JAVACMD from the process' environment, we don't care about errors.
      JAVA=$(cat /proc/$(cat "${PID_FILE}" 2>/dev/null)/environ 2>/dev/null | grep -z ^JAVACMD= | cut -d= -f2)
      start-stop-daemon --test --start --pidfile "$PID_FILE" \
         --user "$LS_USER" --exec "$JAVA" \
      >/dev/null 2>&1

      if [ "$?" = "0" ]; then
         if [ -f "$PID_FILE" ]; then
            log_success_msg "$DESC is not running, but pid file exists."
            exit 1
         else
            log_success_msg "$DESC is not running."
            exit 3
         fi
      else
         log_success_msg "$DESC is running with pid `cat $PID_FILE`"
      fi

      set -e
   ;;
   restart|force-reload)
      if [ -f "$PID_FILE" ]; then
         $0 stop
         sleep 1
      fi

      $0 start
   ;;
   *)
      log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}"
      exit 1
   ;;
esac

exit 0

有人可以帮我吗?

先生

最后,我通过更改值来修复它:

LS_OPEN_FILES=40

到更大的一个。就我而言,是400原因是init脚本运行该命令ulimit,看来40不足以容纳logstash!

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

由于权限错误而无法启动jstatd

Spring Boot jar由于缺少ServletWebServerFactory bean而无法启动Web服务器

码头工人如何找出服务无法启动的原因

如何解决RabbitMQ服务无法启动的原因?

MongoDB服务无法启动。errno:13权限被拒绝

由于缺少pg gem,Rails服务器无法启动。卸载了postgres,但是出现了同样的错误

由于不再存在的类中的ClassNotFoundException,Android服务无法启动

由于TypeError无法启动服务器

错误1069:服务由于登录失败而无法启动?(试过一切)

由于NoMethodError而无法启动Rack服务器

由于elifecycle错误代码,Node和React无法启动服务器

由于服务类错误,Spring Boot应用无法启动

Logstash 6.7.0无法在macOS Mojave(10.14.4)上启动并显示错误“错误:权限被拒绝-权限被拒绝”

无法启动logstash

由于ModuleNotFoundError,Flask无法使用Docker启动服务器:没有名为“ wsgi”的模块

由于无法启动服务而无法卸载postgresql软件包?

Web服务器由于缺少bean而无法启动

由于jboss.persistenceunit中的NullPointer,JBOSS服务器无法启动服务

服务启动和权限被拒绝

服务由于登录失败而无法启动

由于错误而无法启动opscenter:权限被拒绝:“ ./ conf / definitions / opscenter_defs.tar.gz”

由于未知原因,无法创建Windows可启动USB安装程序

由于SQL语法错误,Gammu无法启动服务

由于错误,Apache无法启动

由于AppArmor,MySQL无法启动?

由于错误,MySQL无法启动

WebSocket服务器由于某些原因无法正常工作

由于selinux权限被拒绝而无法启动服务

由于以下问题,无法使用 apache cxf 启动我的 REST 服务

TOP 榜单

热门标签

归档