一、环境准备
1.Kafka安装成功且配置好环境变量
2.Kafka配置成集群状态,broker_id配置成功
二、群起脚本
Kafka路径:/opt/module/kafka/
#!/bin/bash case $1 in "start"){ for i in hadoop1 hadoop2 hadoop3 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 hadoop1 hadoop2 hadoop3 do echo "============kafka $i关闭中==============" ssh $i "source /etc/profile; /opt/module/kafka/bin/kafka-server-stop.sh" done };; esac
注意: >/dev/null 2>&1 是为了打印日志不在控制台显示出来。