如何解決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的問題問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。