从 kafka 主题中删除单个记录 [英] Delete single records from a kafka topic

查看:37
本文介绍了从 kafka 主题中删除单个记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法从 kafka 主题中删除单个记录?我知道有脚本 kafka-delete-records.sh 可以删除指定主题和分区上指定偏移量之前的记录,但我希望能够删除我指定的偏移量上的记录.有没有办法做到这一点?

Is there a way to delete a single record from a kafka topic? I know there is the script kafka-delete-records.sh that deletes the records that are before the specified offset on a specified topic and partition, but I want to be able to delete a record on an offset I specify. Is there a way to do that?

这不是在 Java 上,而是在裸 kafka 实例上.

This is not on Java but on the bare kafka instance.

推荐答案

在压缩的 Topic 上,您可以通过为要指示删除的键发布消息来将记录标记为墓碑"并使用空值.在此处查看答案:Kafka 不使用墓碑删除密钥

On a compacted Topic you can mark a record as a 'tombstone' by publishing a message for the key you want to indicate is deleted with a null value. See answers here: Kafka not deleting key with tombstone

如果主题未压缩,则必须通过保留策略删除记录.您不能针对要删除的单个偏移量.

If the topic is not compacted, the record must be removed through retention policies. You cannot target individual offsets to remove.

这篇关于从 kafka 主题中删除单个记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆