MongDB 启动警告 WARNING: soft rlimits too low

# mongo
MongoDB shell version: 3.0.2
connecting to: test
Server has startup warnings: 
2015-05-09T12:34:19.688-0700 I CONTROL  [initandlisten] 
2015-05-09T12:34:19.688-0700 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 1024 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.


mongodb当前限制:1024 processes, 64000 files

mongodb建议要求:processes = 0.5*files=32000(至少)


所以需要将 processes  从1024 改为 32000 或更大.



查看当前mongodb进程信息:

[root@localhost ~]# ps -ef | grep mongod

[plain]  view plain  copy
  1. mongod   24283     1  0 12:35 ?        00:00:04 /usr/bin/mongod -f /etc/mongod.conf  
  2. root     24240 22049  0 12:45 pts/2    00:00:00 grep mongod  

[root@localhost ~]# cat /proc/24283/limits

#可以看到限制:Max processes,Max open files 

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. Limit                     Soft Limit           Hard Limit           Units       
  2. Max cpu time              unlimited            unlimited            seconds     
  3. Max file size             unlimited            unlimited            bytes       
  4. Max data size             unlimited            unlimited            bytes       
  5. Max stack size            10485760             unlimited            bytes       
  6. Max core file size        0                    unlimited            bytes       
  7. Max resident set          unlimited            unlimited            bytes       
  8. Max processes             1024                 32000                processes   
  9. Max open files            64000                64000                files       
  10. Max locked memory         65536                65536                bytes       
  11. Max address space         unlimited            unlimited            bytes       
  12. Max file locks            unlimited            unlimited            locks       
  13. Max pending signals       14833                14833                signals     
  14. Max msgqueue size         819200               819200               bytes       
  15. Max nice priority         0                    0                      
  16. Max realtime priority     0                    0                      
  17. Max realtime timeout      unlimited            unlimited            us      



修改 Max processes 或者 files ,有几种方法:


方法一:

修改配置文件 /etc/security/limits.d/90-nproc.conf  

[root@localhost ~]# vi /etc/security/limits.d/90-nproc.conf 

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. *          soft    nproc     1024  
  2. 改为:  
  3. *          soft    nproc     32000  

重启 mongod 服务:

[root@localhost ~]# service mongod restart



方法二:

修改配置文件 /etc/security/limits.conf,添加配置信息:

[root@localhost ~]# vi /etc/security/limits.conf

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. mongod soft nofile 64000  
  2. mongod hard nofile 64000  
  3. mongod soft nproc 32000  
  4. mongod hard nproc 32000  

重启 mongod 服务:

[root@localhost ~]# service mongod restart


也可以查看 limits.conf 更多配置信息和使用方法:

[root@localhost ~]# man limits.conf




查看系统限制:

[root@localhost ~]# ulimit -a

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. core file size          (blocks, -c) 0  
  2. data seg size           (kbytes, -d) unlimited  
  3. scheduling priority             (-e) 0  
  4. file size               (blocks, -f) unlimited  
  5. pending signals                 (-i) 14833  
  6. max locked memory       (kbytes, -l) 64  
  7. max memory size         (kbytes, -m) unlimited  
  8. open files                      (-n) 1024  
  9. pipe size            (512 bytes, -p) 8  
  10. POSIX message queues     (bytes, -q) 819200  
  11. real-time priority              (-r) 0  
  12. stack size              (kbytes, -s) 10240  
  13. cpu time               (seconds, -t) unlimited  
  14. max user processes              (-u) 14833  
  15. virtual memory          (kbytes, -v) unlimited  
  16. file locks                      (-x) unlimited  

mongodb推荐设置:

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. -f (file size): unlimited  
  2. -t (cpu time): unlimited  
  3. -v (virtual memory): unlimited  
  4. -n (open files): 64000  
  5. -m (memory size): unlimited  
  6. -u (processes/threads): 64000  

直接在当前shell中设置:ulimit -n <value>

[plain]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. ulimit -f unlimited  
  2. ulimit -t unlimited  
  3. ulimit -v unlimited  
  4. ulimit -n 64000  
  5. ulimit -m unlimited  
  6. ulimit -u 64000  

若要系统启动时在所有生效,将上面的 ulimit 添加到 /etc/profile 

[root@localhost ~]# vi /etc/profile


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值