- 在/home/atguigu/bin目录下创建文件kf.sh脚本文件
脚本如下:
case $1in"start"){ for i in hadoop102 hadoop103 hadoop104 doecho" --------启动 $i Kafka-------"ssh$i"/opt/module/kafka/bin/kafka-server-start.sh -daemon /opt/module/kafka/config/server.properties"done};; "stop"){ for i in hadoop102 hadoop103 hadoop104 doecho" --------停止 $i Kafka-------"ssh$i"/opt/module/kafka/bin/kafka-server-stop.sh "done};; esac
- 添加执行权限
[kunfire@hadoop102 bin]$ chmod+x kf.sh
- 启动集群命令
[kunfire@hadoop102 ~]$ kf.sh start
- 停止集群命令
[kunfire@hadoop102 ~]$ kf.sh stop