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

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

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

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

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

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

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