从独立到副本集的mongorestore [英] mongorestore from standalone to replicaset

查看:149
本文介绍了从独立到副本集的mongorestore的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经转储了一个在默认端口上运行的独立mongo数据库(14 Gb大),如下所示:

I have dumped a standalone mongo database (14Gb big) running on the default port as follows:

mongodump --username <username> --password <password> --db <dbname>

,并且我尝试使用以下命令将其还原到副本集:

and I am trying to restore it onto a replica set with the following:

mongorestore --host myReplSet/127.0.0.1:27020 --drop --username <username> --password <password>

还原似乎可以正常工作(大约需要一分钟,并且输出看起来不错),创建了数据库并创建了所有集合,但是集合中没有数据,它们都为空.我在做什么错了?

The restore seems to work (it takes a minute or so and the output looks good) the database is created and all the collections are created but there is no data in the collections, they are all empty. What am I doing wrong?

对于它的价值,本地数据库显示它的大小为10 Gb(我不确定还原之前它有多大)

For what it is worth, the local database is showing that it is 10 Gb big (I am not sure how big it was before the restore)

推荐答案

如果有人面临相同的问题.我使用了一个副本集,并尝试执行Op的命令.即

If anybody is facing the same issue. I used a replica set, and tried to do the Op's command. i.e

mongorestore --host myReplSet/mongo0.example.com:27020,mongo1.example.com:27012 --db <dbname> <folder_location>

相反,只需转到主服务器并执行此操作

Instead just go to the primary server and do this

mongorestore --port <if running on port other than 27017> --db <dbname> <location of dump>

这对我有用,可能的解释可能是,每当我写入主数据库时,它都会自动复制到我的辅助数据库中.因此,无需提供任何副本集地址.如果您不使用辅助工具,则不确定是否可以编写辅助工具.也许其他人可以对此有所了解.

This works for me, A possible explanation could be that whenever I write into the primary database, it is automatically copied over to my secondary databases. Hence no need to give any replica set address. This might work if you write in a secondary, I am not sure, haven't tried it. Maybe somebody else can throw a light on it.

这篇关于从独立到副本集的mongorestore的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆