jdk 路徑爲/usr/local/javajava
zk路徑爲/use/local/zookeepervim
cd /etc/rc.d/init.d/ vim zookeeper # 添加以下腳本 #!/bin/bash ZK_PATH=/usr/local/zookeeper export JAVA_HOME=/usr/local/java case $1 in start) sh $ZK_PATH/bin/zkServer.sh start;; stop) sh $ZK_PATH/bin/zkServer.sh stop;; status) sh $ZK_PATH/bin/zkServer.sh status;; restart) sh $ZK_PATH/bin/zkServer.sh restart;; *) echo "require start|stop|status|restart" ;; esac
保存bash
#將腳本註冊爲service chkconfig --add zookeeper # 查看 chkconfig --list
#啓動
service zookeeper start
#中止
service zookeeper stop
#從新啓動
service zookeeper restart
# 查看狀態
service zookeeper status