1. The default maximum number of connections for 1.mongodb sharding cluster is 819. I want to increase the number, but the adjustment has not been successful.
[root@ctl1m ~]# mongo mongodb://10.0.1.121:30000
MongoDB shell version v3.4.9
connecting to: mongodb://10.0.1.121:30000
MongoDB server version: 3.4.9
2018-01-18T18:19:13.270+0800 I CONTROL [main]
mongos> db.serverStatus().connections
{ "current" : 715, "available" : 104, "totalCreated" : 719 }
From the above results, it can be seen that the maximum number of connections is 819. When the available is 0, an error will be reported when logging in again:
[root@ctl1m ~]# mongo mongodb://10.0.1.121:30000
MongoDB shell version v3.4.9
connecting to: mongodb://10.0.1.121:30000
2018-01-19T10:52:41.277+0800 E QUERY [thread1] Error: network error while attempting to run command 'isMaster' on host '10.0.1.121:30000' :
connect@src/mongo/shell/mongo.js:237:13
@(connect):1:6
exception: connect failed
2. My revision process:
Modify /etc/secruity/limits.conf, restart the system to view ulimit -n is 16384. configure the following in mongos.conf file:
net:
port: 30000
bindIp: ctl1m # Listen to local interface only, comment to listen on all interfaces.
maxIncomingConnections: 8000
Then restart mongos service, check the connection number again, db.serverStatus().connections, found 819. What is the problem with my amendment? Do you have any amendment methods? Thank you
I also tried to start mongos service with the following method, but it still had no effect:
/usr/bin/mongos –config /etc/mongod/mongos.conf –maxConns=3000
Ulimit -n has been modified and has come into effect. Most of all, when I modified the service file, the total number of connections was normal:
[unit] Description=High-performance, schema-free document-oriented database After=network.target Documentation=https://docs.mongodb.org/manual [Service] User=root Group=root Environment="OPTIONS=-f /etc/mongod/mongos.conf" ExecStart=/usr/bin/mongos $OPTIONS --maxConns 10000 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb PermissionsStartOnly=true PIDFile=/var/run/mongodb/mongos/mongod.pid # file size LimitFSIZE=infinity # cpu time LimitCPU=infinity # virtual memory size LimitAS=infinity # open files LimitNOFILE=64000 # processes/threads LimitNPROC=64000 # total threads (user+kernel) TasksMax=infinity TasksAccounting=false # Recommended limits for for mongod as specified in # http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings [Install] WantedBy=multi-user.target