问题解决了,分区没有副本了,正好在被关的broker上,扩展分区副本数。
配置了这几个参数
offsets.topic.replication.factor=3
transaction.state.log.replication.factor=3
transaction.state.log.min.isr=3
重新调整consumer_offsets
的Replicas
才会生效,默认是是一对一的
Topic: consumer_offsets Partition: 0 Leader: 0 Replicas: 0 Isr: 0
调整后应该是
Topic: __consumer_offsets Partition: 0 Leader: 0 Replicas: 0,1,2 Isr: 0,1,2
调整的命令是:
kafka-reassign-partitions --zookeeper 127.0.0.1:2181 --reassignment-json-file reassign.json --execute
如果是开发环境,可以删掉zookeeper\kafka
日志重建。
补充下,3个broker节点为0、1、2,关掉2节点,Consumer接收不到消息。
Topic:t1 PartitionCount:6 ReplicationFactor:2 Configs:
Topic: t1 Partition: 0 Leader: 1 Replicas: 1,2 Isr: 1,2
Topic: t1 Partition: 1 Leader: 2 Replicas: 2,0 Isr: 0,2
Topic: t1 Partition: 2 Leader: 0 Replicas: 0,1 Isr: 0,1
Topic: t1 Partition: 3 Leader: 1 Replicas: 1,2 Isr: 1,2
Topic: t1 Partition: 4 Leader: 2 Replicas: 2,0 Isr: 0,2
Topic: t1 Partition: 5 Leader: 0 Replicas: 0,1 Isr: 0,1
replication配置:
offsets.topic.replication.factor=2
transaction.state.log.replication.factor=2
transaction.state.log.min.isr=2