【发布时间】:2015-01-19 05:42:58
【问题描述】:
我在用损坏的文档恢复我们的数据库时遇到问题。 mongorestore 当损坏的文档出来时停止恢复。这是错误。
INVALID OBJECT - going to try and print out
size: 2760
error: bson length doesn't match what we found in object with _id: 2
2014-11-21T12:29:48.717+0900 Assertion: 10330:Element extends past end of object
2014-11-21T12:29:48.740+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0x730af3
2014-11-21T12:29:48.741+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0x6db6bc
2014-11-21T12:29:48.741+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0x6c86db
2014-11-21T12:29:48.745+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0x4280
2014-11-21T12:29:48.749+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0x6c1382
2014-11-21T12:29:48.755+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0xafd52b
2014-11-21T12:29:48.758+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0xaff663
2014-11-21T12:29:48.762+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0xafe97b
2014-11-21T12:29:48.765+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0xafe97b
2014-11-21T12:29:48.772+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0xb01584
2014-11-21T12:29:48.777+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0x6c1b03
2014-11-21T12:29:48.780+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0x6c1beb
2014-11-21T12:29:48.784+0900 mongorestore.exe mongo::parseNumberFromStringWithBase<unsigned char>+0xb364e3
2014-11-21T12:29:48.792+0900 kernel32.dll BaseThreadInitThunk+0xd
2014-11-21T12:29:48.795+0900
object up to error: { HERE IS BROKEN DOCUMENT
assertion: 10330 Element extends past end of object
实际上在备份之前发生了同样的错误。文档被破坏的原因仍然未知(只是猜测可能是意外关闭)。该服务器未使用副本集,并且启用了日志记录。
检索损坏文档的.find() 命令总是失败。 .valid() 命令也可以识别损坏的文档。但是 mongodb 无法使用 db.repairDatabase() 和 mongod --repair 恢复它。我的临时措施是使用mongodump 备份数据,然后使用.remove() 命令删除损坏的文档。
现在的问题是如何从备份中恢复完整的数据库以及如何正确修复它。有没有办法在有(或没有)损坏的文档的情况下恢复数据库?
MongoDB 版本:2.6.1
【问题讨论】:
标签: mongodb mongodump mongorestore