我的MongoDB数据库在负载下遇到了问题,垃圾邮件记录了以下错误:
[initandlisten] pthread_create failed: errno:11 Resource temporarily unavailable
[initandlisten] can't create new thread, closing connection
我得出的结论是,我需要提高“ ulimit -u”或“最大进程”设置(该设置为1024),并且使用量可能已经超过了启动Web前端时的使用量(不确定如何检查) 。
我编辑了/etc/security/limits.conf以添加最后两行(前两行已经存在):
* soft nofile 350000
* hard nofile 350000
* soft nproc 30000
* hard nproc 30000
然后,我重新启动了系统(顺便说一句,我应该这样做,还是应该重新启动mongod服务?)
重新启动后,查看mongod进程的进程限制,似乎软限制已被忽略:
$ cat /proc/2207/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 1024 30000 processes
Max open files 350000 350000 files
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 273757 273757 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
$ whoami
mongod
$ 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) 273757
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 350000
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
我希望根据/etc/security/limits.conf文件,“最大进程”的硬限制和软限制都将为30000,但只有硬限制是30000。
我究竟做错了什么?
我正在AWS EC2上运行Amazon Linux。
bash-4.1$ cat /etc/*-release
Amazon Linux AMI release 2012.09
2
看在/etc/security/conf.d/中吗?有时,那里有一个文件会覆盖mainlimits.conf中设置的文件。
—
dmourati 2013年
dmourati,谢谢,您说得对(与Scott Mcinyre一样)。
—
约翰M,