(1)在/root/bin目录下创建脚本kf.sh
vim kf.sh
(2)脚本内容
case $1 in
"start"){
for i in hadoop101 hadoop102 hadoop103
do
echo "============kafka $i启动中=============="
ssh $i "source /etc/profile; /opt/module/kafka/bin/kafka-server-start.sh /opt/module/kafka/config/server.properties >/dev/null 2>&1 &"
done
};;
"stop"){
for i in hadoop101 hadoop102 hadoop103
do
echo "============kafka $i关闭中=============="
ssh $i "source /etc/profile; /opt/module/kafka/bin/kafka-server-stop.sh"
done
};;
esac
~
(3)脚本权限
chmod 777 kf.sh
(4)启动命令`
kf.sh start
(5)关闭命令
kf.sh stop
|