Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to force delete a kafka topic when delete fails? #6

Open
darrenfu opened this issue Jan 14, 2016 · 4 comments
Open

How to force delete a kafka topic when delete fails? #6

darrenfu opened this issue Jan 14, 2016 · 4 comments
Labels

Comments

@darrenfu
Copy link
Owner

*** This is a known issue ***
Even in the latest Kafka version (0.9.0), the deletion command below isn't always working.

bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic <topic_name>

(Note: Topic deletion option is disabled by default. To enable it set the server config)

delete.topic.enable=true

Bug to track: KAFKA-1397

*** The only way to delete a topic permanently is as follows: ***

  • stop the brokers
    sudo supervisorctl stop kafka-broker
  • remove the directories on disk
    sudo rm -rf <kafka_data_dir>/<topic_name>*
  • remove the topic from zookeeper:
    bin/zkCli.sh
rmr /config/topics/<topic_name>
rmr /brokers/topics/<topic_name>
rmr /admin/delete_topics/<topic_name>
  • verify the topic directory is deleted in zookeeper:
ls <path>
  • start the brokers back up
    sudo supervisorctl start kafka-broker
  • re-create the kafka topic if needed
bin/kafka-topics.sh --zookeeper ${zookeeper_server} --create --topic $topic --partitions=$pars --replication-factor $rep --config retention.ms=$ret
@darrenfu darrenfu added the kafka label Jan 17, 2016
@shanemeister
Copy link

On a MAC, I changed directories to: /usr/local/Cellar/zookeeper/3.4.9/bin
Then:
./zkCli -server localhost:2181 rmr /config/topics/
./zkCli -server localhost:2181 rmr /brokers/topics/
./zkCli -server localhost:2181 rmr /admin/delete_topics/

And actually, if you don't add the topic name, it removes all topics.
kafka-topics --list --zookeeper localhost:2181
Returned no topics.

@abdbaddude
Copy link

Thanks guys ... it worked . Most advised solutions missed on "rmr /config/topics/<topic_name>"

@NateHan
Copy link

NateHan commented Sep 12, 2018

I have followed @darrenfu 's suggestion to the T, checked all the directories to be sure those are cleaned, and they are. However, upon restarting the Kafka Server, it STILL is trying to get a reference to old topics and trying to delete them, failing to rename them when deleting, and shutting down the broker because all the log dirs have failed. Any suggestions from here?

@ghost
Copy link

ghost commented May 13, 2020

If you want to delete all the topics created, Then Stop Kafka and zookeeper and delete data/log directories of both.
i.e. directory specified as log.dirs in Kafka and dataDir in Zookeeper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants