问题:

发现mongodb无法连接,查看mongodb日志,出现大量的如下报错:

[initandlisten] connection refused because too many open connections: 

mongodb的连接数到达819后,就无法增加,所以无法连接上去。

分析解决:

1、maxConns 限制

默认情况下,在Linux系统中,mongodb的最大连接数为819。

可以修改mongodb的最大连接数,修改其配置文件mongod.conf:

maxConns=  #官方指定,mongodb最大连接数设置,不能超过20000

重启mongodb服务,让配置生效。

2、ulimit 限制

如果调大了maxConns,还是出现 too many open connections 的报错,也可能跟系统的ulimit限制有关。

Linux系统默认每个进程的文件句柄限制open files 为1024,这数值一般过小,需要调大。

查看系统当前所有的limit信息
# ulimit -a
core file size (blocks, -c)
data seg size (kbytes, -d) unlimited
scheduling priority (-e)
file size (blocks, -f) unlimited
pending signals (-i)
max locked memory (kbytes, -l)
max memory size (kbytes, -m) unlimited
open files (-n)
pipe size ( bytes, -p)
POSIX message queues (bytes, -q)
real-time priority (-r)
stack size (kbytes, -s)
cpu time (seconds, -t) unlimited
max user processes (-u)
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

使用 ulimit -n 修改 open files 限制:(当前session生效)

# ulimit -n 

更改系统限制,修改 /etc/security/limits.conf ,添加如下行: (永久生效)

* soft nofile
* hard nofile

mongodb报错:connection refused because too many open connections: 819的更多相关文章

  1. eclipse运行hadoop程序报错:Connection refused: no further information

    eclipse运行hadoop程序报错:Connection refused: no further information log4j:WARN No appenders could be foun ...

  2. Weblogic 连接 RMI 服务报错 Connection refused

    WebLogic 连接 RMI 服务报错 Connection refused 访问 WebLogic RMI 服务报错,连接被拒绝,连接超时. 奇怪的是,报错的 host 根本不是我要访问的. 报错 ...

  3. mongodb connection refused because too many open connections: 819

    Env Debian 9 # 使用通用二进制方式安装 # mongod --version db version v3.4.21-2.19 git version: 2e0631f5e0d868dd5 ...

  4. Java远程连接redis, 报错 Connection refused: connect

    在今天的学习Redis中报错 Connection refused: connect 我总结了有三种情况: 1.远程服务器中的Redis没有开启. 2.远程连接地址出错,或者是端口出错. 3.远程服务 ...

  5. Android程序报错 Connection refused 处理

    在用Android测试JSON数据解析的时候,报了这样一个异常: java.net.ConnectException: localhost/ - Connection refused 原来模拟器默认把 ...

  6. Android网络请求的时候报错 Connection refused 处理

    在用Android测试JSON数据解析的时候,报了这样一个异常: java.net.ConnectException: localhost/ - Connection refused 原来模拟器默认把 ...

  7. JDBC连接SQL Server 2005 报错Connection refused: connect

    com.microsoft.sqlserver.jdbc.SQLServerException: 通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败.错误:“Connect ...

  8. 报错Connection refused: connect

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/qq_34266804/article/d ...

  9. MongoDB numa系列问题一:[initandlisten] connection refused because too many open connections:

    1:Mongod日志有很多这样的报错: [initandlisten] connection refused because too many open connections: 2:查看系统的限制 ...

随机推荐

  1. Five Invaluable Techniques to Improve Regex Performance

    Regular expressions are powerful, but with great power comes great responsibility. Because of the wa ...

  2. IIS的安装与配置详细图解教程

    IIS是Internet Information Services(互联网信息服务)的简称,是有微软公司提供的基于在windows操作系统环境下运行的互联网服务.此处将介绍如何安装配置IIS来构架自己 ...

  3. Fragment的理解

    1.生命周期    启动Fragment时: onAttachonCreateonCreateViewonViewCreatedonActivityCreatedonStartonResume 启动后 ...

  4. 双向链表C++实现

    双向链表实现,通过C++实现 #ifndef LinkList_hpp #define LinkList_hpp typedef struct Node{ int data; Node* next; ...

  5. iOS原生数据存储策略

    一 @interface NSCache : NSObject Description A mutable collection you use to temporarily store transi ...

  6. Guitar Pro中文版下载,你想要的,都在这啦!

    我的音乐我做主!Guitar Pro7中文版的发布为更多音乐爱好者带来更多更优质的体验!为帮助所有吉他爱好者学习.绘谱.创作而设计的音乐空间!为前所未有的音乐盛听而震撼,音乐才子,等的就是你! Gui ...

  7. Guitar Pro 的双十一特惠活动,正在如火如荼进行中...

    11月11日这个令人兴奋的日子又来了.没错,“双十一”所有网购达人狂欢的日子.同时期待已久的Guitar Pro 也将在“双十一”当天,把福利分享与你我.11月11日Guitar Pro 将在麦软商城 ...

  8. 扩展Jmeter--BeanShell进行java扩展

    1.在eclipse中写第一个java 程序,导出成jar文件,在Jmeter安装文件下新建一个dependences文件夹,将导出的.jar包文件放在文件夹下. 2.修改Jmter安装文件bin目录 ...

  9. 亲历:IT 从业者避免猝死攻略 v1.0

    作者:香蕉痞 出处:http://www.geekpark.net/read/view/191188?u=0 亲历:IT 从业者避免猝死攻略 v1.0 By 香蕉痞 | 2013/10/28 [核心提 ...

  10. PHP的迭代器和生成器

    一.迭代器 分析:想一下,如果把集合对象和对集合对象的操作放在一起,当我们想换一种方式遍历集合对象中元素时,就需要修改集合对象了,违背"单一职责原则",而迭代器模式将数据结构和数据 ...