kafka获取topic每个分区的数据条数执⾏命令
[hduser@hadoop4 bin]$ kafka-run-class.ls.GetOffsetShell --broker-list 192.168.43.15:9092 --topic test  --time -1 test:0:992786
test:1:1001516
test:2:1000773
kafka命令test:3:1000894
test:4:1004034
[hduser@hadoop4 bin]$ kafka-run-class.ls.GetOffsetShell --broker-list 192.168.43.15:9092 --topic test  --time -2 test:0:0
test:1:0
test:2:0
test:3:0
test:4:0
[hduser@hadoop4 bin]$ kafka-run-class.ls.GetOffsetShell
An interactive shell for getting topic offsets.
Option                                Description
------                                -----------
--broker-list <String: hostname:      REQUIRED: The list of hostname and
port,...,hostname:port>                port of the server to connect to.
--max-wait-ms <Integer: ms>            DEPRECATED AND IGNORED: The max amount
of time each fetch request waits.
(default: 1000)
--offsets <Integer: count>            DEPRECATED AND IGNORED: number of
offsets returned (default: 1)
--partitions <String: partition ids>  comma separated list of partition ids.
If not specified, it will find
offsets for all partitions (default:
)
--time <Long: timestamp/-1(latest)/-2  timestamp of the offsets before that.
(earliest)>                            [Note: No offset is returned, if the
timestamp greater than recently
commited record timestamp is given.]
(default: -1)
--topic <String: topic>                REQUIRED: The topic to get offset from.
2、获取条数
从上述的命令解析可以看到,
--time -1 表⽰获取的最新位移值
--time -2 表⽰获取的最早的位移值,可能由于最早的数据由于过期被删除,所以最早的位移不⼀定是0
通过两数相减,就可以知道当前分区的数据条数。