Kafka-Karft集群部署

集群:

master:192.168.10.130

slave1:192.168.10.131

slave2:192.168.10.132

1、解压 kafka_2.12-3.0.0.tgz 
[root@master soft]# tar -zxvf kafka_2.12-3.0.0.tgz -C /opt/moudel/
2、重命名解压后的文件
mv kafka_2.12-3.0.0 kafka1
3、修改kraft配置文件内容
vim /opt/moudel/kafka1/config/kraft/server.properties
#kafka 的角色(controller 相当于主机、broker 节点相当于从机,主机类似 zk 功
能)
#节点ID
node.id = 1
#controller 服务协议别名
#全Controller列表
controller.quorum.voters=1@master:9093,2@slave1:9093,3@slave2:9093
#对外访问地址
advertised.listeners=PLAINTEXT://master:9092
#kafka数据存储目录
log.dirs = /opt/moudel/kafka1/datas
4、给每个节点分发kafka1
scp -r kafka1 slave1:/opt/moudel/
scp -r kafka1 slave2:/opt/moudel/
修改节点ID,和对应的对外访问地址
slave1:
vim /opt/moudel/kafka1/config/kraft/server.properties
node.id = 2
advertised.listeners=PLAINTEXT://slave1:9092
slave2:
vim /opt/moudel/kafka1/config/kraft/server.properties
node.id = 3
advertised.listeners=PLAINTEXT://slave2:9092
5、初始化集群数据目录
①首先生成存储目录唯一ID
[root@master kafka1]# bin/kafka-storage.sh  random-uuid
MIr8ldvHS0iKbt7XcgJhhg(随机初始化,每次生成的ID不一样)
②用该ID格式化kafka存储目录(三台节点都需要)
[root@master kafka1]# bin/kafka-storage.sh format -t MIr8ldvHS0iKbt7XcgJhhg -c config/kraft/server.properties 
Formatting /opt/moudel/kafka1/datas
[root@slave1 kafka1]# bin/kafka-storage.sh format -t MIr8ldvHS0iKbt7XcgJhhg -c config/kraft/server.properties
Formatting /opt/moudel/kafka1/datas
[root@slave2 kafka1]# bin/kafka-storage.sh format -t MIr8ldvHS0iKbt7XcgJhhg -c config/kraft/server.properties
Formatting /opt/moudel/kafka1/datas
6、启动kafka集群
[root@master kafka1]# bin/kafka-server-start.sh -daemon config/kraft/server.properties
[root@slave1 kafka1]# bin/kafka-server-start.sh -daemon config/kraft/server.properties
[root@slave2 kafka1]# bin/kafka-server-start.sh -daemon config/kraft/server.properties
7、关闭集群
[root@master kafka1]# bin/kafka-server-stop.sh
[root@slave1 kafka1]# bin/kafka-server-stop.sh
[root@slave2 kafka1]# bin/kafka-server-stop.sh

你可能感兴趣的:(笔记,kafka)