kafka创建topic报错

kafka执行如下创建topic的语句:

[root@node01 kafka_2.11-1.0.0]# bin/kafka-topics.sh --create --topic streaming-test --replication-factor 1 --partitions 3 --zookeeper node01:2181,node02:2181,node03:2181
Error while executing topic command : Replication factor: 1 larger than available brokers: 0.
报错:[2019-10-15 20:23:25,461] ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 1 larger than available brokers: 0.

原因:broker的配置文件server.properties中的配置项zookeeper.connect指定了kafka的zookeeper的根目录(zookeeper.connect=node01:2181,node02:2181,node03:2181/kafka)

解决方法:命令行参数“--zookeeper”的值也需要带上根目录,如下:

bin/kafka-topics.sh --create --topic streaming-test --replication-factor 1 --partitions 3 --zookeeper node01:2181,node02:2181,node03:2181/kafka

 

上一篇:从零写一个编译器(二):语法分析之前置知识


下一篇:csp校门外的树