- 在/etc/init.d/目录下新建zookeeper文件,拷贝以下脚本,修改其中路径
#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
export JAVA_HOME=/usr/bin/java
case $1 in
start) su root /opt/soft/zookeeper-3.4.6/bin/zkServer.sh start;;
stop) su root /opt/soft/zookeeper-3.4.6/bin/zkServer.sh stop;;
status) su root /opt/soft/zookeeper-3.4.6/bin/zkServer.sh status;;
restart) su root /opt/soft/zookeeper-3.4.6/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
- 执行权限:chmod a+x zookeeper
- 安装服务:chkconfig --add zookeeper