Transferred from: http://blog.yucanlin.cn/2015/03/23/mongodb-%E4%BF%AE%E6%94%B9-ulimit/
MongoDB Modify Ulimit
It all comes from the warning of MongoDB.
1 |
** WARNING: soft rlimits too low. rlimits set to 4096 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files. |
It is not difficult to modify ulimit, but there are still many pits. MongoDB Official document http://docs.mongodb.org/manual/reference/ulimit/#memory-size, although the method is given, but the Linux ulimit is user-related, So the practice is not reliable.
The correct approach is to modify the/etc/security/limits.conf file, which is a man document that can be viewed by the man limit.conf file. First give a sample:
1 2 3 4 5 6 7 8 9 10 11 |
<domain><
type
><item><value>
* soft core 0
* hard nofile 512
@student hard nproc 20
@faculty soft nproc 20
@faculty hard nproc 50
ftp
hard nproc 0
@student - maxlogins 4
:123 hard cpu 5000
@500: soft cpu 10000
600:700 hard locks 10 |
According to the instructions, we add the following values from the recommended values in the MongoDB document. One requirement is that Nproc be larger than 0.5nofile.
1 2 3 4 5 6 7 8 9 10 |
mongod soft fsize unlimited mongod hard fsize unlimited mongod soft cpu unlimited mongod hard cpu unlimited mongod soft as unlimited mongod hard as unlimited mongod soft nofile 64000 mongod hard nofile 64000 mongod soft nproc 64000 mongod hard nproc 64000 |
It's done after the reboot. Note here, please indicate the user, do not use * instead. Users who start MongoDB will fill in the user, you can use the PS command query.
1 2 3 |
[[email protected] ~]$ ps -ef | grep mongod mongod 945 1 1 12:11? 00:00:14 /usr/bin/mongod -f /etc/mongod .conf yucanlin 3040 2649 0 12:32 pts /0 00:00:00 grep --color=auto mongod |
In addition, if you want to query Mongod's limits, you can use the following command. 945 of them are PID. The above PS command query is obtained.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[[email protected] ~]$
cat /proc/945/limits Limit Soft Limit Hard Limit Units Max cpu
time unlimited unlimited seconds Max
file size unlimited unlimited bytes Max data size unlimited unlimited bytes Max stack size 8388608 unlimited bytes Max core
file size 0 unlimited bytes Max resident
set unlimited unlimited bytes Max processes 64000 64000 processes Max
open files 64000 64000 files Max locked memory 65536 65536 bytes Max address space unlimited unlimited bytes Max
file locks unlimited unlimited locks Max pending signals 7859 7859 signals Max msgqueue size 819200 819200 bytes Max
nice priority 0 0 Max realtime priority 0 0 Max realtime timeout unlimited unlimited us |
Yucanlin March 23, 2015 computer 2 Comments
Goto: MongoDB Modify Ulimit