Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confusion about delete Kafka Topic

Tags:

apache-kafka

I'm using Kafka 0.8.0, it's Cloudera version. When I deleted the topic such as: kafka-topics --zookeeper 10.0.0.11:2181/ --delete --topic test it response:

Topic test is already marked for deletion.

But afterwards I recreated it, it throw exception as following:

kafka-topics --create --zookeeper 10.0.0.11:2181 --partitions 90 --replication-factor 2 --topic test

Error while executing topic command Topic "test" already exists.
kafka.common.TopicExistsException: Topic "test" already exists.

Any ideas please? How should I delete the topic and it's data.

like image 756
Jack Avatar asked Jan 23 '16 02:01

Jack


4 Answers

My Kakfa version is kafka_2.10-0.8.2.2, below link works for me (from Delete topic in Kafka 0.8.1.1)

Add below line in ${kafka_home}/config/server.properties

delete.topic.enable=true   

Restart the kafka server with new config:

${kafka_home}/bin/kafka-server-start.sh ~/kafka/config/server.properties

Delete the topics you wish to:

${kafka_home}/bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic daemon12

More information from Kafka FAQ:

Deleting a topic is supported since 0.8.2.x. You will need to enable topic deletion (setting delete.topic.enable to true) on all brokers first.

like image 169
Shawn Guo Avatar answered Sep 21 '22 23:09

Shawn Guo


  1. Make sure that, In kafka's config.poperties file 'delete.topic.enable' property should be true.
  2. use below command

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

Even if topic is not deleted then follow next steps.

  1. open terminal zookeeper client mode:

    A. stop zookeeper

    B. rmr /broker/topics

    C. check given topic using below command

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

like image 25
Balkrushna Patil Avatar answered Sep 21 '22 23:09

Balkrushna Patil


If delete.topic.enable is set to false by default, the topics are not deleted on execution of --delete command (as displayed in the command response).

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

In order to overcome this, use steps mentioned by @Shawn

like image 28
PradeepKumbhar Avatar answered Sep 23 '22 23:09

PradeepKumbhar


The best and easy to make delete.topic.enable=true is not modify the server.property file.

Because, if kafka restart from ambari, it will overwrite this file, delete.topic.enable =false again.

Only at ambari, click on kafak/config/advance kafka broker/delete.topic.enable =true, it will work.

I just found that out as now.

like image 28
Robin Avatar answered Sep 24 '22 23:09

Robin