【问题标题】:How are offsets reset in kafka 0.11如何在 kafka 0.11 中重置偏移量
【发布时间】:2018-06-02 02:48:10
【问题描述】:

我使用的是 kafka 0.11。我正在尝试重置消费者组中主题的偏移量,但看不到选项之间的一致性。 kafka-consumer-groups中不同option的offset是如何计算的?

$ /opt/cloudera/parcels/KAFKA-3.0.0-1.3.0.0.p0.40/lib/kafka/bin/kafka-consumer-groups.sh --bootstrap-server xxxxxxxxxxxx.devkafka.com:9092 --group testgroup --reset-offsets **--by-duration PT1H30M0S** --topic Test_Upgrade --export --command-config client.properties 2>/dev/null
**Test_Upgrade,1,615
Test_Upgrade,0,625**

$ date
**Thu May 31 15:30:45 BST 2018**

$ /opt/cloudera/parcels/KAFKA-3.0.0-1.3.0.0.p0.40/lib/kafka/bin/kafka-consumer-groups.sh --bootstrap-server xxxxxxxxxxxx.devkafka.com:9092 --group testgroup --reset-offsets **--to-datetime 2018-05-31T14:00:00.000** --topic Test_Upgrade --export --command-config client.properties 2>/dev/null
**Test_Upgrade,1,754
Test_Upgrade,0,772**

【问题讨论】:

    标签: apache-kafka


    【解决方案1】:

    --to-datetime - 当我们想要将偏移重置到特定时间点时。 (例如到 2017 年 1 月 1 日 00:00 重新处理这些年份的所有记录)
    --by-duration - 当我们想回到某个时期之前(例如 P7D 重新处理一周前的所有记录)

    取自这里KIP-122

    要实际运行它,您需要将--execute 添加到您的命令中,没有它,Kafka 会打印操作结果。

    更多信息在gist

    【讨论】:

      猜你喜欢
      • 2018-01-22
      • 2018-05-03
      • 2017-03-09
      • 2018-01-30
      • 2018-10-14
      • 2019-08-23
      • 2018-02-03
      • 2016-06-01
      • 2021-10-16
      相关资源
      最近更新 更多