3
votes

I try to delete a existing topic (I checked using kafka management console) using following command;

#./kafka-topics.sh --zookeeper zookeeper.xx.com:2181/chroot --delete --topic testTopic

But it says topic not available in zookeeper.[1]

I create those topics at runtime . (I use Highlevel Client APIs.I think it is created in kafka clusters? )

How can I delete the topic using this bash script?

[1]

Error while executing topic command : Topic targettopic does not exist on ZK path zookeeper.xx.com:2181/chroot

[2016-10-14 11:58:59,919] ERROR java.lang.IllegalArgumentException: Topic streamtargettopic does not exist on ZK path zookeeper.xx.com:2181/chroot

at kafka.admin.TopicCommand$.deleteTopic(TopicCommand.scala:169)

at kafka.admin.TopicCommand$.main(TopicCommand.scala:69)

at kafka.admin.TopicCommand.main(TopicCommand.scala)
2
Does the topic exist? ./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181/chroot --topic testTopci --describelouxiu
@louxiu No output for the above command. Means my topic is not in zookeeper? So, where the topics are created in kafka 0.10?Ratha
Not sure for 0.10.1, I tried this in 0.9.0.1 ./bin/kafka-topics.sh --create --zookeeper 127.0.0.1:2181 --topic test_kafka123 --replication-factor 1 --partitions 1. The topic is under /brokers/topics in zk and command above can be printed. I think you can try to create topic using command if you have not tried.louxiu
@louxiu Issue was I had "/chroot" at the end of the zookeeper parameter. Now working fine without that.Ratha

2 Answers

18
votes

You can use below command to check the list of topics available in Zookeeper.

bin/kafka-topics.sh --list --zookeeper localhost:2181

Also set the below properties in server.properties

delete.topic.enable=true 

Then try to delete the topic using

bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic test
1
votes

If the below command didn't work for you

bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic test

You can do the delete manually by connecting to zookeeper and delete the path.

./zookeeper-shell.sh

Manually delete the topic

rmr /brokers/topics/<topic>