kafka重平衡不生效?

洛漓 发表于: 2023-03-30   最后更新时间: 2023-03-30 17:07:19   813 游览

第一步:本地启动两个节点,分别配置监听为broker0=ip:9092和broker=ip:9094,并且启动重平衡频率为5s,10%;创建一个topic有5个分区2个备份

kafka_2.13-3.4.0$ bin/kafka-topics.sh --describe --topic test2 --bootstrap-server ip:9092
Topic: test2    TopicId: y2dwPl1ZTeqoFYCJiDS_2A PartitionCount: 5       ReplicationFactor: 2    Configs: retention.ms=20,retention.bytes=20
        Topic: test2    Partition: 0    Leader: 1       Replicas: 1,0   Isr: 1,0
        Topic: test2    Partition: 1    Leader: 0       Replicas: 0,1   Isr: 1,0
        Topic: test2    Partition: 2    Leader: 1       Replicas: 1,0   Isr: 1,0
        Topic: test2    Partition: 3    Leader: 0       Replicas: 0,1   Isr: 1,0
        Topic: test2    Partition: 4    Leader: 1       Replicas: 1,0   Isr: 1,0

第二步:将broker1节点下线,此时启用broker0的备份,查询topic详情发现所有分区的leader都是broker0,原本leader是broker1的分区的备份的优先副本还是1

kafka_2.13-3.4.0$ bin/kafka-topics.sh --describe --topic test2 --bootstrap-server ip:9092
Topic: test2    TopicId: y2dwPl1ZTeqoFYCJiDS_2A PartitionCount: 5       ReplicationFactor: 2    Configs: 
        Topic: test2    Partition: 0    Leader: 0       Replicas: 1,0   Isr: 0
        Topic: test2    Partition: 1    Leader: 0       Replicas: 0,1   Isr: 0
        Topic: test2    Partition: 2    Leader: 0       Replicas: 1,0   Isr: 0
        Topic: test2    Partition: 3    Leader: 0       Replicas: 0,1   Isr: 0
        Topic: test2    Partition: 4    Leader: 0       Replicas: 1,0   Isr: 0

第三步:再启动broker1,不知道为什么始终没有重平衡分区,查询的topic详情和第二步的一样,反过来下线broker0再上线的话就触发重平衡,查询到的分区详情就和第一步一样,

为什么broker1下线再上线没有触发重平衡,而broker0下线再上线就触发了重平衡?

发表于 2023-03-30
  • bin/kafka-topics.sh --describe --topic __consumer_offsets --bootstrap-server ip:9092半兽人 1年前 回复
  • 执行以下以上的命令,获取 __consumer_offsets 看看有几个副本。半兽人 1年前 回复
    @半兽人 __consumer_offsets这个不是针对消费者的吗,我启动了服务生产数据之后没有消费过数据,查不到这个系统生成的主题的洛漓 回复
添加评论
你的答案

查看kafka相关的其他问题或提一个您自己的问题