Help Center/ MapReduce Service/ Troubleshooting/ Using Kafka/ Failed to Manage a Kafka Cluster Using the Kafka Shell Command
Updated on 2023-11-30 GMT+08:00

Failed to Manage a Kafka Cluster Using the Kafka Shell Command

Symptom

A user fails to run the Kafka command to view the current topic information.

The error information is as follows:

root@Slave2bin]#./kafka-topics.sh --describe --topic example-metric1 --zookeeper 192.119.147.231:2181,192.119.147.228:2181,192.119.147.227:2181
Error while executing topic command:org.apache.zookeeper.KeeperException$AuthFailedException:KeeperErrorCode=AuthFailedfor/brokers/topics
[2016-09-2616:58:59,873]ERRORorg.I0Itec.zkclient.exception.ZkException:org.apache.zookeeper.KeeperException$AuthFailedException:KeeperErrorCode=AuthFailedfor/brokers/topics
atorg.I0Itec.zkclient.exception.ZkException.create(ZkException.java:68)
atorg.I0Itec.zkclient.ZkClient.retryUntilConnected(ZkClient.java:995)
atorg.I0Itec.zkclient.ZkClient.getChildren(ZkClient.java:675)
atorg.I0Itec.zkclient.ZkClient.getChildren(ZkClient.java:671)
atkafka.utils.ZkUtils.getChildrenParentMayNotExist(ZkUtils.scala:548)
atkafka.utils.ZkUtils.getAllTopics(ZkUtils.scala:798)
atkafka.admin.TopicCommand$.getTopics(TopicCommand.scala:82)
atkafka.admin.TopicCommand$.describeTopic(TopicCommand.scala:183)
atkafka.admin.TopicCommand$.main(TopicCommand.scala:66)
atkafka.admin.TopicCommand.main(TopicCommand.scala)
Causedby:org.apache.zookeeper.KeeperException$AuthFailedException:KeeperErrorCode=AuthFailedfor/brokers/topics
atorg.apache.zookeeper.KeeperException.create(KeeperException.java:127)
atorg.apache.zookeeper.KeeperException.create(KeeperException.java:51)
atorg.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:2256)
atorg.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:2284)
atorg.I0Itec.zkclient.ZkConnection.getChildren(ZkConnection.java:114)
atorg.I0Itec.zkclient.ZkClient$4.call(ZkClient.java:678)
atorg.I0Itec.zkclient.ZkClient$4.call(ZkClient.java:675)
atorg.I0Itec.zkclient.ZkClient.retryUntilConnected(ZkClient.java:985)
...8more
(kafka.admin.TopicCommand$)

Cause Analysis

The user has checked the permission of the account for running this command. The account has the highest permission to perform operations for Kafka. This problem is not caused by lack of permission.

The command executed is incorrect. It should contain /kafka to access the path (Znode) of the Kafka information stored on ZooKeeper. The correct command is as follows:

root@Slave2bin]#./kafka-topics.sh --describe --topic example-metric1 --zookeeper 192.168.147.231:2181,192.168.147.228:2181,192.168.147.227:2181/kafka

Solution

Use the correct command to query topic information. For details, see Shell.