进入目录
cd /etc/rc.d/init.d/
新建文件
touch zookeeper
添加可执行权限
chmod +x zookeeper
编辑文件
vi zookeeper
添加如下内容
export JAVA_HOME=/usr/local/java/jdk1.8.0_102 #jdk路径
case $1 in
start) su root /usr/local/amysoft/apache-zookeeper-3.5.8-bin/bin/zkServer.sh start;;
stop) su root /usr/local/amysoft/apache-zookeeper-3.5.8-bin/bin/zkServer.sh stop;;
status) su root /usr/local/amysoft/apache-zookeeper-3.5.8-bin/bin/zkServer.sh status;;
restart) su /usr/local/amysoft/apache-zookeeper-3.5.8-bin/bin/zkServer.sh restart;;
*) echo "require start|stop|status|restart" ;;
esac
使用命令执行启动、查看状态、停止
service zookeeper start
service zookeeper status
service zookeeper stop
添加到开机启动
chkconfig --add zookeeper
检查开机自启项
chkconfig --list