环境配置
节点 | IP地址 |
---|---|
Node1 | 192.168.2.201 |
Node2 | 192.168.2.202 |
Node3 | 192.168.2.203 |
下载安装
通过官网下载地址获取kafka_2.13-3.2.1
版本的压缩包。
ZooKeeper集群配置
修改zookeeper.properties
配置文件,增加以下内容:
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
# disable the per-ip limit on the number of connections since this is a non-production config
maxClientCnxns=0
# Disable the adminserver by default to avoid port conflicts.
# Set the port to something non-conflicting if choosing to enable this
admin.enableServer=true
admin.serverPort=8080
tickTime=2000
initLimit=10
syncLimit=5
server.0=192.168.2.201:2888:3888
server.1=192.168.2.202:2888:3888
server.2=192.168.2.203:2888:3888
在/tmp/zookeeper
目录下创建myid
文件,文件内容为当前节点的编号。
[root@node1 bin]# echo "0" > /tmp/zookeeper/myid
[root@node2 bin]# echo "1" > /tmp/zookeeper/myid
[root@node3 bin]# echo "2" > /tmp/zookeeper/myid
启动ZooKeeper
执行启动脚本并指定配置文件:
[root@node1 bin]# ./zookeeper-server-start.sh ../config/zookeeper.properties
Kafka集群配置
修改配置文件server.properties
中的内容,修改以下配置项:
broker.id=0
num.partitions=3
auto.create.topics.enable=true
offsets.topic.replication.factor=3
transaction.state.log.replication.factor=3
transaction.state.log.min.isr=2
zookeeper.connect=192.168.2.201:2181,192.168.2.203:2181,192.168.2.203:2181
启动Kafka
执行启动脚本
[root@node1 bin]# ./kafka-server-start.sh ../config/server.properties