异常情况:

[henry@hadoop102 kafka]$ bin/kafka-topics.sh --zookeeper hadoop102:2181 --create --topic whale --partitions 3 --replication-factor 2
Exception in thread "main" org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server 'hadoop102:2181' with timeout of 30000 ms
	at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:1233)
	at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:157)
	at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:131)
	at kafka.utils.ZkUtils$.createZkClientAndConnection(ZkUtils.scala:103)
	at kafka.utils.ZkUtils$.apply(ZkUtils.scala:85)
	at kafka.admin.TopicCommand$.main(TopicCommand.scala:55)
	at kafka.admin.TopicCommand.main(TopicCommand.scala)

jpsall命令查看集群中三个服务器情况后发现,zookeeper集群中3台仅启动1台,不满足选举机制中过半数的条件,因此zookeeper为正常启动

解决方法:

启动zookeeper2台服务器,激活leader选举过程,正常启动集群

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐