Table of contents
1. Cluster deployment of Kafka3.0.0 version (linux environment-centos7)
- Refer to this blog post link of lz: https://blog.csdn.net/li1325169021/article/details/129804602?spm=1001.2014.3001.5501
Two, 3 server information
- 3 servers
name of server server ip centos7 virtual machine 1 192.168.136.27 centos7 virtual machine 2 192.168.136.28 centos7 virtual machine 3 192.168.136.29
3. Kafka3.0.0 cluster start and stop script
3.1, write kf.sh script
-
Create a script named kf.sh in the /home directory of the 192.168.136.27 server
[root@localhost home]# vi kf.sh
-
Write the following in the kf.sh script
#! /bin/bash case $1 in "start"){ for i in 192.168.136.27 192.168.136.28 192.168.136.29 do echo " --------启动 $i Kafka-------" ssh $i "/opt/module/kafka-3.0.0/bin/kafka-server-start.sh -daemon /opt/module/kafka-3.0.0/config/server.properties" done };; "stop"){ for i in 192.168.136.27 192.168.136.28 192.168.136.29 do echo " --------停止 $i Kafka-------" ssh $i "/opt/module/kafka-3.0.0/bin/kafka-server-stop.sh " done };; esac
3.2. Increase script execution permission
-
The kf.sh script adds the execution permission of u+x
[root@localhost home]# chmod +x kf.sh
4. Execute the kf.sh script to start the Kafka cluster
-
Enter the home directory and execute the sh kf.sh start command to start the Kafka cluster
[root@localhost /]# cd /home/ [root@localhost home]# sh kf.sh start
5. Execute the kf.sh script to stop the Kafka cluster
-
Enter the home directory and execute the sh kf.sh stop command to start the Kafka cluster
[root@localhost /]# cd /home/ [root@localhost home]# sh kf.sh stop
6. Precautions for stopping Kafka cluster
- When stopping the Kafka cluster, be sure to wait for all Kafka node processes to stop before stopping the Zookeeper cluster.
- Because the Zookeeper cluster records the relevant information of the Kafka cluster, once the Zookeeper cluster is stopped first, the Kafka cluster has no way to obtain the information of the stopped process, and can only manually kill the Kafka process.