Kafka 集群启动脚本

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zz657114506/article/details/54698125

启动脚本

$Kafka_home/bin下 touch kafka-start-cluster.sh,并chmod a+x kafka-start-cluster.sh

#!/bin/bash

brokers="mini05 mini06 mini07"
kafka_home="/home/apps/kafka"

for i in $brokers
do
    echo "Starting kafka on ${i} ... "
    ssh ${i} "source /etc/profile; nohup sh ${kafka_home}/bin/kafka-server-start.sh ${kafka_home}/config/server.properties > /dev/null 2>&1 &"
    if [[ $? -ne 0 ]]; then
        echo "Start kafka on ${i} is OK !"
    fi
done
echo kafka kafka are started !
exit 0


停止脚本

$Kafka_home/bin下 touch kafka-stop-cluster.sh,并chmod a+x kafka-stop-cluster.sh

#!/bin/bash 

brokers="mini05 mini06 mini07"
kafka_home="/home/apps/kafka"

for i in $brokers
do
    echo "Stopping kafka on ${i} ..."
    ssh ${i} "source /etc/profile;bash ${kafka_home}/bin/kafka-server-stop.sh"
    if [[ $? -ne 0 ]]; then
        echo "Stopping ${kafka_home} on ${i} is down"
    fi
done

echo all kafka  are stopped !
exit 0
展开阅读全文

没有更多推荐了,返回首页