[Kafka]How to Clean Topic data
Posted lily-tiantian
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Kafka]How to Clean Topic data相关的知识,希望对你有一定的参考价值。
1.方法一.直接删除Topic
a:如果Kafka服务器 delete.topic.enable=false
1) kafka-topics.sh --delete --zookeeper host:port --topic topicname
2) 删除kafka存储目录(server.properties文件log.dirs配置,默认为"/tmp/kafka-logs")相关topic目录
3)删除zookeeper "/brokers/topics/"目录下相关topic节点
b:如果Kafka服务器 delete.topic.enable=true
bin/kafka-topics.sh --zookeeper 192.168.4.71:2181,192.168.4.72:2181,192.168.4.73:2181delete test
2.方法二:设置 retention.ms
2.1 设置原数据最大的保留时间1m,5分钟后删除,
bin/kafka-configs.sh --alter --zookeeper 192.168.4.71:2181,192.168.4.72:2181,192.168.4.73:2181 --entity-type topics --entity-name test --add-config retention.ms=1000
2.2 删除完毕后,需要重新设置回来7 days
bin/kafka-configs.sh --alter --zookeeper 192.168.4.71:2181,192.168.4.72:2181,192.168.4.73:2181 --entity-type topics --entity-name test --add-config retention.ms=604800000
3.查看topic基本信息
以上是关于[Kafka]How to Clean Topic data的主要内容,如果未能解决你的问题,请参考以下文章
[转]How to Clean the Global Assembly Cache
kafkaFlink 消费 kafka Received unknown topic topic/partition may not exist Describe access to it
How Hulu Uses InfluxDB and Kafka to Scale to Over 1 Million Metrics a Second
SpringBoot: kafka stream报kafka stream must subscribe to at least one source topic or global table