使用 mongodb 恢复转储失败
我已经使用以下 mongodump 命令行转储了 mongodb 数据库
mongodump -h www.myhost.com -u myusername -p mypassword -d mydb > dump.bson
,并且我正在尝试在本地服务器上恢复转储:
mongorestore -h localhost -d mydb dump.bson
不幸的是,它失败并出现以下错误:
assertion: 10264 invalid object size: 1096040772
有谁知道什么可能导致此错误?
在两台服务器上 mongo 的版本都是 1.8.3
谢谢
I've dumped a mongodb database with the following mongodump command line
mongodump -h www.myhost.com -u myusername -p mypassword -d mydb > dump.bson
And I'm trying to restore the dump on my local server:
mongorestore -h localhost -d mydb dump.bson
Unfortunately it fails with the following error:
assertion: 10264 invalid object size: 1096040772
Does anyone know what could cause this error?
On both servers mongo's version is 1.8.3
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
因为
mongodump
的第一个字符串输出是“已启用数据库级别锁定:0”,您需要执行此操作
Because first string output from
mongodump
is "db level locking enabled: 0"You need to do this
请原谅我的英语:P 当我使用 mongoexport 导出并尝试使用 mongorestore 导入时,这发生在我身上:D 我的错误!我不得不使用 mongoimport 。
请记住:mongoexport/mongoimport 和 mongodump/mongorestore
我希望这对某些人有用:P
excuse my english :P this happened to me when i did export with mongoexport and try to import with mongorestore :D my mistake! i had to use mongoimport.
Remember: mongoexport/mongoimport, and mongodump/mongorestore
i hope this is usefull to some one :P
我也遇到了这个问题。最后我发现这个问题是由于错误地使用了 mongodump 命令造成的。
I also encountered this problem. And finally I found that this problem was caused by using mongodump command in a wrong way.
最好使用 mongo Restore 而不是 mongodump
well use mongo restore instead of mongodump
我发现的任何地方都没有很好地解释这一点,但我找到了一个有效的解决方案。
我从 mongolab 下载了一个 .tgz 文件,其中包含 .bson 和 .json 文件。
我在我的 Mac 上创建了一个 ~/dump 文件夹。
我将所有这些 .bson 和 .json 文件复制到 ~/dump 文件夹中,因此我有 ~/dump/users.bson 。
我在终端中运行了这个命令:
它在几秒钟内导入。我确信还有其他方法/选择,但这对我有用。
This isn't explained very well anywhere that I found, but I found a solution that worked.
I downloaded a .tgz file from mongolab, which contained .bson and .json files in it.
I created a ~/dump folder on my mac.
I copied all those .bson and .json files into the ~/dump folder, so I had ~/dump/users.bson for example.
I ran this command in terminal:
It imported in seconds. I'm sure there are other ways/options, but this is what worked for me.