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

相关推荐
Bug退退退1234 小时前
RabbitMQ 高级特性之事务
java·分布式·spring·rabbitmq
CodeWithMe5 小时前
【Note】《Kafka: The Definitive Guide》第四章:Kafka 消费者全面解析:如何从 Kafka 高效读取消息
分布式·kafka
洁辉7 小时前
Spring Cloud 全栈指南:构建云原生微服务的终极武器
spring cloud·微服务·云原生
Gauss松鼠会8 小时前
GaussDB应用场景全景解析:从金融核心到物联网的分布式数据库实践
数据库·分布式·物联网·金融·database·gaussdb
阿里云云原生9 小时前
加工进化论:SPL 一键加速日志转指标
云原生
阿里云云原生10 小时前
破解异构日志清洗五大难题,全面提升运维数据可观测性
云原生
@Jackasher11 小时前
Redisson是如何实现分布式锁的?
分布式
阿里云云原生16 小时前
从 Python 演进探寻 AI 与云对编程语言的推动
云原生
亲爱的非洲野猪17 小时前
关于k8s Kubernetes的10个面试题
云原生·容器·kubernetes
西京刀客17 小时前
k8s之configmap
云原生·容器·kubernetes