简体   繁体   English

MongoDB:直接mongodump / restore与备份文件

[英]MongoDB: mongodump/restore vs. backup up files directly

I'm wondering about experiences people have had with MongoDB backups. 我想知道人们对MongoDB备份的经历。 Assuming a filesystem snapshot is not an option, what have your experiences been with mongodump/restore versus doing a write lock and backing up the files? 假设文件系统快照不是一个选项,那么您使用mongodump / restore与写入锁定和备份文件有什么关系? Have you run into any bugs with one method that caused you to switch? 您是否因为一种导致您切换的方法而遇到任何错误?

From the reading I've done so far, it seems like mongodump/restore has the advantage of being able to run it while the server is live, but I'm not sure how well it will scale. 从我到目前为止所做的阅读来看,似乎mongodump / restore具有能够在服务器运行时运行它的优势,但我不确定它将如何扩展。

Locking and copying files is only an option when you don't have heavy write load. 只有在没有大量写入负载时,才能锁定和复制文件。

mongodump can be run against live server. mongodump可以对实时服务器运行。 It will create some additional load, so don't do it on peak hours. 它会产生一些额外的负载,所以不要在高峰时段进行。 Also, it is advised to do it on a secondary node (if you don't use replica sets, you should). 此外,建议在辅助节点上执行此操作(如果您不使用副本集,则应该这样做)。

There are some complications when you have a DB so large that no single machine can hold it. 如果您的DB太大而没有一台机器可以容纳它,那么会出现一些复杂情况。 See this document . 请参阅此文档

Also, if you have replica set, you take down one of secondaries and copy its files directly. 此外,如果您有副本集,则会删除其中一个辅助副本并直接复制其文件。 See http://www.mongodb.org/display/DOCS/Backups : 请参阅http://www.mongodb.org/display/DOCS/Backups

A simple approach is just to stop the database, back up the data files, and resume. 一种简单的方法就是停止数据库,备份数据文件并恢复。 This is safe but of course requires downtime. 这是安全的,但当然需要停机时间。 This can be done on a secondary without requiring downtime, but you must ensure your oplog is large enough to cover the time the secondary is unavailable so that it can catch up again when you restart it. 这可以在辅助设备上完成而无需停机,但您必须确保您的oplog足够大,以覆盖辅助设备不可用的时间,以便在重新启动它时它可以再次赶上。

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

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