shell 一键启动zookeeper集群
2021/10/24 7:11:15
本文主要是介绍shell 一键启动zookeeper集群,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
#!/bin/bash if [ $# -lt 1 ];then echo "invalid param" exit fi hosts=(node1 node2 node3) # 判断第二个参数是否在hosts数组中 contains(){ n=1 for i in ${hosts[*]} do if [ "$1" = "$i" ];then n=0 fi done echo $n } case $1 in "start"){ for i in ${hosts[*]} do echo ---------- zookeeper $i 启动 ------------ ssh $i "/export/server/zookeeper-3.4.6/bin/zkServer.sh start" done };; "stop"){ for i in ${hosts[*]} do echo ---------- zookeeper $i 停止 ------------ ssh $i "/export/server/zookeeper-3.4.6/bin/zkServer.sh stop" done };; "status"){ for i in ${hosts[*]} do echo ---------- zookeeper $i 状态 ------------ ssh $i "/export/server/zookeeper-3.4.6/bin/zkServer.sh status" done };; "client") if [ $# -ne 2 ];then echo "need two params, but given $#" exit elif [ $(contains $2) -eq 1 ];then echo "second param error: $2" exit fi echo ---------- 连接客户端zookeeper $2 ------------ /export/server/zookeeper-3.4.6/bin/zkCli.sh -server $2:2181 ;; *) echo ---------- param $* invalid ------------ ;; esac
这篇关于shell 一键启动zookeeper集群的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-01后台管理开发学习:新手入门指南
- 2024-11-01后台管理系统开发学习:新手入门教程
- 2024-11-01后台开发学习:从入门到实践的简单教程
- 2024-11-01后台综合解决方案学习:从入门到初级实战教程
- 2024-11-01接口模块封装学习入门教程
- 2024-11-01请求动作封装学习:新手入门教程
- 2024-11-01登录鉴权入门:新手必读指南
- 2024-11-01动态面包屑入门:轻松掌握导航设计技巧
- 2024-11-01动态权限入门:新手必读指南
- 2024-11-01动态主题处理入门:新手必读指南