Zookeeper Too many connections情况

我的zookeeper机器,跑了一段时间后有的服务就连接失败,正常连接ok,但是socket 被 close掉了,zookeeper的日记如下:
2016-11-03 10:45:18,190 [myid:4] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@193] - Too many connections from /10.10.0.48 - max is 60
2016-11-03 10:45:18,213 [myid:4] - WARN [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@193] - Too many connections from /10.10.0.46 - max is 60
2016-11-03 10:45:18,236 [myid:4] - WARN [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@193] - Too many connections from /10.10.0.46 - max is 60
2016-11-03 10:45:18,349 [myid:4] - WARN [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@193] - Too many connections from /10.10.0.48 - max is 60
2016-11-03 10:45:18,351 [myid:4] - WARN [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@193] - Too many connections from /10.10.0.46 - max is 60
2016-11-03 10:45:18,393 [myid:4] - WARN [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@193] - Too many connections from /10.10.0.46 - max is 60
2016-11-03 10:45:18,431 [myid:4] - WARN [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@193] - Too many connections from /10.10.0.48 - max is 60
2016-11-03 10:45:18,434 [myid:4] - WARN [NIOServerCxn.Factory:
这个是不是因为系统内核参数的原因还是什么?
已邀请:

采菊篱下 - 无分享不快乐 助力技术开源分享 运维一枚

赞同来自:

你这是ZooKeeper客户端连接数过多的问题,zookeeper中有相应的参数maxClientCnxns 可以来限制某ip的连接数。
 
maxClientCnxns介绍:
这个配置参数将限制连接到ZooKeeper的客户端的数量,限制并发连接的数量,它通过IP来区分不同的客户端。此配置选项可以用来阻止某些类别的Dos攻击。该参数默认是60,将它设置为0将会取消对并发连接的限制。
 
例如,将maxClientCnxns的值设置为1,如下所示:
#set maxClientCnxns
maxClientCnxns=1
启动ZooKeeper之后,首先用一个客户端连接到ZooKeeper服务器之上。然后,当第二个客户端尝试对ZooKeeper进行连接,或者某些隐式的对客户端的连接操作,将会触发ZooKeeper的上述配置。系统会提示相关信息,如下图所示:
zk.png

ZooKeeper关于maxClientCnxns参数的官方解释:
单 个客户端与单台服务器之间的连接数的限制,是ip级别的,默认是60,如果设置为0,那么表明不作任何限制。请注意这个限制的使用范围,仅仅是单台客户端 机器与单台ZK服务器之间的连接数限制,不是针对指定客户端IP,也不是ZK集群的连接数限制,也不是单台ZK对所有客户端的连接数限制。

maxClientCnxns
Limits the number of concurrent connections (at the socket level) that a single client, identified by IP address, may make to a single member of the ZooKeeper ensemble. This is used to prevent certain classes of DoS attacks, including file descriptor exhaustion. The default is 60. Setting this to 0 entirely removes the limit on concurrent connections.
 
所以最后:你这里想解决把maxClientCnxns=1000设置为1000就好。

要回复问题请先登录注册