linux下添加zookeeper开机自动启动
1、安装zookeeper请自行百度,假设安装的路径为:/opt/apache-zookeeper-3.5.7-bin启动:/opt/apache-zookeeper-3.5.7-bin/bin/zkServer.sh start查看:/opt/apache-zookeeper-3.5.7-bin/bin/zkServer.sh status停止:/opt/apache-zoo...
·
1、安装zookeeper
请自行百度,假设安装的路径为:
/opt/apache-zookeeper-3.5.7-bin
启动:/opt/apache-zookeeper-3.5.7-bin/bin/zkServer.sh start
查看:/opt/apache-zookeeper-3.5.7-bin/bin/zkServer.sh status
停止:/opt/apache-zookeeper-3.5.7-bin/bin/zkServer.sh stop
2、添加开机启动脚本zookeeper文件到/etc/rc.d/init.d目录(centos机器)
#!/bin/bash
#chkconfig: 2345 10 90
#description: service zookeeper
#processname:zookeeper
#环境变量加载
source /etc/profile
#export JAVA_HOME=/usr/local/java/jdk1.8.0_241
export ZOOKEEPER_HOME=/opt/apache-zookeeper-3.5.7-bin
case "$1" in
start) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh start;;
start-foreground) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh start-foreground;;
stop) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh stop;;
status) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh status;;
restart) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh restart;;
upgrade) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh upgrade;;
print-cmd) su root ${ZOOKEEPER_HOME}/bin/zkServer.sh print-cmd;;
test) echo "test good";;
*) echo "requirestart|start-foreground|stop|status|restart|print-cmd";;
esac
3、添加到开机服务
chkconfig --add zookeeper
ps:查看开机启动服务使用:chkconfig --list
4、重启机器reboot看看,zookeeper就会自动启动了。
更多推荐
已为社区贡献3条内容
所有评论(0)