当前位置:   article > 正文

kafka 删除topic 操作指南_delete.topic.enable

delete.topic.enable

kafka 删除topic 操作指南

删除topic 有两种方式:
开启Kafka的delete.topic.enable=true配置(推荐使用)
手动删除Zookeeper相关数据

方式一
优点:由Kafka来完成Topic的相关删除,只需要修改server.properties配置文件的delete.topic.enable为true就可以了
缺点:需要重启Kafka来完成配置文件的生效

操作步骤:
修改kafka集群的server.properties文件
delete.topic.enable=true #默认是false
auto.create.topics.enable=false #不允许生产者创建topic

pssh -h kafka-ip.lst -l admin -i “echo ‘delete.topic.enable=true’ >> /home/admin/soft/kafka-current/config/server.properties”
pssh -h kafka-ip.lst -l admin -i “echo ‘auto.create.topics.enable=false’ >> /home/admin/soft/kafka-current/config/server.properties”

重启kafka集群

pssh -h kafka-ip.lst -l admin -i “supervisorctl restart kafka”

查看目前所有的topic
ssh kafka所在的服务器

cd /home/admin/soft/kafka-current/
./bin/kafka-topics.sh –list –zookeeper $zkip:port/kafka-zhizi

删除某个topic, 以 streaming-flink-cedt-out-p0 为例
查看streaming-flink-cedt-out-p0 的情况

./bin/kafka-topics.sh –describe –zookeeper zkip:port/kafka−zhizi–topicstreaming−flink−cedt−out−p0删除./bin/kafka−topics.sh–delete–zookeeperzkip:port/kafka−zhizi–topicstreaming−flink−cedt−out−p0删除./bin/kafka−topics.sh–delete–zookeeperzkip:port/kafka-zhizi –topic streaming-flink-cedt-out-p0
查看删除后效果(显示为空)
./bin/kafka-topics.sh –describe –zookeeper $zkip:port/kafka-zhizi –topic streaming-flink-cedt-out-p0

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/982047?site
推荐阅读
相关标签
  

闽ICP备14008679号