# 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

  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

  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

  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

  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

  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推荐设置:

  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>

  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

最新文章

  1. iOS10 适配问题-Xcode8
  2. Atitti.数字证书体系cer pfx attilax总结
  3. Javascript高级程序设计——在HTML中使用Javascript
  4. PL/0与Pascal-S编译器程序详细注释
  5. process thread Fiber(linux)
  6. 重构前的程序:通过rsync命令抓取日志文件
  7. iOS开源 框架
  8. Oracle Berkeley DB Java 版
  9. jboss7.1.0配置数据库(mysql)
  10. get方式提交中文乱码(两次编码,一次解码)
  11. LOJ#6374 网格
  12. [Swift]LeetCode853. 车队 | Car Fleet
  13. uva-757-贪心
  14. eureka 学习
  15. Oracle 12C -- purge dba_recyclebin
  16. android笔记--加载框
  17. Linux free命令使用及解析
  18. ASP.NET MVC4优化
  19. 关于 ake sure class name exists, is public, and has an empty constructor that is public
  20. 转一个Visual Stuido 快捷键

热门文章

  1. HttpURLConnection发送GET、POST请求
  2. Mac 10.12原生方法对NTFS分区进行读写的配置
  3. Mac 10.12安装迅雷2.7.2
  4. linux inotifywait 下监控是否有IO
  5. 【es6】数组扩展
  6. StackMapTable属性说明
  7. CyclicBarrier正确的使用方法和错误的使用方法
  8. 令狐冲和TCP/IP协议的第三层协议的关系(经典)
  9. 去掉img标签周围的空白
  10. [译]用R语言做挖掘数据《三》