kafka集群每次啟動(dòng)都需要登錄多臺(tái)服務(wù)器操作,比較麻煩,安裝了一個(gè)批量管理工具pssh,配置了ssh免秘鑰登錄,寫(xiě)了一個(gè)簡(jiǎn)單的shell腳本方便日常的批量啟動(dòng)、關(guān)閉操作。
玉龍網(wǎng)站制作公司哪家好,找
成都創(chuàng)新互聯(lián)公司!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、APP開(kāi)發(fā)、響應(yīng)式網(wǎng)站等網(wǎng)站項(xiàng)目制作,到程序開(kāi)發(fā),運(yùn)營(yíng)維護(hù)。
成都創(chuàng)新互聯(lián)公司于2013年開(kāi)始到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來(lái)保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選
成都創(chuàng)新互聯(lián)公司。
[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
#三臺(tái)主機(jī)配置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
添加腳本的執(zhí)行權(quán)限
[root@kafka1 ~]# chmod 755 /usr/local/kafka/bin/kafka-daemons.sh
啟動(dòng)zookeeper
啟動(dòng)kafka
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
文章題目:kafka怎樣實(shí)現(xiàn)批量啟動(dòng)和關(guān)閉腳本?-創(chuàng)新互聯(lián)
本文URL:http://jinyejixie.com/article28/dececp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、Google、面包屑導(dǎo)航、外貿(mào)網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、動(dòng)態(tài)網(wǎng)站
廣告
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源:
創(chuàng)新互聯(lián)