Logstash does not start after server reboot

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












There is /etc/rc.d/init.d/logstash script on server CentOS release 6.9. Please find example below. To start logstash service automatically after server reboot I added logstash into chkconfig.



I used the following commands:



To add in the chkconfig:



sudo /sbin/chkconfig --add logstash


To make sure it is in the chkconfig:



sudo /sbin/chkconfig --list logstash
logstash 0:off 1:off 2:on 3:on 4:on 5:on 6:off


Set it to autostart:



sudo /sbin/chkconfig logstash on


But logstash does not load automatically after server reboot. I do not understand cause for this. Сould you please tell me if you know?



#!/bin/sh
# Init script for logstash
# Maintained by Elasticsearch
# Generated by pleaserun.
# Implemented based on LSB Core 3.1:
# * Sections: 20.2, 20.3
#
### BEGIN INIT INFO
# Provides: logstash
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description:
# Description: Starts Logstash as a daemon.
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

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

name=logstash
pidfile="/var/run/$name.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="$LS_LOG_DIR/$name.log"
LS_CONF_DIR=/etc/logstash/conf.d
LS_OPEN_FILES=16384
LS_NICE=19
KILL_ON_STOP_TIMEOUT=$KILL_ON_STOP_TIMEOUT-0 #default value is zero to this variable but could be updated by user request
LS_OPTS=""


[ -r /etc/default/$name ] && . /etc/default/$name
[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name

program=/opt/logstash/bin/logstash
args="agent -f $LS_CONF_DIR -l $LS_LOG_FILE $LS_OPTS"

quiet()
"$@" > /dev/null 2>&1
return $?


start() tr " " ","

stop() break
sleep 1
done
if status ; then
if [ $KILL_ON_STOP_TIMEOUT -eq 1 ] ; then
echo "Timeout reached. Killing $name (pid $pid) with SIGKILL. This may result in data loss."
kill -KILL $pid
echo "$name killed with SIGKILL."
else
echo "$name stop failed; still running."
return 1 # stop timed out and not forced
fi
else
echo "$name stopped."
fi
fi


status()
if [ -f "$pidfile" ] ; then
pid=`cat "$pidfile"`
if kill -0 $pid > /dev/null 2> /dev/null ; then
# process by this pid is running.
# It may not be our pid, but that's what you get with just pidfiles.
# TODO(sissel): Check if this process seems to be the same as the one we
# expect. It'd be nice to use flock here, but flock uses fork, not exec,
# so it makes it quite awkward to use in this case.
return 0
else
return 2 # program is dead but pid file exists
fi
else
return 3 # program is not running
fi


reload()
if status ; then
kill -HUP `cat "$pidfile"`
fi


force_stop()
if status ; then
stop
status && kill -KILL `cat "$pidfile"`
fi


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

HOME=$LS_HOME
export PATH HOME

test_args="--configtest -f $LS_CONF_DIR $LS_OPTS"
$program $test_args
[ $? -eq 0 ] && return 0
# Program not configured
return 6


case "$1" in
start)
status
code=$?
if [ $code -eq 0 ]; then
echo "$name is already running"
else
start
code=$?
fi
exit $code
;;
stop) stop ;;
force-stop) force_stop ;;
status)
status
code=$?
if [ $code -eq 0 ] ; then
echo "$name is running"
else
echo "$name is not running"
fi
exit $code
;;
reload) reload ;;
restart)

quiet configtest
RET=$?
if [ $RET -ne 0 ]; then
echo "Configuration error. Not restarting. Re-run with configtest parameter for details"
exit $RET
fi
stop && start
;;
configtest)
configtest
exit $?
;;
*)
echo "Usage: $SCRIPTNAME stop" >&2
exit 3
;;
esac

exit $?






share|improve this question






















  • What do you have in logs of logstash after system up? When you try to start logstash manually via /etc/rc.d/init.d/logstash start it up correctly?
    – mariaczi
    Mar 15 at 12:58














up vote
0
down vote

favorite












There is /etc/rc.d/init.d/logstash script on server CentOS release 6.9. Please find example below. To start logstash service automatically after server reboot I added logstash into chkconfig.



I used the following commands:



To add in the chkconfig:



sudo /sbin/chkconfig --add logstash


To make sure it is in the chkconfig:



sudo /sbin/chkconfig --list logstash
logstash 0:off 1:off 2:on 3:on 4:on 5:on 6:off


Set it to autostart:



sudo /sbin/chkconfig logstash on


But logstash does not load automatically after server reboot. I do not understand cause for this. Сould you please tell me if you know?



#!/bin/sh
# Init script for logstash
# Maintained by Elasticsearch
# Generated by pleaserun.
# Implemented based on LSB Core 3.1:
# * Sections: 20.2, 20.3
#
### BEGIN INIT INFO
# Provides: logstash
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description:
# Description: Starts Logstash as a daemon.
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

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

name=logstash
pidfile="/var/run/$name.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="$LS_LOG_DIR/$name.log"
LS_CONF_DIR=/etc/logstash/conf.d
LS_OPEN_FILES=16384
LS_NICE=19
KILL_ON_STOP_TIMEOUT=$KILL_ON_STOP_TIMEOUT-0 #default value is zero to this variable but could be updated by user request
LS_OPTS=""


[ -r /etc/default/$name ] && . /etc/default/$name
[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name

program=/opt/logstash/bin/logstash
args="agent -f $LS_CONF_DIR -l $LS_LOG_FILE $LS_OPTS"

quiet()
"$@" > /dev/null 2>&1
return $?


start() tr " " ","

stop() break
sleep 1
done
if status ; then
if [ $KILL_ON_STOP_TIMEOUT -eq 1 ] ; then
echo "Timeout reached. Killing $name (pid $pid) with SIGKILL. This may result in data loss."
kill -KILL $pid
echo "$name killed with SIGKILL."
else
echo "$name stop failed; still running."
return 1 # stop timed out and not forced
fi
else
echo "$name stopped."
fi
fi


status()
if [ -f "$pidfile" ] ; then
pid=`cat "$pidfile"`
if kill -0 $pid > /dev/null 2> /dev/null ; then
# process by this pid is running.
# It may not be our pid, but that's what you get with just pidfiles.
# TODO(sissel): Check if this process seems to be the same as the one we
# expect. It'd be nice to use flock here, but flock uses fork, not exec,
# so it makes it quite awkward to use in this case.
return 0
else
return 2 # program is dead but pid file exists
fi
else
return 3 # program is not running
fi


reload()
if status ; then
kill -HUP `cat "$pidfile"`
fi


force_stop()
if status ; then
stop
status && kill -KILL `cat "$pidfile"`
fi


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

HOME=$LS_HOME
export PATH HOME

test_args="--configtest -f $LS_CONF_DIR $LS_OPTS"
$program $test_args
[ $? -eq 0 ] && return 0
# Program not configured
return 6


case "$1" in
start)
status
code=$?
if [ $code -eq 0 ]; then
echo "$name is already running"
else
start
code=$?
fi
exit $code
;;
stop) stop ;;
force-stop) force_stop ;;
status)
status
code=$?
if [ $code -eq 0 ] ; then
echo "$name is running"
else
echo "$name is not running"
fi
exit $code
;;
reload) reload ;;
restart)

quiet configtest
RET=$?
if [ $RET -ne 0 ]; then
echo "Configuration error. Not restarting. Re-run with configtest parameter for details"
exit $RET
fi
stop && start
;;
configtest)
configtest
exit $?
;;
*)
echo "Usage: $SCRIPTNAME stop" >&2
exit 3
;;
esac

exit $?






share|improve this question






















  • What do you have in logs of logstash after system up? When you try to start logstash manually via /etc/rc.d/init.d/logstash start it up correctly?
    – mariaczi
    Mar 15 at 12:58












up vote
0
down vote

favorite









up vote
0
down vote

favorite











There is /etc/rc.d/init.d/logstash script on server CentOS release 6.9. Please find example below. To start logstash service automatically after server reboot I added logstash into chkconfig.



I used the following commands:



To add in the chkconfig:



sudo /sbin/chkconfig --add logstash


To make sure it is in the chkconfig:



sudo /sbin/chkconfig --list logstash
logstash 0:off 1:off 2:on 3:on 4:on 5:on 6:off


Set it to autostart:



sudo /sbin/chkconfig logstash on


But logstash does not load automatically after server reboot. I do not understand cause for this. Сould you please tell me if you know?



#!/bin/sh
# Init script for logstash
# Maintained by Elasticsearch
# Generated by pleaserun.
# Implemented based on LSB Core 3.1:
# * Sections: 20.2, 20.3
#
### BEGIN INIT INFO
# Provides: logstash
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description:
# Description: Starts Logstash as a daemon.
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

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

name=logstash
pidfile="/var/run/$name.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="$LS_LOG_DIR/$name.log"
LS_CONF_DIR=/etc/logstash/conf.d
LS_OPEN_FILES=16384
LS_NICE=19
KILL_ON_STOP_TIMEOUT=$KILL_ON_STOP_TIMEOUT-0 #default value is zero to this variable but could be updated by user request
LS_OPTS=""


[ -r /etc/default/$name ] && . /etc/default/$name
[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name

program=/opt/logstash/bin/logstash
args="agent -f $LS_CONF_DIR -l $LS_LOG_FILE $LS_OPTS"

quiet()
"$@" > /dev/null 2>&1
return $?


start() tr " " ","

stop() break
sleep 1
done
if status ; then
if [ $KILL_ON_STOP_TIMEOUT -eq 1 ] ; then
echo "Timeout reached. Killing $name (pid $pid) with SIGKILL. This may result in data loss."
kill -KILL $pid
echo "$name killed with SIGKILL."
else
echo "$name stop failed; still running."
return 1 # stop timed out and not forced
fi
else
echo "$name stopped."
fi
fi


status()
if [ -f "$pidfile" ] ; then
pid=`cat "$pidfile"`
if kill -0 $pid > /dev/null 2> /dev/null ; then
# process by this pid is running.
# It may not be our pid, but that's what you get with just pidfiles.
# TODO(sissel): Check if this process seems to be the same as the one we
# expect. It'd be nice to use flock here, but flock uses fork, not exec,
# so it makes it quite awkward to use in this case.
return 0
else
return 2 # program is dead but pid file exists
fi
else
return 3 # program is not running
fi


reload()
if status ; then
kill -HUP `cat "$pidfile"`
fi


force_stop()
if status ; then
stop
status && kill -KILL `cat "$pidfile"`
fi


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

HOME=$LS_HOME
export PATH HOME

test_args="--configtest -f $LS_CONF_DIR $LS_OPTS"
$program $test_args
[ $? -eq 0 ] && return 0
# Program not configured
return 6


case "$1" in
start)
status
code=$?
if [ $code -eq 0 ]; then
echo "$name is already running"
else
start
code=$?
fi
exit $code
;;
stop) stop ;;
force-stop) force_stop ;;
status)
status
code=$?
if [ $code -eq 0 ] ; then
echo "$name is running"
else
echo "$name is not running"
fi
exit $code
;;
reload) reload ;;
restart)

quiet configtest
RET=$?
if [ $RET -ne 0 ]; then
echo "Configuration error. Not restarting. Re-run with configtest parameter for details"
exit $RET
fi
stop && start
;;
configtest)
configtest
exit $?
;;
*)
echo "Usage: $SCRIPTNAME stop" >&2
exit 3
;;
esac

exit $?






share|improve this question














There is /etc/rc.d/init.d/logstash script on server CentOS release 6.9. Please find example below. To start logstash service automatically after server reboot I added logstash into chkconfig.



I used the following commands:



To add in the chkconfig:



sudo /sbin/chkconfig --add logstash


To make sure it is in the chkconfig:



sudo /sbin/chkconfig --list logstash
logstash 0:off 1:off 2:on 3:on 4:on 5:on 6:off


Set it to autostart:



sudo /sbin/chkconfig logstash on


But logstash does not load automatically after server reboot. I do not understand cause for this. Сould you please tell me if you know?



#!/bin/sh
# Init script for logstash
# Maintained by Elasticsearch
# Generated by pleaserun.
# Implemented based on LSB Core 3.1:
# * Sections: 20.2, 20.3
#
### BEGIN INIT INFO
# Provides: logstash
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description:
# Description: Starts Logstash as a daemon.
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

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

name=logstash
pidfile="/var/run/$name.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="$LS_LOG_DIR/$name.log"
LS_CONF_DIR=/etc/logstash/conf.d
LS_OPEN_FILES=16384
LS_NICE=19
KILL_ON_STOP_TIMEOUT=$KILL_ON_STOP_TIMEOUT-0 #default value is zero to this variable but could be updated by user request
LS_OPTS=""


[ -r /etc/default/$name ] && . /etc/default/$name
[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name

program=/opt/logstash/bin/logstash
args="agent -f $LS_CONF_DIR -l $LS_LOG_FILE $LS_OPTS"

quiet()
"$@" > /dev/null 2>&1
return $?


start() tr " " ","

stop() break
sleep 1
done
if status ; then
if [ $KILL_ON_STOP_TIMEOUT -eq 1 ] ; then
echo "Timeout reached. Killing $name (pid $pid) with SIGKILL. This may result in data loss."
kill -KILL $pid
echo "$name killed with SIGKILL."
else
echo "$name stop failed; still running."
return 1 # stop timed out and not forced
fi
else
echo "$name stopped."
fi
fi


status()
if [ -f "$pidfile" ] ; then
pid=`cat "$pidfile"`
if kill -0 $pid > /dev/null 2> /dev/null ; then
# process by this pid is running.
# It may not be our pid, but that's what you get with just pidfiles.
# TODO(sissel): Check if this process seems to be the same as the one we
# expect. It'd be nice to use flock here, but flock uses fork, not exec,
# so it makes it quite awkward to use in this case.
return 0
else
return 2 # program is dead but pid file exists
fi
else
return 3 # program is not running
fi


reload()
if status ; then
kill -HUP `cat "$pidfile"`
fi


force_stop()
if status ; then
stop
status && kill -KILL `cat "$pidfile"`
fi


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

HOME=$LS_HOME
export PATH HOME

test_args="--configtest -f $LS_CONF_DIR $LS_OPTS"
$program $test_args
[ $? -eq 0 ] && return 0
# Program not configured
return 6


case "$1" in
start)
status
code=$?
if [ $code -eq 0 ]; then
echo "$name is already running"
else
start
code=$?
fi
exit $code
;;
stop) stop ;;
force-stop) force_stop ;;
status)
status
code=$?
if [ $code -eq 0 ] ; then
echo "$name is running"
else
echo "$name is not running"
fi
exit $code
;;
reload) reload ;;
restart)

quiet configtest
RET=$?
if [ $RET -ne 0 ]; then
echo "Configuration error. Not restarting. Re-run with configtest parameter for details"
exit $RET
fi
stop && start
;;
configtest)
configtest
exit $?
;;
*)
echo "Usage: $SCRIPTNAME stop" >&2
exit 3
;;
esac

exit $?








share|improve this question













share|improve this question




share|improve this question








edited Mar 15 at 14:05









galoget

36319




36319










asked Mar 15 at 9:42









Mikhail

1




1











  • What do you have in logs of logstash after system up? When you try to start logstash manually via /etc/rc.d/init.d/logstash start it up correctly?
    – mariaczi
    Mar 15 at 12:58
















  • What do you have in logs of logstash after system up? When you try to start logstash manually via /etc/rc.d/init.d/logstash start it up correctly?
    – mariaczi
    Mar 15 at 12:58















What do you have in logs of logstash after system up? When you try to start logstash manually via /etc/rc.d/init.d/logstash start it up correctly?
– mariaczi
Mar 15 at 12:58




What do you have in logs of logstash after system up? When you try to start logstash manually via /etc/rc.d/init.d/logstash start it up correctly?
– mariaczi
Mar 15 at 12:58















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430353%2flogstash-does-not-start-after-server-reboot%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430353%2flogstash-does-not-start-after-server-reboot%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay