简体   繁体   English

MongoDB副本设置为独立备份和还原

[英]MongoDB replica set to stand alone backup and restore

For development reasons, I need to backup a production replica set mongodb and restore it on a stand alone, different machine test instance. 出于开发原因,我需要备份生产副本集mongodb并将其还原到独立的其他机器测试实例上。

Some docs are talking about the opposite ( standalone 2 replica-set ), but I cannot find his downgrade/rollback way. 一些文档正在谈论相反的内容(独立的2个副本集),但是我找不到他的降级/回滚方式。

What's the way to go, in this case ? 在这种情况下,要走的路是什么?

No matter how many nodes you have in a replica set, each of them holds the same data. 无论副本集中有多少个节点,每个节点都保存相同的数据。

So getting the data is easy - just use mongodump (preferably against the secondary, for performance reasons) and then mongorestore into a new mongod for your development stand-alone system. 因此,获取数据非常容易-只需使用mongodump (出于性能方面的考虑,最好使用mongodump ),然后将mongorestore到用于开发独立系统的新mongod中。

mongodump does not pick up any replication related collections (they live in database called local ). mongodump 拿起任何复制有关的收藏品(他们住在数据库中调用local )。 If you end up taking a file system snapshot of a replica node rather than using mongodump , be sure to drop the local database when you restore the snapshot into your production stand-alone server and then restart mongod so that it will properly detect that it is not part of a replica set. 如果最终要拍摄副本节点的文件系统快照而不是使用mongodump ,请确保在将快照还原到生产独立服务器中时删除local数据库,然后重新启动mongod以便它将正确检测到它是属于副本集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM