查看kafka最近消息的队列情况
1、使用 kafka-run-class 指令,获取topic的最小offset和最大offset#查看各个分区的最小offset(这个意思就是,这个offset之前的消息已经被清除了,现在consumer是从这个offset之后开始消费):./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --
·
1、使用 kafka-run-class 指令,获取topic的最小offset和最大offset
#查看各个分区的最小offset(这个意思就是,这个offset之前的消息已经被清除了,现在consumer是从这个offset之后开始消费):
./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic topic的名字 --time -2
#查看各个分区的最大offset(这个意思就是,producer下一次写入信息时的offset):
./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic topic的名字 --time -1
2、获取最近N条数据,offset = MaxOffset - N;
比如想要获取最近10条数据,根据上一步的命令得到:MaxOffset为52884,那么offset则为:52884 - 10 = 52874
./kafka-console-consumer.sh --bootstrap-server 192.168.35.14:9092 --topic topic的名字 \
--property print.key=true --partition 0 --offset 52874
更多推荐
已为社区贡献5条内容
所有评论(0)