因此我们目前正在尝试使用Kafka 0.9,并且几乎处于概念验证阶段。我们刚开始研究它并试图找出它,如果它是我们需要的。还有一些学习要做,所以请在这里忍受我:)
目前的设置如下:
现在我尝试使用kafka-reassign-partitions.sh脚本更改复制因子。为此,我创建了以下JSON文件:
{"version":1,
"partitions":[
{"topic":"myTopic","partition":0,"replicas":[0,1,2]},
{"topic":"myTopic","partition":1,"replicas":[0,1,2]},
{"topic":"myTopic","partition":2,"replicas":[0,1,2]},
{"topic":"myTopic","partition":3,"replicas":[0,1,2]}
]
}
...然后执行脚本:
kafka/bin/kafka-reassign-partitions.sh --zookeeper zkhost1:2181,zkhost2:2181,zkhost3:2181 --reassignment-json-file increase-replication-factor.json --execute
这顺利进行,之后我得到了预期的复制:
Topic:myTopic PartitionCount:4 ReplicationFactor:3 Configs:
Topic: myTopic Partition: 0 Leader: 0 Replicas: 0,1,2 Isr: 0,2,1
Topic: myTopic Partition: 1 Leader: 0 Replicas: 0,1,2 Isr: 0,2,1
Topic: myTopic Partition: 2 Leader: 0 Replicas: 0,1,2 Isr: 0,2,1
Topic: myTopic Partition: 3 Leader: 0 Replicas: 0,1,2 Isr: 0,2,1
我不明白的是,在重新分配期间分区发生了什么。当我查看ConsumerOffsetChecker时,这是我在重新分配之前之前看到的:
kafka/bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --group myGroup --zookeeper zkhost1:2181 --topic myTopic
Group Topic Pid Offset logSize Lag Owner
myGroup myTopic 0 925230 925230 0 none
myGroup myTopic 1 925230 925230 0 none
myGroup myTopic 2 925230 925230 0 none
myGroup myTopic 3 925230 925230 0 none
...这就是我在重新分配>后看到的:
Group Topic Pid Offset logSize Lag Owner
myGroup myTopic 0 23251 23252 1 none
myGroup myTopic 1 41281 41281 0 none
myGroup myTopic 2 23260 23260 0 none
myGroup myTopic 3 41270 41270 0 none
对我来说,这提出了几个问题:
感谢您的回答和最诚挚的问候,
/ tehK