Kafka 集群启动脚本

启动脚本

$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

你可能感兴趣的:(Kafka)