如何正确创建一个新的消费者组并在Kafka CLI中重置所有主题的偏移量?

huangapple go评论50阅读模式
英文:

How should I properly create a new consumer group and reset the offset from all topics in kakfa CLI?

问题

我有1000多个kafka主题,每个主题包含14天的数据,大约12亿条消息。

我创建了一个新的消费者组:groupA,并执行了重置偏移量的命令。

sh kafka-consumer-groups.sh --reset-offsets --execute --to-datetime "2023-05-03T00:00:00.000" --group groupA --bootstrap-server kfk-data-001:9092,kfk-data-002:9092,kfk-data-003:9092 --all-topics

但它没有按照我的期望工作,我尝试在Java中使用groupA拉取数据,仍然会消耗每个主题的起始数据。

我应该如何正确创建组并从所有主题重置偏移量?

英文:

I have 1000+ topics in my kakfa, each topic contains 14 days of data, about 1.2 billion messages.

I created a new consumer group: groupA, and executed the command to reset the offset.

sh kafka-consumer-groups.sh --reset-offsets --execute --to-datetime "2023-05-03T00:00:00.000" --group groupA --bootstrap-server kfk-data- 001:9092,kfk-data-002:9092,kfk-data-003:9092 --all-topics

But it didn't work as I expected, I tried to use groupA pull data in Java, and it still consumes the starting data for each topics.

How should I properly create the group and reset the offset from all topics?

答案1

得分: 0

你不需要使用那个命令。在你的消费者代码中,你可以使用消费者实例的offsetsForTimeseek函数来前往你想要的时间戳。

英文:

You don't need to use that command. In your consumer code, you could use offsetsForTime and seek function of consumer instance to go to the timestamp you want

huangapple
  • 本文由 发表于 2023年5月6日 18:01:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76188278.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定