在項目實際使用過程中,客戶反饋能打開網頁但無法登陸,第一時間感覺到應該是數據庫服務器掛了,于是查看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文件:
1
|
vi /etc/security/limits.d/nofile.conf |
在此配置文件中寫入:
1
2
|
* soft nofile 65536 * hard nofile 65536 |
保存后,需要重啟系統,永久有效。
具體修改方法二:(不需要重啟,不需要停服務,動態修改)
1,查看mongodb pid:
2,查看對應pid limits:
1
|
cat /proc/41814/limits |
3,可直接編輯以上文件,也可以直接運行命令行:
1
|
prlimit --pid 41814 --nofile=65535:65535 |
4,再次查看,修改成功:
總結:建議雙管齊下,都修改了。
到此這篇關于Mongodb 崩潰報錯 Too many open files的問題解析的文章就介紹到這了,更多相關Mongodb 報錯 Too many open files內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!
原文鏈接:https://blog.csdn.net/arroganceee/article/details/111862546