MongDB 啟動警告 WARNING: soft rlimits too low,mongdbrlimits

來源:互聯網
上載者:User

MongDB 啟動警告 WARNING: soft rlimits too low,mongdbrlimits

# 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

mongod   24283     1  0 12:35 ?        00:00:04 /usr/bin/mongod -f /etc/mongod.confroot     24240 22049  0 12:45 pts/2    00:00:00 grep mongod

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

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

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                 32000                processes Max open files            64000                64000                files     Max locked memory         65536                65536                bytes     Max address space         unlimited            unlimited            bytes     Max file locks            unlimited            unlimited            locks     Max pending signals       14833                14833                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 或者 files ,有幾種方法:


方法一:

修改設定檔 /etc/security/limits.d/90-nproc.conf  

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

*          soft    nproc     1024改為:*          soft    nproc     32000

重啟 mongod 服務:

[root@localhost ~]# service mongod restart



方法二:

修改設定檔 /etc/security/limits.conf,添加配置資訊:

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

mongod soft nofile 64000mongod hard nofile 64000mongod soft nproc 32000mongod hard nproc 32000

重啟 mongod 服務:

[root@localhost ~]# service mongod restart


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

[root@localhost ~]# man limits.conf




查看系統限制:

[root@localhost ~]# ulimit -a

core file size          (blocks, -c) 0data seg size           (kbytes, -d) unlimitedscheduling priority             (-e) 0file size               (blocks, -f) unlimitedpending signals                 (-i) 14833max locked memory       (kbytes, -l) 64max memory size         (kbytes, -m) unlimitedopen files                      (-n) 1024pipe size            (512 bytes, -p) 8POSIX message queues     (bytes, -q) 819200real-time priority              (-r) 0stack size              (kbytes, -s) 10240cpu time               (seconds, -t) unlimitedmax user processes              (-u) 14833virtual memory          (kbytes, -v) unlimitedfile locks                      (-x) unlimited

mongodb推薦設定:

-f (file size): unlimited-t (cpu time): unlimited-v (virtual memory): unlimited-n (open files): 64000-m (memory size): unlimited-u (processes/threads): 64000

直接在當前shell中設定:ulimit -n <value>

ulimit -f unlimitedulimit -t unlimitedulimit -v unlimitedulimit -n 64000ulimit -m unlimitedulimit -u 64000

若要系統啟動時在所有生效,將上面的 ulimit 添加到 /etc/profile 

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



參考: UNIX ulimit Settings


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.