kafka集群每次启动都需要登录多台服务器操作,比较麻烦,安装了一个批量管理工具pssh,配置了ssh免秘钥登录,写了一个简单的shell脚本方便日常的批量启动、关闭操作。
玉龙网站制作公司哪家好,找
成都创新互联公司!从网页设计、网站建设、微信开发、APP开发、响应式网站等网站项目制作,到程序开发,运营维护。
成都创新互联公司于2013年开始到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选
成都创新互联公司。
[root@kafka1 ~]# cat /usr/local/kafka/bin/kafka-daemons.sh
#!/bin/bash
#kafka start stop
#date 2020.03.07
###########################
#[root@kafka1 ~]# cat /root/khost.txt
#192.168.180.21
#192.168.180.22
#192.168.180.23
#三台主机配置ssh免秘钥
function zookeeper_start(){
pssh -h khost.txt -i zkServer.sh start
sleep 5
pssh -h khost.txt -i jps
}
function zookeeper_stop(){
pssh -h khost.txt -i zkServer.sh stop
sleep 5
pssh -h khost.txt -i jps
}
function zookeeper_status(){
pssh -h khost.txt -i zkServer.sh status
}
function kafka_start(){
pssh -h khost.txt -i kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties
sleep 5
pssh -h khost.txt -i jps
}
function kafka_stop(){
pssh -h khost.txt -i kafka-server-stop.sh
sleep 5
pssh -h khost.txt -i jps
}
function kafka_status(){
pssh -h khost.txt -i jps
}
echo -e "[1] start zookeeper
[2] stop zookeeper
[3] status zookeeper
[4] start kafka
[5] stop kafka
[6] status kafka
"
read -p "please input install servers[1]|[2]|[3]|[4]|[5]|[6]|:" server_s
case $server_s in
1)
read -p "Please confirm your input [yes]:" confirm
case $confirm in
yes|YES|YEs|yEs|yeE)
zookeeper_start
;;
*)
exit
esac
;;
2)
read -p "Please confirm your input [yes]:" confirm
case $confirm in
yes|YES|YEs|yEs|yeE)
zookeeper_stop
;;
*)
exit
esac
;;
3)
read -p "Please confirm your input [yes]:" confirm
case $confirm in
yes|YES|YEs|yEs|yeE)
zookeeper_status
;;
*)
exit
esac
;;
4)
read -p "Please confirm your input [yes]:" confirm
case $confirm in
yes|YES|YEs|yEs|yeE)
kafka_start
;;
*)
exit
esac
;;
5)
read -p "Please confirm your input [yes]:" confirm
case $confirm in
yes|YES|YEs|yEs|yeE)
kafka_stop
;;
*)
exit
esac
;;
6)
read -p "Please confirm your input [yes]:" confirm
case $confirm in
yes|YES|YEs|yEs|yeE)
kafka_status
;;
*)
exit
esac
;;
*)
echo -e "\033[32;1m please input start or stop servers[1]|[2]|[3]|[4]|[5]|[6]!!!\033[0m"
exit
esac
添加脚本的执行权限
[root@kafka1 ~]# chmod 755 /usr/local/kafka/bin/kafka-daemons.sh
启动zookeeper
启动kafka
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网站题目:kafka怎样实现批量启动和关闭脚本?-创新互联
分享URL:
http://6mz.cn/article/dececp.html