Zookeeper Kakfa createTopics失败

hlswsv35  于 2023-05-27  发布在  Apache
关注(0)|答案(1)|浏览(457)

我是Kafka的新手,我试图使用命令行创建一个主题,它给了我以下错误:

C:\kafka\bin\windows>kafka-topics.bat --create --topic tutorialspedia --bootstrap-server localhost:9092
    Error while executing topic command : Call(callName=createTopics, deadlineMs=1684812803022, tries=1, nextAllowedTryMs=1684812803141) timed out at 1684812803041 after 1 attempt(s)
    [2023-05-23 09:03:23,047] ERROR org.apache.kafka.common.errors.TimeoutException: Call(callName=createTopics, deadlineMs=1684812803022, tries=1, nextAllowedTryMs=1684812803141) timed out at 1684812803041 after 1 attempt(s)
    Caused by: org.apache.kafka.common.errors.DisconnectException: Cancelled createTopics request with correlation id 3 due to node 0

 being disconnected
 (kafka.admin.TopicCommand$)

我有Zookeeper和卡法运行。
我也试过按照其他帖子中的建议执行代码,但得到了错误:

C:\kafka\bin\windows>kafka-topics --zookeeper 127.0.0.1:2181 --topics first_topic --create --partitions 3 --replication-factor 1
Exception in thread "main" joptsimple.UnrecognizedOptionException: zookeeper is not a recognized option
        at joptsimple.OptionException.unrecognizedOption(OptionException.java:108)
        at joptsimple.OptionParser.handleLongOptionToken(OptionParser.java:510)
        at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:56)
        at joptsimple.OptionParser.parse(OptionParser.java:396)
        at kafka.admin.TopicCommand$TopicCommandOptions.<init>(TopicCommand.scala:567)
        at kafka.admin.TopicCommand$.main(TopicCommand.scala:47)
        at kafka.admin.TopicCommand.main(TopicCommand.scala)

我错过什么了吗?

tcbh2hod

tcbh2hod1#

从Kafka 3.0开始,--zookeeper选项已经被删除。现在需要使用-bootstrap-server来指定kafka-topics命令应该使用的Kafka代理。
例如:

./bin/kafka-topics.sh --bootstrap-server localhost:9092 
  --topic first-topic --create 
  --partitions 3 --replication-factor 1

请注意,主题名称的正确标志是--topic(而不是--topics)。

相关问题