我有两个kafka代理在本地机器上有两个分区,并使用以下工具将一个本地文件写入kafka test2主题.
# create topic
./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 2 --partitions 2 --topic test2
Created topic "test2".
# write 15MB file to kafka, very fast!!
kafka-console-producer.sh --broker-list localhost:9093,localhost:9094 --topic test2 < data.txt
# read data from kafka
./kafka-console-consumer.sh --zookeeper localhost:2181 --topic test2 --from-beginning
Run Code Online (Sandbox Code Playgroud)
然后我发现所有消息都在一个分区中,如何调试呢?
$ kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9093,localhost:9094 --topic test2 --time -1
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
test2:0:68263
test2:1:0
Run Code Online (Sandbox Code Playgroud)
分区的状态是:
$ kafka-topics.sh --describe --zookeeper localhost:2181 --topic test2
Topic:test2 PartitionCount:2 ReplicationFactor:2 Configs:
Topic: test2 Partition: 0 Leader: 1 Replicas: 1,2 Isr: 1,2
Topic: test2 Partition: 1 Leader: 2 Replicas: 2,1 Isr: 2,1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1348 次 |
| 最近记录: |