Apache kafka Zookeeper会话持续到期…没有心跳?

Apache kafka Zookeeper会话持续到期…没有心跳?,apache-kafka,apache-zookeeper,session-timeout,kafka-consumer-api,Apache Kafka,Apache Zookeeper,Session Timeout,Kafka Consumer Api,我们正在使用Kafka高级消费者,我们能够成功地消费消息,但zookeeper连接不断过期并重新建立 我想知道为什么没有心跳来维持连接: Kafka Consumer Logs ==================== [localhost-startStop-1-SendThread(10.41.105.23:2181)] [ClientCnxn$SendThread] [line : 1096 ] - Client session timed out, have not heard f

我们正在使用Kafka高级消费者,我们能够成功地消费消息,但zookeeper连接不断过期并重新建立

我想知道为什么没有心跳来维持连接:

Kafka Consumer Logs
====================
 [localhost-startStop-1-SendThread(10.41.105.23:2181)] [ClientCnxn$SendThread] [line : 1096 ]  -  Client session timed out, have not heard from server in 2666ms for sessionid 0x153175bd3860159, closing socket connection and attempting reconnect
2016-03-08 18:00:06,750 INFO  [localhost-startStop-1-SendThread(10.41.105.23:2181)] [ClientCnxn$SendThread] [line : 975 ]  -  Opening socket connection to server 10.41.105.23/10.41.105.23:2181. Will not attempt to authenticate using SASL (unknown error)
2016-03-08 18:00:06,823 INFO  [localhost-startStop-1-SendThread(10.41.105.23:2181)] [ClientCnxn$SendThread] [line : 852 ]  -  Socket connection established to 10.41.105.23/10.41.105.23:2181, initiating session
2016-03-08 18:00:06,892 INFO  [localhost-startStop-1-SendThread(10.41.105.23:2181)] [ClientCnxn$SendThread] [line : 1235 ]  -  Session establishment complete on server 10.41.105.23/10.41.105.23:2181, sessionid = 0x153175bd3860159, negotiated timeout = 4000


Zookeeper Logs
==================
[2016-03-08 17:44:37,722] INFO Accepted socket connection from /10.10.113.92:51333 (org.apache.zookeeper.server.NIOServerCnxnFactory)
[2016-03-08 17:44:37,742] INFO Client attempting to renew session 0x153175bd3860159 at /10.10.113.92:51333 (org.apache.zookeeper.server.ZooKeeperServer)
[2016-03-08 17:44:37,742] INFO Established session 0x153175bd3860159 with negotiated timeout 4000 for client /10.10.113.92:51333 (org.apache.zookeeper.server.ZooKeeperServer)
[2016-03-08 17:46:56,000] INFO Expiring session 0x153175bd3860151, timeout of 4000ms exceeded (org.apache.zookeeper.server.ZooKeeperServer)
[2016-03-08 17:46:56,001] INFO Processed session termination for sessionid: 0x153175bd3860151 (org.apache.zookeeper.server.PrepRequestProcessor)
[2016-03-08 17:46:56,011] INFO Closed socket connection for client /10.10.114.183:38324 which had sessionid 0x153175bd3860151 (org.apache.zookeeper.server.NIOServerCnxn)

ZooKeeper会话超时通常是由“软故障”引起的,这通常是垃圾收集暂停。打开GC日志记录,查看连接超时时是否发生长GC。另外,请阅读关于

[2016-03-08 17:46:56000]即将到期的会话信息0x153175bd3860151, 超时超过4000ms(org.apache.zookeeper.server.ZooKeeperServer)

什么是Zookeeper的
maxSessionTimeout
? 如果它只有4000毫秒(4秒),那么它就太小了

在Hadoop的Cloudera发行版中,ZK的
maxSessionTimeout
默认为40秒 (40000ms)

如ZK配置中所述- 默认为20个勾号
(一个
勾选默认值为2秒)。

我昨天刚开始在Mac(单节点Kafka/zookeeper开发集群)上遇到类似问题。你是在Mac上运行吗?对我来说是Linux…nd单节点群集在IntelliJ IDE中以调试模式运行使我的问题更加严重。从命令行运行Scala应用程序要稳定得多,解决了将zookeeper.connection.timeout.ms
增加到
20000