操作环境
服务器centos6.8, ip:47.52.41.245,
Zookeeper集群设置开启自启动
1,在/etc/init.d目录下面新建启动脚本并且命名为zoo
vim zoo
完整配置信息为
#!/bin/sh
# chkconfig: 345 99 10
# description: Auto-starts zookeeper
# /etc/init.d/zoo
# zookeeper auto-start
export JAVA_HOME=/usr/java/jdk1.8.0_144
export JRE_HOME=/usr/java/jdk1.8.0_144/jre
zoo=/opt/frank/zookeeper/zookeeper-3.4.9/bin/zkServer.sh
case "$1" in
start)
$zoo start
;;
stop)
$zoo stop
;;
status)
$zoo status
;;
restart)
$zoo restart
;;
*)
echo "require start|stop|status|restart"
;;
esac
2,修改启动文件的权限
chmod +x /etc/init.d/zoo
3,设定开机启动服务
chkconfig zoo on
4,启动,停止zoo
service zoo start
service zoo stop
5,reboot重启服务器
6,测试服务是否启动
[root@iZj6c7eeosj2t5vjw8rf4xZ ~]# netstat -tlnp|grep java
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 1642/java
tcp 0 0 0.0.0.0:2181 0.0.0.0:* LISTEN 1657/java
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 1642/java
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1642/java
tcp 0 0 0.0.0.0:34432 0.0.0.0:* LISTEN 1657/java
[root@iZj6c7eeosj2t5vjw8rf4xZ ~]# service zoo status
ZooKeeper JMX enabled by default
Using config: /opt/frank/zookeeper/zookeeper-3.4.9/bin/../conf/zoo.cfg
Mode: standalone
网友评论