kafka2.3集群搭建

时间:2021-04-04 20:10:33

环境:
3台centos7.4
3台zookeeper3.4.14
1. wget http://mirror.bit.edu.cn/apache/kafka/2.3.0/kafka_2.11-2.3.0.tgz
2. 解压:tar -zxvf kafka_2.11-2.3.0.tgz
3. 进入kafka目录,修改config/server.properties,找到zookeeper.connect,修改zk集群的连接地址为:
zookeeper.connect=10.99.32.3:2181,10.99.32.31:2181,10.99.32.9:2181
然后修改broker.id=0 //1,2,每个节点的id必须不一样,否则启动会报错
4. 启动kafka:bin/kafka-server-start.sh -daemon config/server.properties
启动报错:org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = NodeExists:写入zk时目录相同,原因可能是server.properties里面的broker.id=1重复了
5. 启动成功后使用jps查看运行的,或者使用ps -aux | grep kafka,有记录即为运行成功
6. 创建topic:
bin/kafka-topics.sh --create --zookeeper 10.99.32.3:2181 --replication-factor 3 --partitions 1 --topic myTopic
7. 显示topic信息:
bin/kafka-topics.sh --describe --zookeeper 10.99.32.3:2181 --topic myTopic
8. 添加信息节点只需要配置增加即可