简体   繁体   English

Mongodump使用--oplog进行热备份

[英]Mongodump with --oplog for hot backup

I'm looking for the right way to do a Mongodb backup on a replica set (non-sharded). 我正在寻找在副本集上进行Mongodb备份的正确方法(非分片)。

By reading the Mongodb documentation, I understand that a "mongodump --oplog" should be enough, even on a replica (slave) server. 通过阅读Mongodb文档,我知道“mongodump --oplog”应该足够了,即使在副本(从属)服务器上也是如此。

From the mongodb / mongodump documentation : 从mongodb / mongodump文档:

--oplog Use this option to ensure that mongodump creates a dump of the database that includes an oplog, to create a point-in-time snapshot of the state of a mongod instance. --oplog使用此选项可确保mongodump创建包含oplog的数据库转储,以创建mongod实例状态的时间点快照。 To restore to a specific point-in-time backup, use the output created with this option in conjunction with mongorestore --oplogReplay. 要还原到特定的时间点备份,请将使用此选项创建的输出与mongorestore --oplogReplay结合使用。

Without --oplog, if there are write operations during the dump operation, the dump will not reflect a single moment in time. 如果没有--oplog,如果在转储操作期间存在写入操作,则转储将不会反映单个时刻。 Changes made to the database during the update process can affect the output of the backup 在更新过程中对数据库所做的更改可能会影响备份的输出

I'm still having a very hard time to understand how Mongodb can backup and keep writing on the database and make a consistent backup, even with --oplog. 我仍然很难理解Mongodb如何备份并继续写入数据库并进行一致的备份,即使使用--oplog也是如此。 Should I lock my collections first or is it safe to run "mongodump --oplog ? Is there anything else I should know about? 我应该先锁定我的收藏品还是安全地运行“mongodump --oplog?还有什么我应该知道的吗?

Thanks. 谢谢。

The following document explains how mongodump with –oplog option works to create a point in time backup. 以下文档说明了mongodump with -oplog选项如何用于创建时间点备份。

http://docs.mongodb.org/manual/tutorial/backup-databases-with-binary-database-dumps/ http://docs.mongodb.org/manual/tutorial/backup-databases-with-binary-database-dumps/

However, using mongodump and mongorestore to back up and restore MongodDB can be slow. 但是,使用mongodump和mongorestore来备份和恢复MongodDB可能会很慢。 If file system snapshot is an option, you may want to consider using snapshot for MongoDB backup. 如果文件系统快照是一个选项,您可能需要考虑使用快照进行MongoDB备份。 Information from the following link details two snapshot options for performing hot backup of MongoDB. 以下链接中的信息详细说明了用于执行MongoDB热备份的两个快照选项。

http://docs.mongodb.org/manual/tutorial/backup-databases-with-filesystem-snapshots/ http://docs.mongodb.org/manual/tutorial/backup-databases-with-filesystem-snapshots/

You can also look into MongoDB backup service. 您还可以查看MongoDB备份服务。

http://www.10gen.com/products/mongodb-backup-service http://www.10gen.com/products/mongodb-backup-service

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

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