Recently in the MONGO database cluster, used in the production environment after the discovery of the client will be denied access. The query process found that the route MONGOs is not down, can ping through, and then view the maximum number of connections, found to be full.
Popular Science: Under the Linux platform, either 64-bit or 32-bit MONGODB default maximum connection number is 819,win platform do not know, estimated also no one in the win platform using MONGODB production environment.
Therefore, the maximum number of connections is modified.
1. Query the maximum number of connections:
Db.serverstats (). connections
2. Modify the maximum number of connections:
Shut down the database, reboot plus parameters maxconns:mongodb--port 27017--dbpath data/--maxconn 300
3. Reboot to see the maximum number of connections:
Db.serverstats (). connections
The discovery is still 819, has not changed, this is what? After some research, it is found that this is the system limit, the Linux default process can open the maximum number of files is limited, can be resolved through ulimit.
4. Setting up the system
Linux switch to Super User, Ulimit-n 4000, can also be modified in the configuration file,/etc/rc.local add ulimit-n 4000
5. Restart MongoDB to see the maximum number of connections has become 3000
This article is from the "Black Time" blog, so be sure to keep this source http://blacktime.blog.51cto.com/11722918/1795308
MongoDB Maximum Connection number optimization