case $1 in
"start")
for host in hadoop102 hadoop103 hadoop104
do
echo "=====start $host kafka====="
ssh $host "/opt/module/kafka_2.11-2.4.1/bin/kafka-server-start.sh -daemon /opt/module/kafka_2.11-2.4.1/config/server.properties"
done
;;
"stop")
for host in hadoop102 hadoop103 hadoop104
do
echo "=====stop $host kafka====="
ssh $host "/opt/module/kafka_2.11-2.4.1/bin/kafka-server-stop.sh "
done
;;
"status")
for host in hadoop102 hadoop103 hadoop104
do
echo "=====stop $host kafka====="
pid=$(ssh $host "ps -ef|grep server.properties|grep -v grep")
[ "$pid" ] && echo "kafka运行正常" || echo "未找到kafka进程,可能异常"
done
;;
*)
echo "参数传递错误..."
;;
esac
|