-
-
Save superscott/a1c67871cdd54b0c8693 to your computer and use it in GitHub Desktop.
DAEMON_PATH=/opt/kafka/bin | |
DAEMON_NAME=kafka | |
# Check that networking is up. | |
#[ ${NETWORKING} = "no" ] && exit 0 | |
PATH=$PATH:$DAEMON_PATH | |
# See how we were called. | |
case "$1" in | |
start) | |
# Start daemon. | |
echo "Starting $DAEMON_NAME"; | |
nohup $DAEMON_PATH/kafka-server-start.sh -daemon /opt/kafka/config/server.properties | |
;; | |
stop) | |
# Stop daemons. | |
echo "Shutting down $DAEMON_NAME"; | |
pid=`ps ax | grep -i 'kafka.Kafka' | grep -v grep | awk '{print $1}'` | |
if [ -n "$pid" ] | |
then | |
kill -9 $pid | |
else | |
echo "Kafka was not Running" | |
fi | |
;; | |
restart) | |
$0 stop | |
sleep 2 | |
$0 start | |
;; | |
status) | |
pid=`ps ax | grep -i 'kafka.Kafka' | grep -v grep | awk '{print $1}'` | |
if [ -n "$pid" ] | |
then | |
echo "Kafka is Running as PID: $pid" | |
else | |
echo "Kafka is not Running" | |
fi | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|status}" | |
exit 1 | |
esac | |
exit 0 |
Thanks, working fine. If someone wants to out log form kafka than remove -daemon flag and add output to > /var/log/kafka/kafka.log 2>&1 &
Works nicely, cheers!
Might want to update that DAEMON_PATH
variable to remove the /bin
at the end and use the same variable on the config path. My installation of Kafka isn't in /opt/kafka
, it's in /usr/local/kafka
. This wasn't working because it's trying to start the daemon with the wrong path for the configs. I'm sure a lot of people following install guides online have their Kafka installs in that same path.
I have configured successfully but it did not start on startup.
Don't forget that the init.d script alone won't cause automated start up. Once you have the script in the right place, you need to use chkconfig or sysv-rc-conf to turn ot on for the appropriate run levels.
Working fine, but daemon starts as root user.