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 --
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.
Andrea is correct. we can do it using command line.
And we still can program it, by
ZkClient zkClient = new ZkClient("localhost:2181", 10000);
zkClient.deleteRecursive(ZkUtils.getTopicPath("test2"));
Actually I do not recommend you delete topic on Kafka 0.8.1.1. I can delete this topic by this method, but if you check log for zookeeper, deletion mess it up.
If you have issues deleting the topics, try to delete the topic using:
$KAFKA_HOME/bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic your_topic_name
command. Then in order to verify the deletion process, go to the kafka logs directory which normally is placed under /tmp/kafka-logs/
, then delete the your_topic_name
file via rm -rf your_topic_name
command.
Remember to monitor the whole process via a kafka management tool like Kafka Tool
.
The mentioned process above will remove the topics without kafka server restart.
bin/kafka-topics.sh –delete –zookeeper localhost:2181 –topic <topic-name>
You can delete a specific kafka topic (example: test
) from zookeeper shell command (zookeeper-shell.sh
). Use the below command to delete the topic
rmr {path of the topic}
example:
rmr /brokers/topics/test
Steps to Delete 1 or more Topics in Kafka
1. Go to {kafka_home}/config/server.properties
2. Uncomment delete.topic.enable=true
kafka-topics.sh --delete --zookeeper localhost:2181 --topic
(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.