查看kafka topic的消息offset范围

查看各个patition消息的最大位移

sh kafka-run-class.sh kafka.tools.GetOffsetShell --topic mytopic --time -1 --broker-list host1:9092,host2:9092,host3:9092

查看各个partition消息的最小位移

sh kafka-run-class.sh kafka.tools.GetOffsetShell --topic mytopic --time -2 --broker-list host1:9092,host2:9092,host3:9092

计算可消费的消息个数

a=`sh kafka-run-class.sh kafka.tools.GetOffsetShell --topic mytopic --time -1 --broker-list host1:9092,host2:9092,host3:9092|awk -F':' '{print $3}'| awk ' { SUM += $1 } END { print SUM }'`
b=`sh kafka-run-class.sh kafka.tools.GetOffsetShell --topic mytopic --time -2 --broker-list host1:9092,host2:9092,host3:9092|awk -F':' '{print $3}'| awk ' { SUM += $1 } END { print SUM }'`
echo $(($a-$b))
posted @ 2020-03-02 15:07  远去的列车  阅读(5225)  评论(0编辑  收藏  举报