1. 程式人生 > >大資料Zookeeper系列之Zookeeper服務開機自啟動配置

大資料Zookeeper系列之Zookeeper服務開機自啟動配置

1.  編寫執行指令碼

$ sudo cd /etc/init.d
$ sudo vi zookeeper

#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
su - hadoop <<!
case $1 in
start)
sh /opt/apache/zookeeper/zookeeper-3.4.13/bin/zkServer.sh start
;;
stop)
sh /opt/apache/zookeeper/zookeeper-3.4.13/bin/zkServer.sh stop
;;
status)
sh /opt/apache/zookeeper/zookeeper-3.4.13/bin/zkServer.sh status
;;
restart)
sh /opt/apache/zookeeper/zookeeper-3.4.13/bin/zkServer.sh restart
;;
*) 
echo "Usage:$0(start|stop|status|restart)" 
;;
esac
exit
!

2.  賦予許可權

$ sudo chmod +x zookeeper 

3.  設定zookeeper服務開機自啟動

$ sudo chkconfig --add zookeeper

4.  檢視zookeeper服務

$ chkconfig --list zookeeper