现象
get /kafka/brokers/topics/stock_ticks_test1/partitions/0/state
{"controller_epoch":12,"leader":-1,"version":1,"leader_epoch":5,"isr":[5]}
原因
broker shutdown的时候,partition的leader在此broker上,controller选主没有成功,移除此broker后,对应的partition的leader就被赋值成-1了
解决
重启controller
步骤1:找到controller
进入zk命令行,定位controller在哪个节点
[zk: localhost:2181(CONNECTED) 1] get /kafka/controller
{"version":1,"brokerid":4,"timestamp":"1587371673207"}
cZxid = 0x329f55eb3
ctime = Mon Apr 20 16:34:33 CST 2020
mZxid = 0x329f55eb3
mtime = Mon Apr 20 16:34:33 CST 2020
pZxid = 0x329f55eb3
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x100bf66c3b90445
dataLength = 54
numChildren = 0
步骤2:重启controller所在broker 4
bin/kafka-server-stop.sh
bin/kafka-server-start.sh -daemon ./config/server.properties
步骤3:重新查看分区信息
get /kafka/brokers/topics/stock_ticks_test1/partitions/0/state
{"controller_epoch":12,"leader":5,"version":1,"leader_epoch":6,"isr":[5]}
cZxid = 0x309da4876
ctime = Mon Nov 25 17:04:20 CST 2019
mZxid = 0x329f54723
mtime = Mon Apr 20 16:32:18 CST 2020
pZxid = 0x309da4876
cversion = 0
dataVersion = 6
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 73
numChildren = 0
已经恢复正常
————————————————
版权声明:本文为CSDN博主「L13763338360」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/L13763338360/article/details/105638648