温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何解决mongodb中打开大量files的问题

发布时间:2021-09-14 09:59:53 来源:亿速云 阅读:141 作者:柒染 栏目:大数据

如何解决mongodb中打开大量files的问题,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

问题描述:

  mac osx 环境
   通过tcp测试工具,创建3000个连接,就报 too many open files 具体错误:`

2016-05-11T00:59:29.772+0800 E STORAGE  [thread1] WiredTiger (23) [1462899569:771906][60793:0x70000020a000], log-server: /data/db/journal: opendir: Too many open files in system
2016-05-11T00:59:29.772+0800 E STORAGE  [thread1] WiredTiger (23) [1462899569:772155][60793:0x70000020a000], log-server: dirlist journal prefix WiredTigerPreplog: Too many open files in system
2016-05-11T00:59:29.772+0800 E STORAGE  [thread1] WiredTiger (23) [1462899569:772199][60793:0x70000020a000], log-server: log pre-alloc server error: Too many open files in system
2016-05-11T00:59:29.772+0800 E STORAGE  [thread1] WiredTiger (23) [1462899569:772239][60793:0x70000020a000], log-server: log server error: Too many open files in system
2016-05-11T00:59:33.022+0800 W FTDC     [ftdc] Uncaught exception in 'FileNotOpen: Failed to open interim file /data/db/diagnostic.data/metrics.interim.temp' in full-time diagnostic data capture subsystem. Shutting down the full-time diagnostic data capture subsystem.
2016-05-11T00:59:33.566+0800 E STORAGE  [thread2] WiredTiger (23) [1462899573:566795][60793:0x700000393000], file:WiredTiger.wt, WT_SESSION.checkpoint: WiredTiger.turtle: fopen: Too many open files in system
2016-05-11T00:59:33.568+0800 E STORAGE  [thread2] WiredTiger (23) [1462899573:568812][60793:0x700000393000], checkpoint-server: checkpoint server error: Too many open files in system
2016-05-11T00:59:33.568+0800 E STORAGE  [thread2] WiredTiger (-31804) [1462899573:568879][60793:0x700000393000], checkpoint-server: the process must exit and restart: WT_PANIC: WiredTiger library panic
2016-05-11T00:59:33.568+0800 I -        [thread2] Fatal Assertion 28558
2016-05-11T00:59:33.568+0800 I -        [thread2]

可以先查看一下允许多少个打开文件

Yaoxings-MacBook-Pro:db yaoxing$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 709
virtual memory          (kbytes, -v) unlimited

实际上一进入mongoshell就会提示你这一点

2016-05-11T17:45:17.536+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000

WiredTiger的工作原理跟MMAPv1不太一样,一个集合一个文件,一个索引一个文件。所以你一共有多少集合,至少就会有集合数量x2个打开文件(以1集合文件+1索引文件计算)被占用。再考虑到网络连接数量,要保证足够大的open files值。open files可以通过以下命令修改:

ulimit -n 1024

关于如何解决mongodb中打开大量files的问题问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI