MongoDB available connections

左心房为你撑大大i 提交于 2019-12-23 23:25:29

问题


I installed MongoDB on Windows, Mac and Linux. I run MongoDB with all default arguments and I enter a command db.serverStatus().connections on mongo to check the available connections.

Here is my observation, Windows 7 has 19999, Mac has only 203 and Linux has 818. Therefore, I would like to ask what makes the number of available connections different and is it possible to increase the available connections?

Thank you.


回答1:


For UNIX-like systems (i.e. Linux and OS X), the connection limit is governed by ulimits. MongoDB will use 80% of the available file descriptors for connections, which is why you see 203 on Mac (~80% of 256) and 819 on Linux (~80% of 1024).

The MongoDB documentation includes recommended settings for production systems. Typically you wouldn't need to change this on development environments, but you will see a warning on startup if the connection limits are considered low.

In MongoDB 2.4 and earlier, there is a hard-coded maximum of 20,000 connections per server irrespective of the ulimits. This maximum has been removed as at MongoDB 2.6.

There is also a maxConns MongoDB configuration directive that can be used to limit the connections to something lower than what would be allowed by ulimits.




回答2:


@fmchan Turn off SELinux and check again.

I set high NOFile and NProc limits on systemd, and in /etc/security/limits.conf file. But, it didn't help

Now, the only thing that works for me is to 1. setenforce 0 && systemctl restart mongod.service 2. Write a SELinux policy to allow mongod_exec_t to setrlimit and rlimitinh

Here's a similar issue https://bugzilla.redhat.com/show_bug.cgi?id=1415045



来源:https://stackoverflow.com/questions/22375027/mongodb-available-connections

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!