View and modify the maximum number of MONGODB connections

Source: Internet
Author: User

Under the Linux platform, either 64-bit or 32-bit MONGODB default maximum connection number is 819,win platform do not know, estimated that no one in the win platform using MONGODB production environment

[[email protected] mongodb-linux-i686-2.4.1] #./bin/mongo 192.168.6.42
MongoDB Shell version:2.4.1

Connecting To:192.168.6.42/test

> Db.serverstatus (). connections

{"Current": 1, "available": 818, "totalcreated

"

: Numberlong (1)}

On the way available show 818 less one, indicating free. Current represents the number of connections already occupied, two number one plus equals 819, if I'm connecting now, then available is 817,current is 2.

[[email protected] mongodb-linux-i686-2.4.1] #./bin/mongo 192.168.6.42
MongoDB Shell version:2.4.1

Connecting To:192.168.6.42/test

> Db.serverstatus (). connections

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

> Db.serverstatus (). connections

{"Current": 2, "available": 817, "totalcreated

"

: Numberlong (2)}

819 connections for the general site I think it is enough, and are now connected to the current withdrawal. However, the number of connections can also be modified, as long as the boot time to add--maxconns can

Server Startup

[[email protected] mongodb-linux-x86_64-2.4.1] #./bin/mongod--dbpath=/root/db--maxconns=2000
Wed APR 3 11:06:21.905 [Initandlisten] MongoDB starting:pid=2812 port=27017 dbpath=/root/db 64-bit Host=lee

Wed APR 3 11:06:21.957 [Initandlisten] DB version v2.4.1

Wed APR 3 11:06:21.957 [Initandlisten] git version:1560959e9ce11a693be8b4d0d160d633eee75110

Wed APR 3 11:06:21.957 [Initandlisten] Build Info:linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen # 1 SMP Fri Nov 20 17:4 8:28 EST x86_64 boost_lib_version=1_49
Wed APR 3 11:06:21.957 [Initandlisten] Allocator:tcmalloc

Wed APR 3 11:06:21.957 [Initandlisten] Options: {dbpath: "/root/db", maxconns:2000}

Wed APR 3 11:06:21.982 [Initandlisten] Journal Dir=/root/db/journal

Wed APR 3 11:06:21.982 [Initandlisten] recover:no journal files present, no recovery needed

Wed APR 3 11:06:22.297 [Initandlisten] preallocateisfaster=true 2.62

Wed APR 3 11:06:22.717 [Initandlisten]--maxconns too high, can only handle 819

Wed APR 3 11:06:22.724 [Initandlisten] waiting for connections on port 27017

Wed APR 3 11:06:22.725 [websvr] Admin Web console waiting for connections on port 28017

Wed APR 3 11:06:25.126 [Initandlisten] Connection accepted from 192.168.4.86:53917 #

1 (1 connection now OPEN)

Query maximum number of connections

[[email protected] mongodb-linux-i686-2.4.1] #./bin/mongo 192.168.6.42
MongoDB Shell version:2.4.1

Connecting To:192.168.6.42/test

> Db.serverstatus (). connections

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

>

Find it or 819? In fact, the Linux default process can open the maximum number of files, can be resolved by ulimit

[[email protected] mongodb-linux-x86_64-2.4.1] # ulimit-n 2500
[[email protected] mongodb-linux-x86_64-2.4.1] #./bin/mongod--dbpath=/root/db--maxconns=2000
Wed APR 3 11:11:07.013 [Initandlisten] MongoDB starting:pid=2930 port=27017 dbpath=/root/db 64-bit Host=lee

Wed APR 3 11:11:07.013 [Initandlisten] DB version v2.4.1

Wed APR 3 11:11:07.013 [Initandlisten] git version:1560959e9ce11a693be8b4d0d160d633eee75110

Wed APR 3 11:11:07.013 [Initandlisten] Build Info:linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen # 1 SMP Fri Nov 20 17:4 8:28 EST x86_64 boost_lib_version=1_49
Wed APR 3 11:11:07.013 [Initandlisten] Allocator:tcmalloc

Wed APR 3 11:11:07.013 [Initandlisten] Options: {dbpath: "/root/db", maxconns:2000}

Wed APR 3 11:11:07.031 [Initandlisten] Journal Dir=/root/db/journal

Wed APR 3 11:11:07.031 [Initandlisten] recover:no journal files present, no recovery needed

Wed APR 3 11:11:07.170 [Initandlisten] waiting for connections on port 27017

Wed APR 3 11:11:07.171 [websvr] Admin Web console waiting for connections on port 28017

Wed APR 3 11:11:10.076 [Initandlisten] Connection accepted from 192.168.4.86:53161 #

1 (1 connection now OPEN)

Check the maximum number of connections again.

[[email protected] mongodb-linux-i686-2.4.1] #./bin/mongo 192.168.6.42
MongoDB Shell version:2.4.1

Connecting To:192.168.6.42/test

> Db.serverstatus (). connections

{"Current": 1, "Available": 1999, "totalcreated": Numberlong (1)}

>

Learn more about Ulimit you can go online search and search

      • This article is from: Linux Tutorial Network

View and modify the maximum number of MONGODB connections

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.