kafka_start_cluster.sh
#!/bin/bash brokers="kafka-server-1 kafka-server-2 kafka-server-3" KAFKA HOME="/usr/local/software/kafka/kafka2.11-2.1.0" echo "I NFO : Begin to start kafka cluster ... " for broker in $brokers do echo " INFO:Start kafka on { $broker} ssh $broker -C " source /etc/profile ; sh ${KAFKA_HOME}/bin/kafka-server-start.sh -daemon ${KAFKA_HOME}/config/server.properties" if [ $? -eq 0 ]; then echo " INFO:[${broker}] Start successfully " fi done echo " I NFO:Kafka cluster starts successfully !"
kafka_stop_cluster.sh
#!/bin/bash brokers="kafka-server-1 kafka-server-2 kafka-server-3" KAFKA_HOME="/usr/local/software/kafka/kafka_2.11- 2.1.0" echo " INFO:Begin to shut down kafka cluster ... " for broker in $brokers do echo " INFO:Shut down kafka on ${broker} . . . " ssh $broker -c "source etc/profile;sh ${KAFKA_HOME}/bin/kafka-server-stop.sh" if [ $? -eq 0 ] ; then echo " INFO: [${broker)] Shut down completed " fi done echo " INFO:Kafka cluster shuts down completed!"