确定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
阅读(4291) | 评论(0) | 转发(0) |