Saturday, March 9, 2019

How to delete Kafka topic message

Prepare the offset (message below it will be removed)

[donghua@hdp ~]$ /usr/hdp/current/kafka-broker/bin/kafka-topics.sh --describe --topic kafka_hive_topic --zookeeper hdp:2181
Topic:kafka_hive_topic PartitionCount:1 ReplicationFactor:1 Configs:
Topic: kafka_hive_topic Partition: 0 Leader: 1001 Replicas: 1001 Isr: 1 001

parameter file:

[donghua@hdp ~]$ cat /tmp/delete_offset1.json 
{"partitions":                        
    [{"topic": "kafka_hive_topic", "partition": 0,   
     "offset": 12}],
   "version":1     

Execute kafka-delete-records.sh

[donghua@hdp ~]$ /usr/hdp/current/kafka-broker/bin/kafka-delete-records.sh --bootstrap-server hdp:6667 --offset-json-file /tmp/delete_offset1.json 
Executing records delete operation
Records delete operation completed:
partition: kafka_hive_topic-0 low_watermark: 12

No comments:

Post a Comment