Help Center/ MapReduce Service/ Troubleshooting/ Using Kafka/ When a Kafka Topic Fails to Be Created, "NoNode for /brokers/ids" Is Displayed
Updated on 2023-01-11 GMT+08:00

When a Kafka Topic Fails to Be Created, "NoNode for /brokers/ids" Is Displayed

Symptom

When running the following command on the Kafka client to create topics, it is found that the topics cannot be created.

kafka-topics.sh --create  --replication-factor 1 --partitions 2 --topic test --zookeeper 192.168.234.231:2181

The error message "NoNodeException: KeeperErrorCode = NoNode for /brokers/ids" is displayed.

Details are as follows:

Error while executing topic command : org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /brokers/ids
[2017-09-17 16:35:28,520] ERROR 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:995)
	at org.I0Itec.zkclient.ZkClient.getChildren(ZkClient.java:675)
	at org.I0Itec.zkclient.ZkClient.getChildren(ZkClient.java:671)
	at kafka.utils.ZkUtils.getChildren(ZkUtils.scala:541)
	at kafka.utils.ZkUtils.getSortedBrokerList(ZkUtils.scala:176)
	at kafka.admin.AdminUtils$.createTopic(AdminUtils.scala:235)
	at kafka.admin.TopicCommand$.createTopic(TopicCommand.scala:105)
	at kafka.admin.TopicCommand$.main(TopicCommand.scala:60)
	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:115)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:2256)
	at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:2284)
	at org.I0Itec.zkclient.ZkConnection.getChildren(ZkConnection.java:114)
	at org.I0Itec.zkclient.ZkClient$4.call(ZkClient.java:678)
	at org.I0Itec.zkclient.ZkClient$4.call(ZkClient.java:675)
	at org.I0Itec.zkclient.ZkClient.retryUntilConnected(ZkClient.java:985)
	... 8 more
 (kafka.admin.TopicCommand$)

Possible Causes

  • The Kafka service is not running.
  • The ZooKeeper address parameter in the client command is incorrectly configured.

Cause Analysis

  1. After the client command is run, the "NoNodeException" exception is reported.
    Error while executing topic command : org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /brokers/ids
    [2017-09-17 16:35:28,520] ERROR 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:995)
    	at org.I0Itec.zkclient.ZkClient.getChildren(ZkClient.java:675)
    	at org.I0Itec.zkclient.ZkClient.getChildren(ZkClient.java:671)
    	at kafka.utils.ZkUtils.getChildren(ZkUtils.scala:541)
    	at kafka.utils.ZkUtils.getSortedBrokerList(ZkUtils.scala:176)
    	at kafka.admin.AdminUtils$.createTopic(AdminUtils.scala:235)
    	at kafka.admin.TopicCommand$.createTopic(TopicCommand.scala:105)
    	at kafka.admin.TopicCommand$.main(TopicCommand.scala:60)
    	at kafka.admin.TopicCommand.main(TopicCommand.scala)
  2. Check whether the Kafka service is in the normal state on Manager.
  3. Check whether the ZooKeeper address in the client command is correct. Check the Kafka information stored in ZooKeeper. The path (Znode) should be suffixed with /kafka. It is found that /kafka is missing in the configuration.
    [root@10-10-144-2 client]# 
    kafka-topics.sh --create  --replication-factor 1 --partitions 2 --topic test --zookeeper 192.168.234.231:2181

Solution

  1. Ensure that the Kafka service is normal.
  2. Add /kafka to the ZooKeeper address in the command.

    [root@10-10-144-2 client]# 
    kafka-topics.sh --create  --replication-factor 1 --partitions 2 --topic test --zookeeper 192.168.234.231:2181/kafka