linux - mongodb WARNING rlimit too low?
黄舟
黄舟 2017-04-17 15:02:19
0
3
923

启动mongodb,连接之后提示警告

2016-06-02T18:31:22.635+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 14794 processes, 65536 files. Number of processes should be at least 32768 : 0.5 times number of files.

根据网上提示修改了多处地方

vi /etc/security/limits.conf 
#2016-6-2 modified
* soft nofile 65536
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536
# End of file
vi /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     65536
root       soft    nproc     unlimited

修改完配置文件都重启过系统,并且重启mongodb,仍然无效
根据进程id查看mongod加载的limit参数始终没能修改成功

[root@localhost ~]# ps -ef|grep mongod
root      3140  2604  0 18:31 ?        00:00:04 /appdev/mongodb/bin/mongod --config /data/mongodb0/conf/mongodb0.conf -quiet
root      3238  3112  0 18:32 pts/0    00:00:00 /appdev/mongodb/bin/mongo 192.168.1.205:29001
root      3260  3208  0 18:39 pts/1    00:00:00 grep mongod
[root@localhost ~]# 
[root@localhost ~]# cat /proc/3140/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            10485760             unlimited            bytes     
Max core file size        unlimited            unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             14794                14794                processes 
Max open files            65536                65536                files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       14794                14794                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us        
[root@localhost ~]# 

Max processes始终都是“14794”,而不是修改之后的“65536”

这是什么原因,求解答!

modify by 2016-06-03 10:15
后来各方面排查了一下,也根据一楼的答案检查过了;发现问题不在于mongodb,而是在supervisord
我的mongodb是用supervisord来管理的,使用supervisord来启动mongodb之后,mongodb的进程始终加载不了最新修改过的max process,如果直接用mongod命令启动mongodb则可以正常加载到最新修改的max process,supervisord配置是用root用户启动mongodb的,mongod命令也是一样用的root用户启动

supervisord配置:
[program:mongodb]
command = /appdev/mongodb/bin/mongod --config /data/mongodb0/conf/mongodb0.conf -quiet
autostart = true
autorestart = true
redirect_stderr=true 
user = root
priority=9
startsecs=30
stdout_logfile=/data/log/log4supervisord/console_mongodb.log
stdout_logfile_maxbytes=50MB
environment=NLS_LANG="AMERICAN_AMERICA.UTF8",LANG="en_US.UTF-8"
[root@localhost ~]# 

实在不解,为何supervisord来管理mongodb,无法加载limits

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

Antworte allen(3)
迷茫

最终解决是修改supervisord(/etc/init.d/supervisord)的启动参数,加入两行:

ulimit -n65536
ulimit -u 65536

一直是supervisord无法加载系统的/etc/security/limit.conf,而由supervisord启动监控的进程的ulimit等参数是无法超过supervisord自身的,所以只能先把supervisord的上限加大,然后mongodb才能调整.
非常感谢两位楼主的回答,都很有帮助。

左手右手慢动作

登录到启动mongo进程的这个用户上
ulimit -a 看下是否成功 如果成功直接用这个用户启动mongo进程再看看是否更改
如果不成功则是pam_limit.so没有被加载,修改/etc/pam.d/login 文件加上 pam_limit.so就可以了

左手右手慢动作

supervisord配置中加minfds=64000试试

还可以尝试
command=bash -c "ulimit -n 64000;ulimit -u 64000; exec /appdev/mongodb/bin/mongod --config /data/mongodb0/conf/mongodb0.conf -quiet"

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage