批量啟動Kafka,Zookeeper指令碼
阿新 • • 發佈:2021-07-09
注意:一定要先配置免密操作
1、start-zk.sh
#!/bin/bash case $1 in "start"){ for i in hadoop102 hadoop103 hadoop101 do echo ---------- zookeeper $i 啟動 ------------ ssh $i "/usr/java/zookeeper36/bin/zkServer.sh start" done };; "stop"){ for i in hadoop102 hadoop103 hadoop101do echo ---------- zookeeper $i 停止 ------------ ssh $i "/usr/java/zookeeper36/bin/zkServer.sh stop" done };; "status"){ for i in hadoop102 hadoop103 hadoop101 do echo ---------- zookeeper $i 狀態 ------------ ssh $i "/usr/java/zookeeper36/bin/zkServer.sh status" done };; esac
2、start-kafka.sh
#! /bin/bash case $1 in "start"){ for i in hadoop102 hadoop103 hadoop101 do echo " --------啟動 $i Kafka-------" ssh $i "/usr/java/kafka2.3/kafka_2.11-2.3.0/bin/kafka-server-start.sh -daemon /usr/java/kafka2.3/kafka_2.11-2.3.0/config/server.properties" done};; "stop"){ for i in hadoop102 hadoop103 hadoop101 do echo " --------停止 $i Kafka-------" ssh $i "/usr/java/kafka2.3/kafka_2.11-2.3.0/bin/kafka-server-stop.sh stop" done };; esac