Kafka to zookeeper command produces error
Asked Answered
O

5

11
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?

Overdye answered 1/2, 2016 at 8:3 Comment(3)
Perhaps Zookeeper wasn't started?Raglan
i'm not familiar with how kafka uses zk, but this looks like the kafka system wasn't started with the same zk connection information.Serum
try removing the /kafkaVolitive
S
6

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
Subcontract answered 29/11, 2016 at 20:37 Comment(0)
D
4

In a nutshell, this means that the kafka-topics.sh script cannot find any active Kafka brokers registered with ZooKeeper. This could be for several reasons:

  1. Your Kafka broker(s) are not running.

  2. Your Kafka broker(s) are up, but they're connected to a different ZooKeeper instance than the one you referenced in your kafka-topics.sh command.

  3. Your Kafka broker(s) are up, and connecting to the correct ZooKeeper instance, but they're registered under a different chroot than the one in your command. In your example of --zookeeper localhost:2181/kafka, the chroot is the /kafka bit. You can find the chroot being used by your Kafka brokers in the $KAFKA_HOME/config/server.properties file, under the zookeeper.connect property.

Daisie answered 14/6, 2018 at 17:5 Comment(0)
T
1

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.

Thinker answered 24/8, 2016 at 17:3 Comment(0)
S
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)
Sauceda answered 27/2, 2017 at 3:38 Comment(0)
B
0

In my case, I have started only zookeeper and forgot starting kafka server. I started the kafka server as well and then created the topic. The command worked fine.

Batting answered 25/3, 2017 at 6:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.