Zookeeper集群shell脚本一键全启动、停止、重启、查看脚本
Mac启动脚本,名曰 zk.sh
#!/bin/bash # Desc : ZK集群操作 # author : 刘仁奎 # Created : 2020-3-20 # Last Modified : 2020-3-20 # Version : 1.0 echo -e '\n脚本描述:快速操作zk集群,操作示例:zk.sh start' echo -e '\n参数:start、start-foreground、stop、restart、status、upgrade、print-cmd \n' behave=$1 if [ -z "$behave" ]; then echo -e "环境参数必填,请检查!\n" exit fi echo "--------处理zk集群(start)---------" echo -e "$behave ZK 集群\n" ZK_HOME="/Users/liurenkui/myLibrary/zk-kafka/zkCluster" for i in 1 2 3 do "${ZK_HOME}/zk_$i/bin/zkServer.sh" "$behave" done echo -e "\n--------处理zk集群(end)---------\n"
我的zk集群目录
➜ zkCluster tree -L 1 . ├── zk.sh ├── zk_1 ├── zk_2 ├── zk_3
参数介绍
zkServer.sh start :启动zookeeper服务。
zkServer.sh start-foreground:启动zookeeper服务,并且查看运行过程中的异常。检查zookeeper运行异常时使用。
zkServer.sh stop:停止zookeeper服务。
zkServer.sh restart:重启zookeeper服务。
zkServer.sh status:查看zookeeper服务的运行状态。
zkServer.sh upgrade:升级zookeeper。
zkServer.sh print-cmd:查看zookeeper的启动命令及参数。
操作示例
➜ zkCluster zk.sh start 脚本描述:快速操作zk集群,操作示例:zk.sh start 参数:start、start-foreground、stop、restart、status、upgrade、print-cmd --------处理zk集群(start)--------- start ZK 集群 ZooKeeper JMX enabled by default Using config: /Users/liurenkui/myLibrary/zk-kafka/zkCluster/zk_1/bin/../conf/zoo.cfg Starting zookeeper ... STARTED ZooKeeper JMX enabled by default Using config: /Users/liurenkui/myLibrary/zk-kafka/zkCluster/zk_2/bin/../conf/zoo.cfg Starting zookeeper ... STARTED ZooKeeper JMX enabled by default Using config: /Users/liurenkui/myLibrary/zk-kafka/zkCluster/zk_3/bin/../conf/zoo.cfg Starting zookeeper ... STARTED --------处理zk集群(end)--------- ➜ zkCluster zk.sh stop 脚本描述:快速操作zk集群,操作示例:zk.sh start 参数:start、start-foreground、stop、restart、status、upgrade、print-cmd --------处理zk集群(start)--------- stop ZK 集群 ZooKeeper JMX enabled by default Using config: /Users/liurenkui/myLibrary/zk-kafka/zkCluster/zk_1/bin/../conf/zoo.cfg Stopping zookeeper ... STOPPED ZooKeeper JMX enabled by default Using config: /Users/liurenkui/myLibrary/zk-kafka/zkCluster/zk_2/bin/../conf/zoo.cfg Stopping zookeeper ... STOPPED ZooKeeper JMX enabled by default Using config: /Users/liurenkui/myLibrary/zk-kafka/zkCluster/zk_3/bin/../conf/zoo.cfg Stopping zookeeper ... STOPPED --------处理zk集群(end)--------- ➜ zkCluster zk.sh status 脚本描述:快速操作zk集群,操作示例:zk.sh start 参数:start、start-foreground、stop、restart、status、upgrade、print-cmd --------处理zk集群(start)--------- status ZK 集群 ZooKeeper JMX enabled by default Using config: /Users/liurenkui/myLibrary/zk-kafka/zkCluster/zk_1/bin/../conf/zoo.cfg Client port found: 2181. Client address: localhost. Error contacting service. It is probably not running. ZooKeeper JMX enabled by default Using config: /Users/liurenkui/myLibrary/zk-kafka/zkCluster/zk_2/bin/../conf/zoo.cfg Client port found: 2182. Client address: localhost. Error contacting service. It is probably not running. ZooKeeper JMX enabled by default Using config: /Users/liurenkui/myLibrary/zk-kafka/zkCluster/zk_3/bin/../conf/zoo.cfg Client port found: 2183. Client address: localhost. Error contacting service. It is probably not running. --------处理zk集群(end)--------- ➜ zkCluster
未经允许请勿转载:程序喵 » Zookeeper集群shell脚本一键全启动、停止、重启、查看脚本