ローカルマシンに2つのパーティションを持つ2つのカフカブローカーがあり、次のツールを使用してkafka test2トピックに1つのローカルファイルを書き込みます。なぜ私のカフカは1つのパーティションにメッセージを持っていますか?
# 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
次に、すべてのメッセージが1つのパーティションにあることがわかります。これをどのようにデバッグするのですか?
$ 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
パーティションの状況は次のとおりです。私が正しくあなたを理解していれば、データが他のパーティションに複製されませんなぜあなたは
$ 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
メッセージ用に異なるメッセージキーを使用してKafka Producerクラスを作成して、異なるパーティションにメッセージを公開することができます。 – Shankar
メッセージのキーを指定していますか? – amethystic
kafka-console-producer.shがキーを生成しないのですか? –