1新锈、用cd 命令切換到/etc/rc.d/init.d/目錄下
[root@bogon ~]# cd /etc/rc.d/init.d
2甲脏、用touch zookeeper創(chuàng)建一個(gè)文件
[root@bogon init.d]# touch zookeeper
3、添加可執(zhí)行權(quán)限
[root@bogon init.d]# chmod +x zookeeper
4、編輯zookeeper這個(gè)文件块请,添加以下內(nèi)容
[root@bogon init.d]# vi zookeeper
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
case $1 in
start) su root /usr/local/java/zookeeper-3.4.5/bin/zkServer.sh start;;
stop) su root /usr/local/java/zookeeper-3.4.5/bin/zkServer.sh stop;;
status) su root /usr/local/java/zookeeper-3.4.5/bin/zkServer.sh status;;
restart) su root /usr/local/java/zookeeper-3.4.5/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
5娜氏、使用wq保存并退出
6、啟動(dòng)/停止zookeeper服務(wù)
[root@bogon init.d]# service zookeeper start
JMX enabled by default
Using config: /usr/local/java/zookeeper-3.4.5/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
7墩新、把zookeeper添加到開機(jī)啟動(dòng)里面
[root@bogon init.d]# chkconig --add zookeeper