- 1 Kafka-Kraft架构
- 2 Kafka-Kraft集群部署
- The role of this server. Setting this puts us in KRaft mode
- The node id associated with this instance’s roles
- The connect string for the controller quorum
- Hostname and port the broker will advertise to producers and consumers. If not set,
- it uses the value for “listeners” if configured. Otherwise, it will use the value
- returned from java.net.InetAddress.getCanonicalHostName().
- A comma separated list of directories under which to store log files
1 Kafka-Kraft架构

左图为 Kafka 现有架构,元数据在 zookeeper 中,运行时动态选举 controller,由controller 进行 Kafka 集群管理。右图为 kraft 模式架构(实验性),不再依赖 zookeeper 集群,而是用三台 controller 节点代替 zookeeper,元数据保存在 controller 中,由 controller 直接进行 Kafka 集群管理。
2 Kafka-Kraft集群部署
关闭Kafka集群
[qtbhy@hadoop102 ~]$ kf.sh stop
解压kafka安装包
[qtbhy@hadoop102 software]$ tar -zxvf kafka_2.12-3.0.0.tgz -C /opt/module
重命名为kafka2
[qtbhy@hadoop102 module]$ mv kafka_2.12-3.0.0/ kafka2
在 hadoop102 上修改/opt/module/kafka2/config/kraft/server.properties 配置文件 ```shell
The role of this server. Setting this puts us in KRaft mode
process.roles=broker,controller
The node id associated with this instance’s roles
node.id=2
The connect string for the controller quorum
controller.quorum.voters=2@hadoop102:9093,3@hadoop103:9093,4@hadoop104:9093
Hostname and port the broker will advertise to producers and consumers. If not set,
it uses the value for “listeners” if configured. Otherwise, it will use the value
returned from java.net.InetAddress.getCanonicalHostName().
advertised.listeners=PLAINTEXT://hadoop102:9092
A comma separated list of directories under which to store log files
log.dirs=/opt/module/kafka2/data
5. 分发kafka2```shell[qtbhy@hadoop102 module]$ xsync kafka2
- hadoop103,hadoop104上修改node.id分别为3,4
- hadoop103,hadoop104上修改advertised.Listeners
初始化集群数据目录
生成存储目录唯一ID
[qtbhy@hadoop102 kafka2]$ bin/kafka-storage.sh random-uuidz-CJvwWeSw6aP0GALadNxA
用该uuid格式化kafka存储目录
[qtbhy@hadoop102 kafka2]$ bin/kafka-storage.sh format -t z-CJvwWeSw6aP0GALadNxA -c /opt/module/kafka2/config/kraft/server.properties[qtbhy@hadoop103 kafka2]$ bin/kafka-storage.sh format -t z-CJvwWeSw6aP0GALadNxA -c /opt/module/kafka2/config/kraft/server.properties[qtbhy@hadoop104 kafka2]$ bin/kafka-storage.sh format -t z-CJvwWeSw6aP0GALadNxA -c /opt/module/kafka2/config/kraft/server.properties
启动kafka集群
[qtbhy@hadoop102 kafka2]$ bin/kafka-server-start.sh -daemon config/kraft/server.properties[qtbhy@hadoop103 kafka2]$ bin/kafka-server-start.sh -daemon config/kraft/server.properties[qtbhy@hadoop104 kafka2]$ bin/kafka-server-start.sh -daemon config/kraft/server.properties
