To modify the maximum number of MONGODB connections

Source: Internet
Author: User
Tags mongodb

Problem: Today PHP test end error. I don't know if it's a mongodb question. The test is most often normal, and the error occurs after several refreshes.

Think of the reason for the number of connections, so think of the maximum number of connections to modify, and then let them test, whether the problem remains.


To modify the method:

---------------------------------------------------------------------------------------

1. Modify System Parameters: Vi/etc/rc.local

#!/bin/sh
#
# This script would be executed *after* all the other init scripts.
# You can put your own initialization stuff with If you don ' t
# want to does the full Sys V style init stuff.


Ulimit-n 20000
Touch/var/lock/subsys/local



2. Configuration file:
[Root@localhost bin]# Cat Mongod.cfg
dbpath=/opt/mongodb/db/
Logpath=/opt/mongodb/logs/mongod.log
port=28001
Logappend=true
Fork = True
Directoryperdb=true
#auth =true

maxconns=30000


Reboot the server,
But now the maximum number of connections is still the default:
> Db.serverstatus (). connections;
{"Current": 1, "available": 819, "totalcreated": Numberlong (8)}


View: Ulimit-a did not see the open files item.



It's not working. Later in the user's. Bash_profile added, and then look, the problem solved:


[Root@localhost bin]# Su-mongo
[Mongo@localhost ~]$ Ulimit-a
Core file size (blocks,-c) 0
Data seg Size (Kbytes,-D) Unlimited
Scheduling Priority (-e) 0
File size (blocks,-f) Unlimited
Pending Signals (I.) 30435
Max locked Memory (Kbytes, L) 64
Max memory Size (Kbytes, M) Unlimited
open Files (-N) 20000
Pipe Size (bytes, p) 8
POSIX message queues (bytes,-Q) 819200
Real-time priority (-R) 0
Stack size (Kbytes,-s) 10240
CPU time (seconds,-t) unlimited
MAX User Processes (-u) 1024
Virtual Memory (Kbytes,-V) Unlimited

File locks (-X) Unlimited


The modified. bash_profile file is as follows:

--------------------------------------------
[Mongo@localhost ~]$ Cat ~/.bash_profile
#. Bash_profile

# get the aliases and functions
If [f ~/.BASHRC]; Then
. ~/.bashrc
Fi

# User specific environment and startup programs

Path= $PATH: $HOME/bin


mongo_home=/opt/mongodb/mongodb-linux-x86_64-2.5.5; Export Mongo_home
Path= $PATH: $MONGO _home/bin;
Export PATH

Stty Erase ^h #删除键可用处理

ulimit-n 20000
Export PATH
[Mongo@localhost ~]$


To view the maximum number of connections:


> Db.serverstatus (). connections;

{"Current": 1, "available": 15999, "totalcreated": Numberlong (8)}



later, modify the Mongod startup parameters in another test server:

maxconns=30000 found in the modified to 10 o'clock, also reported wrong, and later to test modified to 100, no error.

The specific minimum value is how much, has not been tested down.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.