0

I have deleted topic directly from Zookeeper using the below command and did not execute deletion from Kafka before:

zookeeper-shell.sh localhost:2181 rmr /brokers/topics/<topic_name>

Now what I see is that the topic shows up in the log.dirs of at least one broker in the cluster. Is there a way that can be deleted as well.

When i attempt to delete from kafka now it throws the below error

Error while executing topic command : Topic <topic_name> does not exist on ZK path <zookeeper_server_list:2181>
Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156
Preethi Jahnavi
  • 187
  • 1
  • 1
  • 10

1 Answers1

1

I think you have missed a couple of steps. In order to manually delete a topic you need to follow these steps:

1) Stop Kafka server

2) On each broker, you have you have to delete all the topic's log files under logs.dirs:

rm -rf path/to/logs/topic_name/

3) Remove topic directory from Zookeeper:

> zookeeper-shell.sh localhost:2181
> ls /brokers/topics
> rmr /brokers/topics/topic_name

4) Restart Kafka server


Note that the suggested way for deleting a topic is

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

assuming that delete.topic.enable=true.

Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156