设置zookeeper开机自启动

Posted 猪脚踏浪

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了设置zookeeper开机自启动相关的知识,希望对你有一定的参考价值。

1.进入到/etc/init.d目录下,新建一个zookeeper脚本

cd /etc/init.d

vi zookeeper

#!/bin/bash    
#chkconfig:2345 20 90    
#description:zookeeper    
#processname:zookeeper    
export JAVA_HOME=/usr/local/programs/jdk1.8
case $1 in    
        start) su root /usr/local/programs/zookeeper-3.4.10/bin/zkServer.sh start;;    
        stop) su root /usr/local/programs/zookeeper-3.4.10/bin/zkServer.sh stop;;    
        status) su root /usr/local/programs/zookeeper-3.4.10/bin/zkServer.sh status;;    
        restart) su root /usr/local/programs/zookeeper-3.4.10/bin/zkServer.sh restart;;    
        *) echo "require start|stop|status|restart" ;;    
esac

 

2.给脚本添加执行权限
chmod +x zookeeper

[[email protected] bin]# cd /etc/init.d
[[email protected] init.d]# chmod +x zookeeper

 

3.使用service zookeeper start/stop命令来尝试启动关闭zookeeper,使用service zookeeper status查看zookeeper状态。
或者直接 zookeeper start/stop/status

 

4.添加到开机启动

[[email protected] init.d]# chkconfig --add zookeeper

 

5.查看开机自启的服务中是否已经有我们的zookeeper

[[email protected] init.d]# chkconfig --list zookeeper
zookeeper          0:off    1:off    2:on    3:on    4:on    5:on    6:off

 

以上是关于设置zookeeper开机自启动的主要内容,如果未能解决你的问题,请参考以下文章

Centos 设置zookeeper开机自启动

zookeeper/kafka设置开机自启/nginx安装部署

mac设置shell脚本开机自启动

zookeeper设置开机自启

zookeeper的开机自启动

hadoop+zookeeper+hbase 开机自启动