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?
Steps to Delete 1 or more Topics in Kafka
To delete topics in kafka the delete option needs to be enabled in Kafka server.
Delete one Topic in Kafka enter the following command
kafka-topics.sh --delete --zookeeper localhost:2181 --topic
To Delete more than one topic from kafka
(good for testing purposes, where i created multiple topics & had to delete them for different scenarios)
bin/kafka-topics.sh --list --zookeeper localhost:2181
if no topics are listed then the all topics have been deleted successfully.If topics are listed, then the delete was not successful. Try the above steps again or restart your computer.
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:
In the meantime, the bug got fixed and the deletion command is now officially available from Kafka 0.8.2.0 as:
Add below line in ${kafka_home}/config/server.properties
Restart the kafka server with new config:
Delete the topics you wish to:
You can delete a specific kafka topic (example:
test
) from zookeeper shell command (zookeeper-shell.sh
). Use the below command to delete the topicexample:
This steps will delete all topics and data
Adding to above answers one has to delete the meta data associated with that topic in zookeeper consumer offset path.
bin/zookeeper-shell.sh zookeeperhost:port
rmr /consumers/<sample-consumer-1>/offsets/<deleted-topic>
Otherwise the lag will be negative in kafka-monitoring tools based on zookeeper.