Kafka 3.0.0集群部署教程
1、集群规划
主机名 | ip地址 | node.id | process.roles |
kafka1 | 192.168.0.29 | 1 | broker,controller |
Kafka2 | 192.168.0.30 | 2 | broker,controller |
Kafka3 | 192.168.0.31 | 3 | broker,controller |
2、将kafka包上传以上节点/app目录下
mkdir /app |
3、解压kafka包 所有节点
tar -zxvf kafka_2.13-3.0.0.tgz |
4、修改Raft配置文件
cd kafka_2.13-3.0.0 vi config/kraft/server.properties |
192.168.0.29机器配置
process.roles=broker,controller node.id=1 controller.quorum.voters=1@192.168.0.29:9093,2@192.168.0.30:9093,3@192.168.0.31:9093 listeners=PLAINTEXT://192.168.0.29:9092,CONTROLLER://192.168.0.29:9093 advertised.listeners=PLAINTEXT://192.168.0.29:9092 |
192.168.0.30机器配置
process.roles=broker,controller node.id=2 controller.quorum.voters=1@192.168.0.29:9093,2@192.168.0.30:9093,3@192.168.0.31:9093 listeners=PLAINTEXT://192.168.0.30:9092,CONTROLLER://192.168.0.30:9093 advertised.listeners=PLAINTEXT://192.168.0.30:9092 |
192.168.0.31机器配置
process.roles=broker,controller node.id=3 controller.quorum.voters=1@192.168.0.29:9093,2@192.168.0.30:9093,3@192.168.0.31:9093 listeners=PLAINTEXT://192.168.0.31:9092,CONTROLLER://192.168.0.31:9093 advertised.listeners=PLAINTEXT://192.168.0.31:9092 |
5、生成一个唯一的集群ID 第一节点
使用bin目录下的kafka-storage.sh工具为你的新集群生成一个唯一的ID
bin/kafka-storage.sh random-uuid |
6、格式化存储数据的目录 所有节点
bin/kafka-storage.sh format -t pdw5bp6oSbCxY59UpqR5Ng -c ./config/kraft/server.properties |
meta.properties 文件内容
cat /tmp/kraft-combined-logs/meta.properties |
7、开放端口 所有节点
sudo firewall-cmd --state sudo firewall-cmd --zone=public --add-port=9092/tcp --permanent sudo firewall-cmd --zone=public --add-port=9093/tcp --permanent sudo firewall-cmd --reload sudo firewall-cmd --zone=public --list-ports |
8、启动 所有节点
bin/kafka-server-start.sh ./config/kraft/server.properties |