Kafka中操做topic時 Error: Failed to parse the broker info from zookeeper
1.問題描述
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的配置
2.在zookeeper中查看對應的zNode
方式二(如下在kafka的server.properties中沒有指定/kafka,那麼默認的路徑是在zookeeper的根路徑下建立/broker/ids/xxx)
1.這是在server.properties的配置
2.在zookeeper中查看對應的zNode
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,執行成功