How does kafka implement batch startup and shutdown scripts?
Kafka cluster needs to log in to multiple servers every time it starts, which is troublesome. A batch management tool pssh is installed, ssh key-free login is configured, and a simple shell script is written to facilitate daily batch start-up and shutdown operations.
[root@kafka1 ~] # cat / usr/local/kafka/bin/kafka-daemons.sh #! / bin/bash # kafka start stop # date 2020.03.07 cat # [root@kafka1 ~] # cat / root/khost.txt # 192.168.180.21 "192.168.180.22" 192.168.180.2 "three hosts configure ssh key-free function zookeeper_start () {pssh-h khost.txt-I zkServer.sh startsleep 5pssh-h khost.txt-I jps} function zookeeper_stop () {pssh-h khost.txt-I zkServer.sh stopsleep 5pssh-h khost.txt-I jps} function zookeeper_status () {pssh-h khost.txt-I zkServer.sh status} function kafka_start () {pssh-h khost.txt-I kafka-server-start.sh-daemon / usr/local/kafka/config/server.propertiessleep 5pssh-h khost.txt-I jps} Function kafka_stop () {pssh-h khost.txt-I kafka-server-stop.shsleep 5pssh-h khost.txt-I jps} function kafka_status () {pssh-h khost.txt-I jps} echo-e "[1] start zookeeper [2] stop zookeeper [3] status zookeeper [4] start kafka [5] stop kafka [6] status kafka" read-p "please input install servers [1] | [2] | [3] | [5] | [6] |:" server_ Scase $server_s in 1) read-p "Please confirm your input [yes]:" confirm case $confirm in yes | YES | YEs | yEs | yeE) zookeeper_start ; *) exit esac;; 2) read-p "Please confirm your input [yes]:" confirm case $confirm in yes | YES | YEs | yEs | yeE) zookeeper_stop *) exit esac 3) read-p "Please confirm your input [yes]:" confirm case $confirm in yes | YES | YEs | yEs | yeE) zookeeper_status *) exit esac 4) read-p "Please confirm your input [yes]:" confirm case $confirm in yes | YES | YEs | yEs | yeE) kafka_start *) exit esac 5) read-p "Please confirm your input [yes]:" confirm case $confirm in yes | YES | YEs | yEs | yeE) kafka_stop *) exit esac 6) read-p "Please confirm your input [yes]:" confirm case $confirm in yes | YES | YEs | yEs | yeE) kafka_status *) exitesac;; *) echo-e "\ 033 [32 + 1m please input start or stop servers [1] | [2] | [3] | [4] | [5] | [6]!!\ 033 [0m" exitesac
Add execution permissions for the script
[root@kafka1 ~] # chmod 755 / usr/local/kafka/bin/kafka-daemons.sh
Start zookeeper
Start kafka