shell脚本启动kafka集群的多台节点
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                shell脚本启动kafka集群的多台节点
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                【README】 由于集群有多臺機器,啟動kafka ,查看其狀態,都需要每臺機器去執行命令, 可以寫個腳本基于ssh免密登錄批量執行;?
?
【1】啟動kafak (kk.sh)
#!/bin/bash case $1 in "start"){for i in centos201 centos202 centos203do echo "**********$i kafka start **********"ssh $i "/opt/module/kafka-0.11/bin/kafka-server-start.sh -daemon /opt/module/kafka-0.11/config/server.properties"done };;"stop"){for i in centos201 centos202 centos203do echo "**********$i kafka stop**********"ssh $i "/opt/module/kafka-0.11/bin/kafka-server-stop.sh /opt/module/kafka-0.11/config/server.properties"done };; esac【2】執行jps(xcall.sh )
#!/bin/bash params=$@ for i in centos201 centos202 centos203do echo "********** $i $params start **********"ssh $i "$params"done【3】 以上腳本,只需要將其放置在 kafka_home/bin/ 目錄下,然后 chmod +x xcall.sh 即可執行 ;
?
【4】執行效果?
[root@centos201 bin]# kk.sh stop **********centos201 kafka stop********** No kafka server to stop **********centos202 kafka stop********** No kafka server to stop **********centos203 kafka stop********** No kafka server to stop [root@centos201 bin]# [root@centos201 bin]# kk.sh start **********centos201 kafka start ********** **********centos202 kafka start ********** **********centos203 kafka start ********** [root@centos201 bin]# [root@centos201 bin]# [root@centos201 ~]# xcall.sh jps ********** centos201 jps start ********** 5763 Jps 1692 QuorumPeerMain 5116 Kafka ********** centos202 jps start ********** 4784 Kafka 5076 Jps 3370 QuorumPeerMain ********** centos203 jps start ********** 4185 Jps 1676 QuorumPeerMain 4110 Kafka?
總結
以上是生活随笔為你收集整理的shell脚本启动kafka集群的多台节点的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 中考大捷的意思 中考大捷是什么意思
- 下一篇: 北海公园要门票吗
