Mongodb:使用损坏的文档恢复数据库

时间:2014-11-21 06:15:41

标签: mongodb mongodump mongorestore

我在使用损坏的文档恢复数据库时遇到问题。当文档损坏时,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

1 个答案:

答案 0 :(得分:1)

听起来你已经备份了一个腐败的数据库。 尝试使用--noobjcheck选项运行mongorestore 希望这会有所帮助。