我的這兩個(gè)腳本文件的路徑是:/opt/module/kafka/tools
vim start-kafka.sh
image
image.gif
?
#! /bin/sh
for host in hadoop101 hadoop102 hadoop103
do
ssh $host "source /etc/profile;nohup /opt/module/kafka/bin/kafka-server-start.sh /opt/module/kafka/config/server.properties >/dev/null 2>&1 &"
echo "$host kafka is running"
done
image.gif
vim stop-kafka.sh
#! /bin/sh
for host in hadoop101 hadoop102 hadoop103
do
ssh $host "source /etc/profile; /opt/module/kafka/bin/kafka-server-stop.sh"
echo "$host kafka is stopping"
done
image.gif
修改腳本的權(quán)限
chmod u+x start-kafka.sh
chmod u+x stop-kafka.sh
測(cè)試
關(guān)閉
[root@hadoop101 tools]# sh stop-kafka.sh
image
image.gif
?
image
image.gif
image
image.gif
?
啟動(dòng):[root@hadoop101 tools]# sh start-kafka.sh
image
image.gif
?
image
image.gif
?
image
image.gif
?