kafka主题删除_如何删除apache kafka中的主题

I need to delete a topic in kafka-0.8.2.2.3. I have used the below command for deleting the topic:

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

The command executed successfully but when I run a command to list the topics, I could see that the topic is still there and it shows marked for deletion.

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

DummyTopic - marked for deletion

And when I create the topic DummyTopic it outputs the exception, The topic already exists, below is the stack trace:

Error while executing topic command Topic "DummyTopic" already exists.

kafka.common.TopicExistsException: Topic "DummyTopic" already exists.

at kafka.admin.AdminUtils$.createOrUpdateTopicPartitionAssignmentPathInZK(AdminUtils.scala:248)

at kafka.admin.AdminUtils$.createTopic(AdminUtils.scala:233)

at kafka.admin.TopicCommand$.createTopic(TopicCommand.scala:92)

at kafka.admin.TopicCommand$.main(TopicCommand.scala:54)

at kafka.admin.TopicCommand.main(TopicCommand.scala)

Please let me know how can I delete this topic.

解决方案

Deletion of a topic has been supported since 0.8.2.x version. You have to enable topic deletion (setting delete.topic.enable to true) on all brokers first.

Follow this step by step process for manual deletion of topics

Stop Kafka server

Delete the topic directory with rm -rf command

Connect to Zookeeper instance: zookeeper-shell.sh host:port

ls /brokers/topics

Remove the topic folder from ZooKeeper using rmr /brokers/topics/yourtopic

Restart Kafka server

Confirm if it was deleted or not by using this command

kafka-topics.sh --list --zookeeper host:port

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值