Mongodb 崩溃报错 Too many open files

在项目实际使用过程中,客户反馈能打开网页但无法登陆,第一时间感觉到应该是数据库服务器挂了,于是查看Mongodb数据库服务器日志,果不其然挂了。
报错信息如下:

2020-12-28T13:21:21.731+0800 E STORAGE  [conn2624] WiredTiger error (24) [1609132881:731422][23581:0x7fe157189700], WT_SESSION.create: __posix_directory_sync, 135: /data1/mongodb/data/db/: directory-sync: open: Too many open files Raw: [1609132881:731422][23581:0x7fe157189700], WT_SESSION.create: __posix_directory_sync, 135: /data1/mongodb/data/db/: directory-sync: open: Too many open files
2020-12-28T13:21:21.731+0800 E STORAGE  [conn2624] WiredTiger error (24) [1609132881:731616][23581:0x7fe157189700], WT_SESSION.create: __posix_directory_sync, 151: /data1/mongodb/data/db/collection-1063-1706476241051221735.wt: directory-sync: Too many open files Raw: [1609132881:731616][23581:0x7fe157189700], WT_SESSION.create: __posix_directory_sync, 151: /data1/mongodb/data/db/collection-1063-1706476241051221735.wt: directory-sync: Too many open files
2020-12-28T13:21:21.731+0800 E STORAGE  [conn2624] WiredTiger error (-31804) [1609132881:731651][23581:0x7fe157189700], WT_SESSION.create: __wt_panic, 494: the process must exit and restart: WT_PANIC: WiredTiger library panic Raw: [1609132881:731651][23581:0x7fe157189700], WT_SESSION.create: __wt_panic, 494: the process must exit and restart: WT_PANIC: WiredTiger library panic
2020-12-28T13:21:21.731+0800 F -        [conn2624] Fatal Assertion 50853 at src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp 420
2020-12-28T13:21:21.731+0800 F -        [conn2624] 

***aborting after fassert() failure

可以看到核心问题就是 Too many open files。经查阅相关资料,造成如下问题的原因就是Centos7给每个用户默认的同时打开文件的数值为1024,可通过如下配置文件查看:

ulimit -a

在这里插入图片描述
其中所有的参数均可修改,那么如何修改open files呢?
在此提供两种方法:
首先查看系统全局参数:
在这里插入图片描述
所以我们可以修改的最大值也是174198

具体修改方法一:
新建一个nofile.conf文件:

vi /etc/security/limits.d/nofile.conf

在此配置文件中写入:

* soft nofile 65536
* hard nofile 65536

在这里插入图片描述
保存后,需要重启系统,永久有效。

具体修改方法二:(不需要重启,不需要停服务,动态修改
1,查看mongodb pid:
在这里插入图片描述

2,查看对应pid limits:

cat /proc/41814/limits

在这里插入图片描述

3,可直接编辑以上文件,也可以直接运行命令行:

prlimit --pid 41814 --nofile=65535:65535

4,再次查看,修改成功:
在这里插入图片描述

总结:建议双管齐下,都修改了。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值