Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ CentOS6 MongoDB connection solution can not break 1000     - Command line tool Tmux (Linux)

- 10 really interesting Linux command (Linux)

- W and uptime command (Linux)

- Linux pwd command learning experience (Linux)

- CentOS 6.5 upgrade to CentOS 7 (Linux)

- The Objects in JavaScript (Programming)

- JavaScript function part (Programming)

- Linux how to prohibit the use of Ping command (Linux)

- Shell for loop (Programming)

- linux remote control software (Linux)

- JavaScript basic tools list (Programming)

- Mybatis + binding Struts2: achieving user to insert and find (Programming)

- Three minutes to teach you to easily grasp the grep command regular expression (Linux)

- Windows 8.1 and Ubuntu 14.04 dual system uninstall Ubuntu Tutorial (Linux)

- Oracle 11g R2 RAC RMAN backup script example (Database)

- Linux installation skynet issue summary (Linux)

- Thinking in Java study notes - Access modifiers (Programming)

- RedHat command line and graphical interface switching (Linux)

- Detailed PHP code optimization [section] (explain reasons) (Programming)

- Use LKM change the default linux security level (Linux)

 
         
  CentOS6 MongoDB connection solution can not break 1000
     
  Add Date : 2018-11-21      
         
       
         
  Problem Description:

Production environment found CPU running at full capacity, MongoDB number of connections can not always break through 1000.

solution:

1, views mongodb log, the following error message:

Wed Nov 21 15:26:09 [initandlisten] pthread_create failed: errno: 11 Resource temporarily unavailable

Wed Nov 21 15:26:09 [initandlisten] can not create new thread, closing connection

2, on a different machine CentOS5 test of the connection 2000 connection no problem at all.
3, find the problem on google, keyword "mongod.conf can not create new thread, closing connection"
4, find the problem, the original centos6 previous centos5 different, more of a default limit nproc user profiles: /etc/security/limits.d/90-nproc.conf, the default is set to the average user nproc 1024, the mongodb just another mongod use the non-root user to run, so the number of connections has been stagnant.
5. Change /etc/security/limits.d/90-nproc.conf, 1024 into the 20480, the problem is solved.

[Root @ test ~] # cat /etc/security/limits.d/90-nproc.conf

# Default limit for number of user's processes to prevent

# Accidental fork bombs.

# See rhbz # 432903 for reasoning.

* Soft nproc 20480

The maximum number of open file handles and process limits the number of users:

In the time following the deployment of Linux applications, sometimes encounter Socket / File: Can not open so many files in question; this value will also affect the maximum number of concurrent server, in fact, there is a Linux file handle limit, but Linux default not very high, usually 1024, with the production server is actually very easy to reach this number. Below that it is how positive solution to correct the system configuration defaults.

  
See Method

We can use ulimit -a to see all limits

[Root @ test ~] # 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) 256469

max locked memory (kbytes, -l) 64

max memory size (kbytes, -m) unlimited

open files (-n) 64000

pipe size (512 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) 65536

virtual memory (kbytes, -v) unlimited

file locks (-x) unlimited

Wherein "open files (-n)" is to limit the number of file handles on Linux operating system for a process to open, the default is 1024.
(Also includes the number of SOCKET opened, the number of concurrent connections to the database may be affected).

The correct approach should be to modify /etc/security/limits.conf
There are very detailed notes, for example,
Hadoop soft nofile 32768
hadoop hard nofile 65536

hadoop soft nproc 32768
hadoop hard nproc 65536

It can be unified into a file handle limit soft 32768, 65536 hard. Profile front refers to domain, is set to an asterisk represents the global, in addition you can also make different restrictions for different users.

Note: This is among the hard limit is the actual limit, while the soft limit is warnning restrictions will only make warning; in fact ulimit command set itself hard and soft points, plus -H is hard, add -S is soft

The default display is the soft limit, if you run the ulimit command to modify the time did not add the words, is to change along with two parameters.

RHE6 and subsequent modifications /etc/security/limits.d/90-nproc.conf in nproc

How to modify the connection limit:

Temporary modifications (changes a user can open the shell of the current number of processes):

# Ulimit -u xxx

Permanent changes, the insurance practice is modified while /etc/security/limits.d/90-nproc.conf and /etc/security/limits.conf as follows:

limits_conf = /etc/security/limits.conf:
* Soft nproc s1
* Hard nproc h1

nproc_conf = /etc/security/limits.d/90-nproc.conf:
* Soft nproc s2
* Hard nproc h2

s1, h1, s2, h2 must be specific number of meaningful at this time shows a value of ulimit -u = min (h1, h2)

So usually set s1 = s2 = h1 = h2, for example, while adding limits_conf and nproc_conf in:
* Soft nproc 65536
* Hard nproc 65536
     
         
       
         
  More:      
 
- Install the open source database PostgreSQL 9.4 and phpMyAdmin on Ubuntu (Database)
- GAMIT 10.50 installed in Ubuntu 12.04 system (Linux)
- Inherent limitations of Linux systems network security (Linux)
- The Samba service does not have permission to access (Server)
- Apache Web Security Linux systems (Linux)
- Linux and hardware (Linux)
- Linux screen command (Linux)
- Defensive programming in PHP (Programming)
- Log analysis is done with Grafana Elasticsearch (Server)
- GoldenGate update is missing (Database)
- SpringMVC garbage processing (Programming)
- How to modify the SQL Server auto-increment value and the corresponding solution (Database)
- Linux system security reinforcement (Linux)
- Redis-2.8.17 installation and configuration process some errors (Linux)
- Linux system security Comments (Linux)
- iOS in Singleton (Programming)
- Why do you need close contact Rust 1.0 (Programming)
- ethtool implementation framework and application in Linux (Linux)
- Eclipse 3.7.2 can not start solving under Ubuntu 14.04 (Linux)
- Beautiful start Ubuntu installation tool Duck Launcher 0.64.5 (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.