Kafka to zookeeper command produces error
bin/kafka-topics.sh --create --topic activityTopic --zookeeper localhost:2181/kafka --partitions 1 --replication-factor 1
The above command from kafka produces an error
Error 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)
Any idea?
In my case, the problem was that I was specifying a non-existent kafka chroot.
I discovered that our company ops team had configured the kafka chroot as purple-elephants
, and configured the creation of this chroot to be ensured on kafka service restart.
First I issued a sudo service kafka restart
and the log shows that the chroot was created:
Ensuring chroot '/purple-elephants' exists
Starting Kafka server.
Then I simply issued:
bin/kafka-topics.sh --create --topic activityTopic --zookeeper localhost:2181/purple-elephants --partitions 1 --replication-factor 1
Try removing /kafka as the command is
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic Falcon
If it still occurs then be sure about the path in zookeeper.properties of
dataDir(default is /tmp/zookeeper)
and path in server.properties of
log.dirs(default is /tmp/kafka-logs)
while creating topic, it should be zookeeper url with --zookeeper option. It should work the following line if zookeeper & kafka are working.
--zookeeper localhost:2181
This link describes how to create a topic. You can also check the no of available ids in zookeeper cli. ./zkCli.sh
& then ls /brokers/ids
. At lease one broker id should be displayed.
上一篇: 根据用例正确设置git autocrlf
下一篇: 卡夫卡到zookeeper命令产生错误