最近在使用 mongodb 的过程中遇到了一些棘手的错误,所以做了一个笔记以供参考

soft rlimits too low

WARNING: soft rlimits too low. rlimits set to processes, files. Number of processes should be at least 32767.5 : 0.5 times number of files.

解决方案:切换至 root 用户,更改相关设置

  1. 查看 ulimit:

    1
    $ ulimit -a
  2. 更改相关 ulimit:

    1
    $ ulimit -n <value>

    推荐设置:

    1
    2
    3
    4
    5
    6
    -f (file size): unlimited
    -t (cpu time): unlimited
    -v (virtual memory): unlimited [1]
    -n (open files): 64000
    -m (memory size): unlimited [1] [2]
    -u (processes/threads): 64000
  3. 重启 mongodb

参考:UNIX ulimit Settings — MongoDB Manual 3.2

BadValue Invalid or no user locale set

BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly

解决方案:设置 locale

  1. 设置 /etc/default/locale 为:

    1
    2
    3
    LANG=en_US.UTF-8
    LANGUAGE=en_US
    LC_ALL=en_US.UTF-8

    或者:

    1
    2
    3
    LANG="en_US.UTF-8"
    LANGUAGE="en_US:en"
    LC_ALL="en_US.UTF-8"
  2. 重启 mongodb

参考:virtualbox - error in installing mongo in virtual machine - Ask Ubuntu

本文地址: http://www.cuixiaochen.com/2016/05/20/Mongodb-常见报错及解决方案/