同事新搭建了一个kafka集群,在创建topic的时候遇到错误:

执行:./kafka-topics.sh --zookeeper linux1:2181 --create --topic test --replication-factor 1 --partitions 1

报错:

rror while executing topic command org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /brokers/ids
org.I0Itec.zkclient.exception.ZkNoNodeException: org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /brokers/ids
    at org.I0Itec.zkclient.exception.ZkException.create(ZkException.java:47)
    at org.I0Itec.zkclient.ZkClient.retryUntilConnected(ZkClient.java:685)
    at org.I0Itec.zkclient.ZkClient.getChildren(ZkClient.java:413)
    at org.I0Itec.zkclient.ZkClient.getChildren(ZkClient.java:409)
    at kafka.utils.ZkUtils$.getChildren(ZkUtils.scala:462)
    at kafka.utils.ZkUtils$.getSortedBrokerList(ZkUtils.scala:78)
    at kafka.admin.AdminUtils$.createTopic(AdminUtils.scala:170)
    at kafka.admin.TopicCommand$.createTopic(TopicCommand.scala:93)
    at kafka.admin.TopicCommand$.main(TopicCommand.scala:55)
    at kafka.admin.TopicCommand.main(TopicCommand.scala)
Caused by: org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /brokers/ids
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:111)
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
    at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1472)
    at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1500)
    at org.I0Itec.zkclient.ZkConnection.getChildren(ZkConnection.java:99)
    at org.I0Itec.zkclient.ZkClient$2.call(ZkClient.java:416)
    at org.I0Itec.zkclient.ZkClient$2.call(ZkClient.java:413)
    at org.I0Itec.zkclient.ZkClient.retryUntilConnected(ZkClient.java:675)
    ... 8 more


百度了一下发现是因为没有指定kafka在zookeeper上的根目录。不知道是不是版本的问题,我在用0.9的时候没有出现这种问题,但是用0.8的时候就出现了。


修改为:./kafka-topics.sh --zookeeper linux1:2181/kafka --create --topic test --replication-factor 1 --partitions 1

创建成功


Logo

Kafka开源项目指南提供详尽教程,助开发者掌握其架构、配置和使用,实现高效数据流管理和实时处理。它高性能、可扩展,适合日志收集和实时数据处理,通过持久化保障数据安全,是企业大数据生态系统的核心。

更多推荐