在項目實際使用過程中,客戶反饋能打開網(wǎng)頁但無法登陸,第一時間感覺到應(yīng)該是數(shù)據(jù)庫服務(wù)器掛了,于是查看Mongodb數(shù)據(jù)庫服務(wù)器日志,果不其然掛了。
報錯信息如下:
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。經(jīng)查閱相關(guān)資料,造成如下問題的原因就是Centos7給每個用戶默認的同時打開文件的數(shù)值為1024,可通過如下配置文件查看:
ulimit -a

其中所有的參數(shù)均可修改,那么如何修改open files呢?
在此提供兩種方法:
首先查看系統(tǒng)全局參數(shù):

所以我們可以修改的最大值也是174198
具體修改方法一:
新建一個nofile.conf文件:
vi /etc/security/limits.d/nofile.conf
在此配置文件中寫入:
* soft nofile 65536
* hard nofile 65536

保存后,需要重啟系統(tǒng),永久有效。
具體修改方法二:(不需要重啟,不需要停服務(wù),動態(tài)修改)
1,查看mongodb pid:

2,查看對應(yīng)pid limits:

3,可直接編輯以上文件,也可以直接運行命令行:
prlimit --pid 41814 --nofile=65535:65535
4,再次查看,修改成功:

總結(jié):建議雙管齊下,都修改了。
到此這篇關(guān)于Mongodb 崩潰報錯 Too many open files的問題解析的文章就介紹到這了,更多相關(guān)Mongodb 報錯 Too many open files內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:- MongoDB啟動報錯 28663 Cannot start server
- MongoDB添加仲裁節(jié)點報錯:replica set IDs do not match的解決方法
- NodeJS連接MongoDB數(shù)據(jù)庫時報錯的快速解決方法
- 關(guān)于mongoose連接mongodb重復(fù)訪問報錯的解決辦法
- perl操作MongoDB報錯undefined symbol: HeUTF8解決方法