清除卡夫卡主题 [英] Purge Kafka Topic

查看:38
本文介绍了清除卡夫卡主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

kafka 有没有办法清除话题?

我将过大的消息推送到本地计算机上的 kafka 消息主题中,现在出现错误:

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

kafka.common.InvalidMessageSizeException: invalid message size

在这里增加 fetch.size 并不理想,因为我实际上不想接受那么大的消息.

Increasing the fetch.size is not ideal here, because I don't actually want to accept messages that big.

推荐答案

临时更新主题的保留时间为一秒:

Temporarily update the retention time on the topic to one second:

kafka-topics.sh --zookeeper <zkhost>:2181 --alter --topic <topic name> --config retention.ms=1000

在较新的 Kafka 版本中,您也可以使用 kafka-configs --entity-type 主题

And in newer Kafka releases, you can also do it with kafka-configs --entity-type topics

kafka-configs.sh --zookeeper <zkhost>:2181 --entity-type topics --alter --entity-name <topic name> --add-config retention.ms=1000

然后等待清除生效(持续时间取决于主题的大小).清除后,恢复之前的 retention.ms 值.

then wait for the purge to take effect (duration depends on size of the topic). Once purged, restore the previous retention.ms value.

这篇关于清除卡夫卡主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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