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

相关推荐
是Dream呀7 小时前
Harness 工程:让 Agent 真正把任务做完
人工智能·分布式·缓存·agent
yt004yt7 小时前
绿岛数字化平台搭建:VOCs 监测与能碳数据一体化方案
大数据·分布式
天天喝旺仔9 小时前
分布式服务容错实战:用 Sentinel 实现限流、熔断与降级
分布式·微服务·云原生·sentinel
lisanmengmeng11 小时前
分布式追踪与监控:Skywalking(三)
分布式·skywalking
逐流人12 小时前
Containerd容器管理实战:从架构原理到nerdctlcrictl工具链
linux·运维·云原生·容器·云计算·containerd
会周易的程序员20 小时前
5 节点边缘冗余方案(上):基于 aiRaft 的物联网高可用控制面设计
c++·分布式·物联网·raft·iot·共识
运维开发王义杰1 天前
跨项目直连数据库:是架构反模式,还是现实的工程妥协?
云原生
青山木1 天前
RocketMQ 入门到原理(一):整体架构与消息的生命周期
java·分布式·后端·中间件·架构·rocketmq
宋均浩1 天前
告警规则 243 砍到 27:Prometheus 降噪实战,日均打扰 47 次 → 3 次
云原生·监控·devops