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

后端 未结 13 1892
陌清茗
陌清茗 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 of kafka 2.3.0 version, there is an alternate way to soft deletion of Kafka (old approach are deprecated ).

    Update retention.ms to 1 sec (1000ms) then set it again after a min, to default setting i.e 7 days (168 hours, 604,800,000 in ms )

    Soft deletion:- (rentention.ms=1000) (using kafka-configs.sh)

    bin/kafka-configs.sh --zookeeper 192.168.1.10:2181 --alter --entity-name kafka_topic3p3r --entity-type topics  --add-config retention.ms=1000
    Completed Updating config for entity: topic 'kafka_topic3p3r'.
    

    Setting to default:- 7 days (168 hours , retention.ms= 604800000)

    bin/kafka-configs.sh --zookeeper 192.168.1.10:2181 --alter --entity-name kafka_topic3p3r --entity-type topics  --add-config retention.ms=604800000
    
    0 讨论(0)
提交回复
热议问题