Kafka錯誤“Network is unreachable”和“larger than available brokers”
阿新 • • 發佈:2019-02-02
確定Kafka安裝和啟動正確,ZooKeeper可以查到所有的Brokers,但執行:
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic my-replicated-topic
遇到如下錯誤:
java.net.SocketException: Network is unreachable
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
Error while executing topic command : replication factor: 3 larger than available brokers: 0
[2017-06-26 17:25:18,037] ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: replication factor: 3 larger than available brokers: 0
這個問題可能是broker的配置檔案server.properties中的配置項zookeeper.connect指定了kafka的zookeeper的根目錄,如:
zookeeper.connect=192.168.31.32:2181,192.168.31.33:2181/kafka
這個時候,命令列引數“--zookeeper”的值也需要帶上根目錄,否則就會報這個錯誤,正確做法是:
kafka-topics.sh --create --zookeeper localhost:2181/kafka --replication-factor 3 --partitions 1 --topic my-replicated-topic
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic my-replicated-topic
遇到如下錯誤:
java.net.SocketException: Network is unreachable
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
Error while executing topic command : replication factor: 3 larger than available brokers: 0
[2017-06-26 17:25:18,037] ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: replication factor: 3 larger than available brokers: 0
這個問題可能是broker的配置檔案server.properties中的配置項zookeeper.connect指定了kafka的zookeeper的根目錄,如:
zookeeper.connect=192.168.31.32:2181,192.168.31.33:2181/kafka
這個時候,命令列引數“--zookeeper”的值也需要帶上根目錄,否則就會報這個錯誤,正確做法是:
kafka-topics.sh --create --zookeeper localhost:2181/kafka --replication-factor 3 --partitions 1 --topic my-replicated-topic