您好,登錄后才能下訂單哦!
如何解決mongodb中打開大量files的問題,針對這個問題,這篇文章詳細(xì)介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
問題描述:
mac osx 環(huán)境 通過tcp測試工具,創(chuàng)建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
實際上一進(jìn)入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
不太一樣,一個集合一個文件,一個索引一個文件。所以你一共有多少集合,至少就會有集合數(shù)量x2個打開文件(以1集合文件+1索引文件計算)被占用。再考慮到網(wǎng)絡(luò)連接數(shù)量,要保證足夠大的open files值。open files可以通過以下命令修改:
ulimit -n 1024
關(guān)于如何解決mongodb中打開大量files的問題問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。