- A+
所属分类:MongoDB
MongoDB在Linux上启动,有一些warning:
WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
WARNING: soft rlimits too low. rlimits set to 1024 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
针对前面两个WARNING,解决比较简单:
1 2 |
sudo echo "never" > /sys/kernel/mm/transparent_hugepage/enabled sudo echo "never" > /sys/kernel/mm/transparent_hugepage/defrag |
第三个WARNING提示的意思就是说MongoDB的软件进程被限制了,MongoDB希望自己是最少32767.5
我们需要将限制的processes从1024 -> 32000 或者更大
首先我们查看当前的MongoDB进程信息:
1 |
ps -ef | grep mongod |
显示如下结果:
1 2 3 |
[root@iZuf65kt3jxz8thz0b2rj7Z logs]# ps -ef | grep mongod mongod 13974 1 0 08:40 ? 00:00:43 /usr/bin/mongod -f /etc/mongod.conf root 14162 14005 0 10:14 pts/0 00:00:00 grep mongod |
可以看到mongod的进程号是:13974
我们继续查看mongod进程的系统限制:
1 |
cat /proc/13974/limits |
显示如下结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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 0 unlimited bytes Max resident set unlimited unlimited bytes Max processes 1024 64000 processes Max open files 65535 65535 files Max locked memory 65536 65536 bytes Max address space unlimited unlimited bytes Max file locks unlimited unlimited locks Max pending signals 3900 3900 signals Max msgqueue size 819200 819200 bytes Max nice priority 0 0 Max realtime priority 0 0 Max realtime timeout unlimited unlimited us |
可以看到限制Max processes, Max open files
如何修改呢?有两种办法:
- 修改配置文件/etc/security/limits.d/90-nproc.conf
1 2 3 |
* soft nproc 1024 改为: * soft nproc 32000 |
然后重启MongoDB服务即可:
1 |
service mongod restart |
- 修改配置文件/etc/security/limits.conf,添加配置信息:
1 2 3 4 |
mongod soft nofile 64000 mongod hard nofile 64000 mongod soft nproc 32000 mongod hard nproc 32000 |
然后重启MongoDB服务即可:
1 |
service mongod restart |
参考:
MongDB 启动警告 WARNING: soft rlimits too low
Mongodb 启动报错:"/sys/kernel/mm/transparent_hugepage/enabled is 'always'"