Delete topic in Kafka 0.8.1.1

I need to delete the topic test in Apache Kafka 0.8.1.1.

As expressed in the documentation here, I have executed:

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

However, this results in the following message:

Command must include exactly one action: --list, --describe, --create or --alter

How can I delete this topic?


Solution 1:

Deleting topic isn't always working in 0.8.1.1

Deletion should be working in the next release, 0.8.2

kafka-topics.sh --delete --zookeeper localhost:2181 --topic your_topic_name

  Topic your_topic_name is marked for deletion.
  Note: This will have no impact if delete.topic.enable is not set to true.

You may also pass in a bootstrap server instead of zookeeper:

kafka-topics.sh --bootstrap-server kafka:9092 --delete --topic your_topic_name

Is it possible to delete a topic?

Jira KAFKA-1397

Solution 2:

It seems that the deletion command was not officially documented in Kafka 0.8.1.x because of a known bug (https://issues.apache.org/jira/browse/KAFKA-1397).

Nevertheless, the command was still shipped in the code and can be executed as:

bin/kafka-run-class.sh kafka.admin.DeleteTopicCommand --zookeeper localhost:2181 --topic test

In the meantime, the bug got fixed and the deletion command is now officially available from Kafka 0.8.2.0 as:

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