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