简体   繁体   English

mongodump会锁定数据库吗?

[英]Does mongodump lock the database?

我正在为mongo设置备份策略,只是想知道mongodump是否在执行数据库转储之前锁定了数据库?

I found this on mongo's google group : 我在mongo的谷歌小组上发现了这个:

Mongodump does a simple query on the live system and does not require a shutdown. Mongodump对实时系统进行简单查询,不需要关机。 Like all queries it requires a read lock while running but doesn't not block any more than normal queries. 与所有查询一样,它在运行时需要读锁定,但不会阻止任何常规查询。

If you have a replica set you will probably want to use the --oplog flag to do your backups. 如果您有副本集,则可能需要使用--oplog标志来执行备份。

See the docs for more information 有关更多信息,请参阅文档

Additionally I found this previously asked question 另外我发现了这个先前提出的问题

Excerpt from above question 摘自上述问题

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

Mongdump does not lock the db. Mongdump不会锁定数据库。 It means other read and write operations will continue normally. 这意味着其他读写操作将继续正常进行。

Actually, both mongodump and mongorestore are non-blocking. 实际上,mongodump和mongorestore都是非阻塞的。 So if you want to mongodump mongorestore a db then its your responsibility to make sure that it is really a desired snapshot backup/restore. 因此,如果你想mongodump mongorestore一个db,那么你有责任确保它真的是一个理想的快照备份/恢复。 To do this, you must stop all other write operations while taking/restoring backups with mongodump/mongorestore. 为此,您必须在使用mongodump / mongorestore获取/恢复备份时停止所有其他写入操作。 If you are running a sharded environment then its recommended you stop the balancer also. 如果您正在运行分片环境,那么建议您也停止平衡器。

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

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