Kafka中操作topic时 Error: Failed to parse the broker info from zookeeper

1.问题描述

Kafka中操作topic时 Error:Failed to parse the broker info from zookeeper-LMLPHP
 

2.问题原因

    kafka在启动后,会将broker的信息存放在对应的zookeeper里的zNode中,默认存放在zookeeper中的路径 /broker/ids/xxx(当然如果在kafka的server.properties文件中指定zookeeper中的路径/kafka,那么对应的zNode也会在/kafka下创建
    当出现不能从zookeeper中解析broker的信息时,那么就是说明zookeeper中没有对应的zNode(/broker/ids/xxx)或者有这个zNode(即ids下的broker id)但是broker id中没有该broker的信息

For example:

方式一(以下在kafka的server.properties中指定了/kafka,那么会在zookeeper的/kafka路径下创建/broker/ids/xxx)

1.这是在server.properties的配置
Kafka中操作topic时 Error:Failed to parse the broker info from zookeeper-LMLPHP

2.在zookeeper中查看对应的zNode
Kafka中操作topic时 Error:Failed to parse the broker info from zookeeper-LMLPHP
 

方式二(以下在kafka的server.properties中没有指定/kafka,那么默认的路径是在zookeeper的根路径下创建/broker/ids/xxx)

1.这是在server.properties的配置
Kafka中操作topic时 Error:Failed to parse the broker info from zookeeper-LMLPHP

2.在zookeeper中查看对应的zNode
Kafka中操作topic时 Error:Failed to parse the broker info from zookeeper-LMLPHP

 

3.解决方案

方案一:

    重新启动kafka集群

方案二:

    首先知道kafka集群依赖的zookeeper的集群以及zookeeper的安装目录;
    其次知道kafka集群的broker有那几台(就是每一个broker的broker id是多少),同时查看kafka配置文件server.properties中连接zookeeper时有没有指定路径(比如/kafka)
    然后进入到$ZOOKEEPER_HOME/bin下启动zkCli.sh,如果么有对应的zNode,那么创建(注意是在根路径下还是在/kafka下),然后在每一个zNode(/broker/ids/broker的id)下放入该broker的信息
在zookeeper上创建broker信息(date -d @1504856535 +"%Y-%m-%d %H:%M:%S")
set /brokers/ids/182 {"jmx_port":-1,"timestamp":"1504856535","endpoints":["PLAINTEXT://123.59.18.182:9092"],"host":"123.59.18.182","version":1,"port":9092} set /brokers/ids/183 {"jmx_port":-1,"timestamp":"1504856535","endpoints":["PLAINTEXT://123.59.18.183:9092"],"host":"123.59.18.183","version":1,"port":9092} set /brokers/ids/154 {"jmx_port":-1,"timestamp":"1504856535","endpoints":["PLAINTEXT://123.59.18.154:9092"],"host":"123.59.18.154","version":1,"port":9092} set /brokers/ids/33 {"jmx_port":-1,"timestamp":"1504856535","endpoints":["PLAINTEXT://123.59.17.33:9092"],"host":"123.59.17.33","version":1,"port":9092} set /brokers/ids/116 {"jmx_port":-1,"timestamp":"1504856535","endpoints":["PLAINTEXT://123.59.17.116:9092"],"host":"123.59.17.116","version":1,"port":9092}
 
    最后创建topic,执行成功
Kafka中操作topic时 Error:Failed to parse the broker info from zookeeper-LMLPHP

 
 
 
 
 
05-06 17:27