我的这两个脚本文件的路径是:/opt/module/kafka/tools
vim start-kafka.sh
#! /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
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
修改脚本的权限
chmod u+x start-kafka.sh
chmod u+x stop-kafka.sh
测试
关闭
[root@hadoop101 tools]# sh stop-kafka.sh
启动:[root@hadoop101 tools]# sh start-kafka.sh