启动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
最終解決是修改supervisord(/etc/init.d/supervisord)的啟動參數,加入兩行:
一直是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"