You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by Evan <ch...@foxmail.com> on 2020/01/13 02:47:48 UTC
回复: Re: flink消费kafka数据,如何从kafka端获取消费偏移信息
命令行查看kafka消费的Offset命令如下:
kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper zkhost:2181 --group ${group.id} --topic ${topic_name}
替换zkhost 、group.id及topic_name即可
然后就会得到
Group Topic Pid Offset logSize Lag Owner
test dy_event 0 8115733 10658588 2542855 none
test dy_event 1 8114221 10658585 2544364 none
test dy_event 2 8115173 10658587 2543414 none
test dy_event 3 8115127 10658585 2543458 none
test dy_event 4 8115160 10658587 2543427 none
这个pid Offset就是每个分区你对应消费组的偏移信息
------------------ 原始邮件 ------------------
发件人: "Benchao Li"<libenchao@gmail.com>;
发送时间: 2020年1月12日(星期天) 晚上9:46
收件人: "user-zh"<user-zh@flink.apache.org>;
主题: Re: Re: flink消费kafka数据,如何从kafka端获取消费偏移信息
Flink也会commit offset到Kafka的[1],当然在开checkpoint和不开checkpoint的时候表现有些不同。
offset
只要是commit到了kafka,查看offset的方式我理解跟用其他方式commit的offset的查阅方式应该没有区别的。如果你看不到flink消费的topic对应的offset,可能需要check下是什么原因没有commit
offset.
[1]
https://ci.apache.org/projects/flink/flink-docs-master/dev/connectors/kafka.html#kafka-consumers-offset-committing-behaviour-configuration
wqpapa <wqpapa@126.com> 于2020年1月12日周日 下午9:34写道:
> 感谢回复!主要想了解下如何从kafka端后台命令方式获取对应消费组的偏移信息。之前通过普通的java代码消费kafka数据,通过kafka-consumer-groups.sh
> --describe可获取到消费偏移信息,但通过flink消费,不知道要怎么在kafka端获取偏移信息?
>
>
>
>
>
>
>
>
>
> 在 2020-01-12 21:17:40,"Benchao Li" <libenchao@gmail.com> 写道:
> >setStartFromGroupOffsets
>
> >说的是从kafka里面保存的offset开始消费,flink并没有保证kafka一定会有这个consumer的offset,如果没有的话,会按照kafka
> >consumer的配置'auto.offset.reset'来设置这些partition的offset。
> >
> >具体情况可以参考文档[1].
> >
> >[1]
> >
> https://ci.apache.org/projects/flink/flink-docs-master/dev/connectors/kafka.html#kafka-consumers-start-position-configuration
> >
> >wqpapa <wqpapa@126.com> 于2020年1月12日周日 下午9:09写道:
> >
> >> flink通过FlinkKafkaConsumer消费kafka主题,设置group.id
> >> 按setStartFromGroupOffsets取偏移,如何在kafka端获取对应group.id的偏移信息?
> >> kafka为0.9版本,在zk那边找不到对应的group.id;通过kafka-consumer-groups.sh --describe
> >> --group ,也取不到。请问下要怎么获取啊?
> >
> >
> >
> >--
> >
> >Benchao Li
> >School of Electronics Engineering and Computer Science, Peking University
> >Tel:+86-15650713730
> >Email: libenchao@gmail.com; libenchao@pku.edu.cn
>
--
Benchao Li
School of Electronics Engineering and Computer Science, Peking University
Tel:+86-15650713730
Email: libenchao@gmail.com; libenchao@pku.edu.cn