批量启动Kafka,Zookeeper脚本

注意:一定要先配置免密操作

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 hadoop101
        do
        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

 

posted @ 2021-07-09 18:21  小白啊小白,Fighting  阅读(117)  评论(0编辑  收藏  举报