Zookeeper集群启动查看关闭脚本(用户版)

Posted honconM

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Zookeeper集群启动查看关闭脚本(用户版)相关的知识,希望对你有一定的参考价值。

[root@mihaoyu152 ~]# vi /usr/bin/zkopcustomer 
#!/bin/bash
cat <<EOF
 1: 启动集群ZOOKEEPER
 2: 停止集群ZOOKEEPER
 3: 查询集群服务状态
EOF

read -p "请输入要选择的数字:" num

for host in mihaoyu153 mihaoyu154 mihaoyu155
do
  case $num in
  1){
    echo "--------------- $host zookeeper start ---------------"
    ssh $host "source /etc/profile; zkServer.sh start"
  };;
  2){
    echo "--------------- $host zookeeper stop ---------------"
    ssh $host "source /etc/profile; zkServer.sh stop"
  };;
  3){
    echo "--------------- $host zookeeper status ---------------"
    ssh $host "source /etc/profile; zkServer.sh status"
  };;
  esac
done

[root@mihaoyu152 ~]# chmod 777 /usr/bin/zkopcustomer 

[root@mihaoyu152 ~]# zkopcustomer 
 1: 启动集群ZOOKEEPER
 2: 停止集群ZOOKEEPER
 3: 查询集群服务状态
请输入要选择的数字:1
--------------- mihaoyu153 zookeeper start ---------------
JMX enabled by default
Using config: /opt/soft/zookeeper345/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
--------------- mihaoyu154 zookeeper start ---------------
JMX enabled by default
Using config: /opt/soft/zookeeper345/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
--------------- mihaoyu155 zookeeper start ---------------
JMX enabled by default
Using config: /opt/soft/zookeeper345/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

[root@mihaoyu152 ~]# zkopcustomer 
 1: 启动集群ZOOKEEPER
 2: 停止集群ZOOKEEPER
 3: 查询集群服务状态
请输入要选择的数字:3
--------------- mihaoyu153 zookeeper status ---------------
JMX enabled by default
Using config: /opt/soft/zookeeper345/bin/../conf/zoo.cfg
Mode: follower
--------------- mihaoyu154 zookeeper status ---------------
JMX enabled by default
Using config: /opt/soft/zookeeper345/bin/../conf/zoo.cfg
Mode: leader
--------------- mihaoyu155 zookeeper status ---------------
JMX enabled by default
Using config: /opt/soft/zookeeper345/bin/../conf/zoo.cfg
Mode: follower

[root@mihaoyu152 ~]# zkopcustomer 
 1: 启动集群ZOOKEEPER
 2: 停止集群ZOOKEEPER
 3: 查询集群服务状态
请输入要选择的数字:2
--------------- mihaoyu153 zookeeper stop ---------------
JMX enabled by default
Using config: /opt/soft/zookeeper345/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
--------------- mihaoyu154 zookeeper stop ---------------
JMX enabled by default
Using config: /opt/soft/zookeeper345/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
--------------- mihaoyu155 zookeeper stop ---------------
JMX enabled by default
Using config: /opt/soft/zookeeper345/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED

以上是关于Zookeeper集群启动查看关闭脚本(用户版)的主要内容,如果未能解决你的问题,请参考以下文章

搭建Zookeeper集群服务启动失败

Zookeeper集群启动/停止/状态查看脚本

Zookeeper3.5.7版本——集群启动停止脚本

Zookeeper集群启动脚本

Hadoop生态圈相关组件服务启动关闭和查看脚本

zookeeper群集部署及概述