mongodb connection refused because too many open connections: 819

Env

Debian 9

# 使用通用二进制方式安装
# mongod --version
db version v3.4.21-2.19
git version: 2e0631f5e0d868dd51b71e1e55eb8a57300d00df
OpenSSL version: OpenSSL 1.0.2q  20 Nov 2018
allocator: tcmalloc
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64

报错

程序连接数据库报错,mongodb日志中显示connection refused because too many open connections: 819

初步判定是mongodb的连接数满了。

排错过程

  1. 查看mongo连接数
xxx:PRIMARY> db.serverStatus().connections
{ "current" : 819, "available" : 0, "totalCreated" : 1132 }

--> 连接数果然满了

2. 尝试修改连接数,mongo启动时增加 --maxConns 20000 参数,重启mongo,一会连接数又满了,一些资料上说最大是 20000,默认是1024 * 0.8 个

3. 查看 ulimit -n,这个值是 1048576,符合预期。

4. 修改 supervisord 的配置 minfds=1024 为 100000,重启后查看连接数,符合预期。

xx:PRIMARY> db.serverStatus().connections
{ "current" : 1220, "available" : 78780, "totalCreated" : 2158 }

总结

mongod的连接数受限于

  • ulimit -n 系统级
  • supervisord minfds 参数
  • mongo maxConns 参数

最终,只设置minfds参数,不设置maxConns 参数,这样连接数由 supervisor 控制。

参考

  1. supervisor
  2. maxconn
  3. 深入了解MongoDB连接池

原文地址:https://www.cnblogs.com/hiyang/p/12631508.html

时间: 2024-10-04 18:52:23

mongodb connection refused because too many open connections: 819的相关文章

mongodb报错:connection refused because too many open connections: 819

问题: 发现mongodb无法连接,查看mongodb日志,出现大量的如下报错: [initandlisten] connection refused because too many open connections: 819 mongodb的连接数到达819后,就无法增加,所以无法连接上去. 分析解决: 1.maxConns 限制 默认情况下,在Linux系统中,mongodb的最大连接数为819. 可以修改mongodb的最大连接数,修改其配置文件mongod.conf: maxConns

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

1:Mongod日志有很多这样的报错: [initandlisten] connection refused because too many open connections: 2:查看系统的限制 core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 25

“psql: could not connect to server: Connection refused” Error when connecting to remote database

问题: I am trying to connect to a postgres database installed in a remote server using the following command: psql -h host_ip -U db_username -d db_name This the error that occurs: psql: could not connect to server: Connection refused Is the server runn

pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused

/home/mac126/.pyenv/versions/3.6.6/bin/python /home/mac126/Desktop/11/day1/mongo_cache.py Traceback (most recent call last): File "/home/mac126/Desktop/11/day1/mongo_cache.py", line 47, in <module> mongo_cache = MongoCache() File "/ho

android 127.0.0.1/localhost connection refused,在模拟器上应该用10.0.2.2访问你的电脑本机

调试中通过android simulator模拟器链接localhost或者127.0.0.1,因为我在电脑上面建立了apache,我的代码大概就是URL url = new URL(urlString);     URLConnection urlconn = url.openConnection(); 但是报错了!! Exception 1:java.net.ConnectException: localhost/127.0.0.1:8080 - Connection refused 问题是

com.microsoft.sqlserver.jdbc.SQLServerException: 到主机 的 TCP/IP 连接失败。 java.net.ConnectException: Connection refused: connect

问题描述:最简单的数据库连接报错,到主机  的 TCP/IP 连接失败.(win 7 操作系统) 错误信息: com.microsoft.sqlserver.jdbc.SQLServerException: 到主机  的 TCP/IP 连接失败. java.net.ConnectException: Connection refused: connect package sqlconnect; import java.sql.*; public class sqlconnect { public

[转]android访问网络:java.net.ConnectException: localhost/127.0.0.1:8888 - Connection refused

这对刚学会向tomcat模拟的本地服务器发送请求的同学非常重要! 转自:http://wing123.iteye.com/blog/1873763 描述:在做注册功能的时候,向本地服务器:127.0.0.1发送注册请求,logcat显示出错信息: java.net.ConnectException: localhost/127.0.0.1:8888 - Connection refused 解决办法:弃用127.0.0.1来访问服务器,改用本机的真实IP. 问题解释:摘自:http://80x8

linux下FTP拒绝(ftp: connect: Connection refused,500 OOPS: cannot read config file)

使用Ubunto15.0.4环境下,使用APT命令下载的vsftpd程序 在/etc/vsftpd.conf中开启匿名用户权限(anonymous_enable=YES),重新启动vsftpd后,在用ftp localhost,竟然会报ftp: connect: Connection refused的错误,使用sudo service vsftpd start,或sudo /etc/init.d/vsftpd start,竟然启动不起来.报500 OOPS: cannot read config

“Connection refused” vs “No route to host”

曾经在http://blog.csdn.net/bisal/article/details/42496583这篇博文中提到一个端口连接的验证: "[email protected]$telnet 172.101.19.57 1521Trying 172.101.19.57...telnet: connect to address 172.101.19.57: No route to host如果端口未开,实际报错:[email protected]$telnet 172.27.19.56 152