MongoDB 由于缺少 collection*.wt 文件而崩溃
SO 和其他论坛上也有类似的帖子,但是我的问题似乎有所不同,因为我可以启动 mongod 并成功读取它。在 mongosh 终端中运行命令“show dbs”时,它会返回一个错误:
MongoServerError: unable to open cursor at URI statistics:table:collection-124-8620454490016200065. reason: No such file or directory
此外,当尝试将大量数据写入数据库时,mongod 服务本身会由于缺少 .wt 文件而崩溃。 mongod.log 文件显示:
{"t":{"$date":"2022-02-28T12:11:51.031+05:30"},"s":"E", "c":"STORAGE", "id":22435, "ctx":"conn26124","msg":"WiredTiger error","attr":{"error":2,"message":"[1646030511:31871][2824:0x7f3c0e85e700], file:collection-102-8620454490016200065.wt, WT_SESSION.open_cursor: __posix_open_file, 805: /var/lib/mongo/collection-102-8620454490016200065.wt: handle-open: open: No such file or directory"}}
{"t":{"$date":"2022-02-28T12:11:51.036+05:30"},"s":"F", "c":"STORAGE", "id":50883, "ctx":"conn26124","msg":"Cursor not found","attr":{"error":{"code":43,"codeName":"CursorNotFound","errmsg":"Failed to open a WiredTiger cursor. Reason: UnknownError: 2: No such file or directory, uri: table:collection-102-8620454490016200065, config: "}}}
{"t":{"$date":"2022-02-28T12:11:51.037+05:30"},"s":"F", "c":"-", "id":23091, "ctx":"conn26124","msg":"Fatal assertion","attr":{"msgid":50883,"file":"src/mongo/db/storage/wiredtiger/wiredtiger_cursor.cpp","line":72}}
{"t":{"$date":"2022-02-28T12:11:51.037+05:30"},"s":"F", "c":"-", "id":23092, "ctx":"conn26124","msg":"\n\n***aborting after fassert() failure\n\n"}
我假设数据库中缺少一个集合。我没有办法验证这一点。任何损坏的数据丢失都不是问题。只需要让数据库再次工作即可。
更新:正如评论中所建议的, mongod --dbpath /data/db --repair 按预期工作。尽管看起来其中一个数据库丢失了一些集合。备份的好提醒!
Similar threads are present on SO and other forums, however my issue seems to be different in that I can start mongod and read from it successfully. When running the command 'show dbs' in the mongosh terminal, it returns an error saying:
MongoServerError: unable to open cursor at URI statistics:table:collection-124-8620454490016200065. reason: No such file or directory
Also, when trying to write large amount of data to the db it the mongod service itself crashes due to missing .wt files. The mongod.log file says:
{"t":{"$date":"2022-02-28T12:11:51.031+05:30"},"s":"E", "c":"STORAGE", "id":22435, "ctx":"conn26124","msg":"WiredTiger error","attr":{"error":2,"message":"[1646030511:31871][2824:0x7f3c0e85e700], file:collection-102-8620454490016200065.wt, WT_SESSION.open_cursor: __posix_open_file, 805: /var/lib/mongo/collection-102-8620454490016200065.wt: handle-open: open: No such file or directory"}}
{"t":{"$date":"2022-02-28T12:11:51.036+05:30"},"s":"F", "c":"STORAGE", "id":50883, "ctx":"conn26124","msg":"Cursor not found","attr":{"error":{"code":43,"codeName":"CursorNotFound","errmsg":"Failed to open a WiredTiger cursor. Reason: UnknownError: 2: No such file or directory, uri: table:collection-102-8620454490016200065, config: "}}}
{"t":{"$date":"2022-02-28T12:11:51.037+05:30"},"s":"F", "c":"-", "id":23091, "ctx":"conn26124","msg":"Fatal assertion","attr":{"msgid":50883,"file":"src/mongo/db/storage/wiredtiger/wiredtiger_cursor.cpp","line":72}}
{"t":{"$date":"2022-02-28T12:11:51.037+05:30"},"s":"F", "c":"-", "id":23092, "ctx":"conn26124","msg":"\n\n***aborting after fassert() failure\n\n"}
I assume one collection is missing from the db. I have no means to verify this. Data loss for any corrupted data is not an issue. Just need to get the db working again.
Update: as suggested in the comments, mongod --dbpath /data/db --repair worked as expected. Although it seems some collections were lost from one of the dbs. Good reminder for backups!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论