参考
https://www.cnblogs.com/zhangmingcheng/p/7455278.html
在 /etc/rc.d/init.d 下创建zookeeper脚本
1 #!/bin/bash 2 #chkconfig:2345 10 90 3 #description:service zookeeper 4 export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64 5 export ZOO_LOG_DIR=/var/log/zookeeper 6 ZOOKEEPER_HOME=/usr/local/zookeeper 7 case "$1" in 8 start) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh start;; 9 start-foreground) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh start-foreground;; 10 stop) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh stop;; 11 status) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh status;; 12 restart) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh restart;; 13 upgrade)su root ${ZOOKEEPER_HOME}/bin/zkServer.sh upgrade;; 14 print-cmd)su root ${ZOOKEEPER_HOME}/bin/zkServer.sh print-cmd;; 15 *) echo "requirestart|start-foreground|stop|status|restart|print-cmd";; 16 esac