kafka创建topic报错

Posted mediocreworld

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

 

以上是关于kafka创建topic报错的主要内容,如果未能解决你的问题,请参考以下文章

kafka Create topic 报错

kafka报错:Exception in thread “main“ joptsimple.UnrecognizedOptionException: zookeeper is not a recogn

kafka报错:Exception in thread “main“ joptsimple.UnrecognizedOptionException: zookeeper is not a recogn

记录一下Kafka报错:timeout expired while fetching topic metadata

查看Kafka集群下所有的topic报错“Timed out waiting for a node assignment. Call: listTopics“

kafka Java创建生产者报错:Invalid partition given with record: 1 is not in the range [0...1)