在Windows下kafka启动方式为 进入kafka目录输入  .\bin\windows\kafka-server-start.bat .\config\server.properties  

启动报错如下:

[2018-12-14 11:21:27,899] INFO [ZooKeeperClient] Waiting until connected. (kafka.zookeeper.ZooKeeperClient)
[2018-12-14 11:21:27,899] INFO Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2018-12-14 11:21:27,904] INFO Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session (org.apache.zookeeper.ClientCnxn)
[2018-12-14 11:21:33,903] INFO [ZooKeeperClient] Closing. (kafka.zookeeper.ZooKeeperClient)
[2018-12-14 11:21:33,905] WARN Client session timed out, have not heard from server in 6002ms for sessionid 0x0 (org.apache.zookeeper.ClientCnxn)
[2018-12-14 11:21:34,008] INFO Session: 0x0 closed (org.apache.zookeeper.ZooKeeper)
[2018-12-14 11:21:34,014] INFO EventThread shut down for session: 0x0 (org.apache.zookeeper.ClientCnxn)
[2018-12-14 11:21:34,015] INFO [ZooKeeperClient] Closed. (kafka.zookeeper.ZooKeeperClient)
[2018-12-14 11:21:34,019] ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING
	at kafka.zookeeper.ZooKeeperClient$$anonfun$kafka$zookeeper$ZooKeeperClient$$waitUntilConnected$1.apply$mcV$sp(ZooKeeperClient.scala:268)
	at kafka.zookeeper.ZooKeeperClient$$anonfun$kafka$zookeeper$ZooKeeperClient$$waitUntilConnected$1.apply(ZooKeeperClient.scala:264)
	at kafka.zookeeper.ZooKeeperClient$$anonfun$kafka$zookeeper$ZooKeeperClient$$waitUntilConnected$1.apply(ZooKeeperClient.scala:264)
	at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:251)
	at kafka.zookeeper.ZooKeeperClient.kafka$zookeeper$ZooKeeperClient$$waitUntilConnected(ZooKeeperClient.scala:264)
	at kafka.zookeeper.ZooKeeperClient.<init>(ZooKeeperClient.scala:97)
	at kafka.zk.KafkaZkClient$.apply(KafkaZkClient.scala:1693)
	at kafka.server.KafkaServer.kafka$server$KafkaServer$$createZkClient$1(KafkaServer.scala:348)
	at kafka.server.KafkaServer.initZkClient(KafkaServer.scala:372)
	at kafka.server.KafkaServer.startup(KafkaServer.scala:202)
	at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
	at kafka.Kafka$.main(Kafka.scala:75)
	at kafka.Kafka.main(Kafka.scala)
[2018-12-14 11:21:34,022] INFO shutting down (kafka.server.KafkaServer)
[2018-12-14 11:21:34,055] INFO shut down completed (kafka.server.KafkaServer)
[2018-12-14 11:21:34,056] ERROR Exiting Kafka. (kafka.server.KafkaServerStartable)
[2018-12-14 11:21:34,058] INFO shutting down (kafka.server.KafkaServer)

这里Will not attempt to authenticate using SASL (unknown error) 应该是没有找到zk的 Server environment:host.name 

这个名称是在zk启动时,会打印出来的 [main:Environment@100] - Server environment:host.name=xiaofengz_1.tujia.com

只需要在kafka的机器下的host文件加入 zk的ip 映射的Server environment:host.name 即可解决。

Logo

Kafka开源项目指南提供详尽教程,助开发者掌握其架构、配置和使用,实现高效数据流管理和实时处理。它高性能、可扩展,适合日志收集和实时数据处理,通过持久化保障数据安全,是企业大数据生态系统的核心。

更多推荐