問題描述:
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 system2016-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 system2016-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 system2016-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 system2016-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 system2016-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 system2016-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 panic2016-05-11T00:59:33.568+0800 I - [thread2] Fatal Assertion 285582016-05-11T00:59:33.568+0800 I - [thread2]
`
回複內容:
問題描述:
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 system2016-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 system2016-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 system2016-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 system2016-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 system2016-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 system2016-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 panic2016-05-11T00:59:33.568+0800 I - [thread2] Fatal Assertion 285582016-05-11T00:59:33.568+0800 I - [thread2]
`
可以先查看一下允許多少個開啟檔案
Yaoxings-MacBook-Pro:db yaoxing$ ulimit -acore file size (blocks, -c) 0data seg size (kbytes, -d) unlimitedfile size (blocks, -f) unlimitedmax locked memory (kbytes, -l) unlimitedmax memory size (kbytes, -m) unlimitedopen files (-n) 256pipe size (512 bytes, -p) 1stack size (kbytes, -s) 8192cpu time (seconds, -t) unlimitedmax user processes (-u) 709virtual 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