Is there a way to delete all the data from a topic or delete the topic before every run?

后端 未结 13 1881
陌清茗
陌清茗 2020-12-12 10:33

Is there a way to delete all the data from a topic or delete the topic before every run?

Can I modify the KafkaConfig.scala file to change the logRetentionHour

13条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-12 11:36

    As a dirty workaround, you can adjust per-topic runtime retention settings, e.g. bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic my_topic --config retention.bytes=1 (retention.bytes=0 might also work)

    After a short while kafka should free the space. Not sure if this has any implications compared to re-creating the topic.

    ps. Better bring retention settings back, once kafka done with cleaning.

    You can also use retention.ms to persist historical data

提交回复
热议问题