Purge Kafka Topic

后端 未结 19 2381
慢半拍i
慢半拍i 2020-11-28 00:06

Is there a way to purge the topic in kafka?

I pushed a message that was too big into a kafka message topic on my local machine, now I\'m getting an

19条回答
  •  清歌不尽
    2020-11-28 00:51

    Sometimes, if you've a saturated cluster (too many partitions, or using encrypted topic data, or using SSL, or the controller is on a bad node, or the connection is flaky, it'll take a long time to purge said topic.

    I follow these steps, particularly if you're using Avro.

    1: Run with kafka tools :

    bash kafka-configs.sh --alter --entity-type topics --zookeeper zookeeper01.kafka.com --add-config retention.ms=1 --entity-name 
    

    2: Run on Schema registry node:

    kafka-avro-console-consumer --consumer-property security.protocol=SSL --consumer-property ssl.truststore.location=/etc/schema-registry/secrets/trust.jks --consumer-property ssl.truststore.password=password --consumer-property ssl.keystore.location=/etc/schema-registry/secrets/identity.jks --consumer-property ssl.keystore.password=password --consumer-property ssl.key.password=password --bootstrap-server broker01.kafka.com:9092 --topic --new-consumer --from-beginning

    3: Set topic retention back to the original setting, once topic is empty.

    bash kafka-configs.sh --alter --entity-type topics --zookeeper zookeeper01.kafka.com --add-config retention.ms=604800000 --entity-name 
    

    Hope this helps someone, as it isn't easily advertised.

提交回复
热议问题