添加zookeeper到服務,並設置開機啓動

1、先安裝jdk

jdk 路徑爲/usr/local/javajava

2、再安裝zookeeper

zk路徑爲/use/local/zookeepervim

3、建立zookeeper腳本

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 

4、zk 操做

#啓動
service  zookeeper start
#中止
service zookeeper   stop
#從新啓動
service  zookeeper   restart 
# 查看狀態
service  zookeeper  status
相關文章
相關標籤/搜索