启动脚本
#!/bin/bash
case $1 in
"start"){
echo ---------- zookeeper hadoop1 启动 ------------
sh /usr/local/zookeeper3.5.7/bin/zkServer.sh start
for i in hadoop2 hadoop3
do
echo ---------- zookeeper $i 启动 ------------
ssh $i "/usr/local/zookeeper3.5.7/bin/zkServer.sh start"
done
echo "==========kafka hadoop1 启动 =========="
sh /usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties
for i in hadoop2 hadoop3
do
echo "==========kafka $i 启动 =========="
ssh $i '/usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties'
done
};;
"stop"){
echo ---------- zookeeper hadoop1 停止 ------------
sh /usr/local/zookeeper3.5.7/bin/zkServer.sh stop
for i in hadoop2 hadoop3
do
echo ---------- zookeeper $i 停止 ------------
ssh $i "/usr/local/zookeeper3.5.7/bin/zkServer.sh stop"
done
echo ---------- kafka hadoop1 停止 ------------
sh /usr/local/kafka/bin/kafka-server-stop.sh stop
for i in hadoop2 hadoop3
do
echo ---------- kafka $i 停止 ------------
ssh $i "/usr/local/kafka/bin/kafka-server-stop.sh stop"
done
};;
"status"){
echo ---------- zookeeper hadoop1 状态 ------------
sh /usr/local/zookeeper3.5.7/bin/zkServer.sh status
for i in hadoop2 hadoop3
do
echo ---------- zookeeper $i 状态 ------------
ssh $i "/usr/local/zookeeper3.5.7/bin/zkServer.sh status"
done
};;
esac
1 启动时zookeeper报错找不到JAVA_HOME,在zkEnv.sh下图片段报错
/etc/profile 有export JAVA_HOME且可以取到,但是zkEnv.sh取不到值 可在zkEnv.sh或zkServer.sh 上source /etc/profile profile zkEnv.sh zkServer.sh,顶行,在zkEnv.sh之前
2启动Kafka没反应,起不来
kafkaServer.out日志 kafka-server-start.sh 顶行增加 source /etc/profile
|