7

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.

Jack
  • 5,540
  • 13
  • 65
  • 113
  • 1
    Possible duplicate of [Delete topic in Kafka 0.8.1.1](http://stackoverflow.com/questions/24287900/delete-topic-in-kafka-0-8-1-1) – Aravind Yarram Jan 23 '16 at 03:11

5 Answers5

7

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.

Community
  • 1
  • 1
Shawn Guo
  • 3,169
  • 3
  • 21
  • 28
5
  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

Balkrushna Patil
  • 418
  • 6
  • 12
2

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

Prasad Khode
  • 6,602
  • 11
  • 44
  • 59
PradeepKumbhar
  • 3,361
  • 1
  • 18
  • 31
1

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.

Fred Gandt
  • 4,217
  • 2
  • 33
  • 41
Robin
  • 61
  • 1
  • 1
  • 5
1

Delete topic in kafka step 1 -->> cd /usr/lib/zookeeper/bin

step 2 -->> zkCli.sh -server 127.0.0.1:2181

step 3 -->>rmr /brokers/topics/topic_name