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 将存储数据的日志目录,在准备工作中创建好的目录

相关推荐
秋播2 天前
国内本地WSL2编译rancher源码
云原生
小猿姐3 天前
MySQL Top 10 热点问题 AI 运维实战:从内核诊断到云原生运维
mysql·云原生·aiops
阿里云云原生5 天前
深入内核:拆解 OpenTelemetry eBPF 探针如何优雅地“透视”多语言微服务?
云原生
JLWcai202510095 天前
铸造领域树脂砂轮|金利威多场景解决方案,20 + 配方覆盖全需求
mongodb·zookeeper·eureka·spark·rabbitmq·memcached·storm
java_cj5 天前
深入kube-apiserver认证机制:从Bearer Token到mTLS的完整认证链解析
linux·运维·服务器·云原生·容器·kubernetes
风吹夏回5 天前
RabbitMQ 核心术语 + Python pika 方法完整讲解
分布式·python·rabbitmq
风吹夏回5 天前
RabbitMQ 三种模式入门:HelloWorld、WorkQueue、PubSub
分布式·rabbitmq·ruby
霸道流氓气质5 天前
分布式追踪与 RequestId 传播完全指南
分布式
cheems95275 天前
[RabbitMQ高级特性] 消息确认机制:从 Ready / Unacked 到 basicAck、basicReject、basicNack 的底层拆解
分布式·rabbitmq·ruby
互联网推荐官5 天前
上海软件定制开发公司推荐:从PaaS工程化路径看D-coding的技术取舍
云原生·云计算·paas·软件开发·开发经验·上海