kafka3.X集群安装(不使用zookeeper)

参考文献

kafka3.X集群安装(不使用zookeeper) http://www.bryh.cn/a/601016.html

正文

kafka3.x不再支持JDK8,建议安装JDK11或JDK17。

安装jdk

|------------|-----------------|-------------------|---------|
| 主机名称 | IP | 角色 | node.id |
| centos.7.1 | 192.168.244.128 | broker,controller | 1 |
| centos.7.2 | 192.168.244.129 | broker,controller | 2 |
| centos.7.3 | 192.168.244.130 | broker,controller | 3 |

vi /etc/hosts,在3个节点,都添加如下内容:

192.168.244.128 centos.7.1
192.168.244.129 centos.7.2
192.168.244.130 centos.7.3

上传kafka_2.12-3.0.0.tgz至服务器并解压

tar -zxvf kafka_2.12-3.0.0.tgz -C /opt/module/

修改解压后的文件名称

mv kafka_2.12-3.0.0/ kafka

在kafka3.x版本中,使用Kraft协议代替zookeeper进行集群的Controller选举,所以要针对它进行配置

vi /opt/module/kafka/config/kraft/server.properties

具体配置参数如下:

#centos.7.1节点
node.id=1
process.roles=broker,controller
listeners=PLAINTEXT://centos.7.1:9092,CONTROLLER://centos.7.1:9093
advertised.listeners=PLAINTEXT://:9092
controller.quorum.voters=1@centos.7.1:9093,2@centos.7.2:9093,3@centos.7.3:9093
log.dirs=/opt/module/kafka/datas
#
inter.broker.listener.name=PLAINTEXT
controller.listener.names=CONTROLLER
listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000

#centos.7.2节点
node.id=2
process.roles=broker,controller
listeners=PLAINTEXT://centos.7.2:9092,CONTROLLER://centos.7.2:9093
advertised.listeners=PLAINTEXT://:9092
controller.quorum.voters=1@centos.7.1:9093,2@centos.7.2:9093,3@centos.7.3:9093
log.dirs=/opt/module/kafka/datas
#
inter.broker.listener.name=PLAINTEXT
controller.listener.names=CONTROLLER
listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000

#centos.7.3节点
node.id=3
process.roles=broker,controller
listeners=PLAINTEXT://centos.7.3:9092,CONTROLLER://centos.7.3:9093
advertised.listeners=PLAINTEXT://:9092
controller.quorum.voters=1@centos.7.1:9093,2@centos.7.2:9093,3@centos.7.3:9093
log.dirs=/opt/module/kafka/datas
#
inter.broker.listener.name=PLAINTEXT
controller.listener.names=CONTROLLER
listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000

node.id:这将作为集群中的节点 ID,唯一标识,按照我们事先规划好的(上文),在不同的服务器上这个值不同。其实就是kafka2.0中的broker.id,只是在3.0版本中kafka实例不再只担任broker角色,也有可能是controller角色,所以改名叫做node节点。

process.roles:一个节点可以充当broker或controller或两者兼而有之。按照我们事先规划好的(上文),在不同的服务器上这个值不同。多个角色用逗号分开。

listeners: broker将使用9092端口,而kraft controller控制器将使用9093端口。

advertised.listeners: 这里指定kafka通过代理暴漏的地址,如果都是局域网使用,就配置PLAINTEXT://:9092即可。

controller.quorum.voters:这个配置用于指定controller主控选举的投票节点,所有process.roles包含controller角色的规划节点都要参与,即:zimug1、zimug2、zimug3。其配置格式为:node.id1@host1:9093,node.id2@host2:9093

log.dirs:kafka 将存储数据的日志目录,在准备工作中创建好的目录

相关推荐
coisini.cn11 分钟前
Windows10、CentOS Stream9 环境下安装kafka_2.12-3.6.2记录
运维·zookeeper·kafka·windows10·centos stream 9
不能再留遗憾了13 分钟前
RabbitMQ 高级特性——发送方确认
分布式·rabbitmq·ruby
益达_z14 分钟前
中间件知识点-消息中间件(Rabbitmq)一
分布式·中间件·rabbitmq
.生产的驴3 小时前
SpringBoot 消息队列RabbitMQ在代码中声明 交换机 与 队列使用注解创建
java·spring boot·分布式·servlet·kafka·rabbitmq·java-rabbitmq
lipviolet4 小时前
Redis系列---Redission分布式锁
数据库·redis·分布式
液态不合群8 小时前
低代码革命:加速云原生时代的端到端产品创新
低代码·云原生
spiker_12 小时前
RabbitMQ 常见使用模式详解
分布式·rabbitmq
不能再留遗憾了12 小时前
RabbitMQ 高级特性——持久化
分布式·rabbitmq·ruby
成为大佬先秃头12 小时前
解决RabbitMQ设置TTL过期后不进入死信队列
分布式·中间件·rabbitmq·java-rabbitmq
七夜zippoe14 小时前
分布式系统实战经验
java·分布式