mongodb使用中遇到的问题
Invariant failure: ret resulted in status UnknownError:24:Too many open files at ***
错误原因为打开文件过多的错误,即“句柄数超出系统显示”。
1.需要更改一下系统的句柄数:
查看一下系统目前设置的句柄数 open files 对应的即为 当前系统的最大句柄数,目前这台服务器为1024,
ulimit -n 2048 #设置句柄数为2048 但是重启后会重置
2.在mongoDB的bin路径下,重新启动 mongodb服务
#./mongod -f /etc/mongodb/bin/mongodb.conf
3.检查mongoDB服务是否启动:
#ps -def | grep mongod
永久设置方法
vim /etc/security/limits.conf
在最后增加
- soft nofile 4096
- hard nofile 4096
最前的 * 表示全部用户。可依据须要设置某一用户,比如
fdipzone soft nofile 8192
fdipzone hard nofile 8192
改完后注销一下就能生效。