问题:

发现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. Unity碰撞和触发的区别

    碰撞的必要条件: 2个都有Collider,且至少有一个刚体.带刚体的身上会检测OnCollision事件,stay就是2个一直在碰着. 触发的必要条件: 至少有一个碰撞器勾选了IsTrigger,至 ...

  2. Django路由中的include

    include(module,namespace = None,app_name = None)[source] include(pattern_list) include((pattern_list ...

  3. 分清encodeURIComponent encodeURI 和 escape

    encodeURIComponent encodeURI escape 目的:这三个函数的作用都是让一段字符串在所有电脑(所有国家区域语言)上可读. escape对字符串进行处理: encodeURI ...

  4. C语言基本语法——函数

    1.什么是函数 2.函数语法 3.函数声明 4.函数调用 5.函数的形参与实参 6.return与exit关键字 7.递归函数 1.什么是函数 • 函数就是一连串语句被组合在一起,并指定了一个名字 • ...

  5. 如何让select中的滚动条自动定位到框中选中项的位置

    document.getElementById("hidScrollTop").value = document.getElementById("slcYZYongFa& ...

  6. HDU 1042 N!( 高精度乘法水 )

    链接:传送门 思路:高精度乘法板子题,高精度耗时又耗空间...... /**************************************************************** ...

  7. oracle11.2静默安装

    操作系统及Oracle版本 Linux版本:rhel-server-5.8-x86_64-dvd Oracle版本:Oracle Database 11g Release 2 (11.2.0.4.0) ...

  8. vi 编辑器的日常使用

    命令行模式: 光标管理 text  屏幕 行 单词 gg 跳转到文档头部 H 跳转到屏幕首行 ^  或 数字0 跳转到行首 w 向前 G 跳转到文档尾部 M 跳转到屏幕中行 $ 跳转到行尾 b 向后 ...

  9. s5pv210 uboot-2012-10移植(二) 之能够启动进入控制台

    这次我们将从官网下载的最新uboot-2012-10移植到s5pv210开发板上,让其进入控制台,效果如下: 首先,我暂时没采用内核的SPL,这个将在后面给补上,这里的BL1是我自己参考资料写的,我用 ...

  10. webpack操作基础

    webpack 是一个前端加载/打包工具,根据模块的依赖关系进行静态分析,并依根据规则生成对应的静态资源