On this page本页内容
In a sharded cluster, the balancer process is responsible for distributing sharded data around the cluster, so that each shard has roughly the same amount of data.在分片集群中,均衡器进程负责在集群周围分发分片数据,以便每个分片拥有大致相同的数据量。
However, when creating backups from a sharded cluster it is important that you disable the balancer while taking backups to ensure that no chunk migrations affect the content of the backup captured by the backup procedure. 但是,在从分片群集创建备份时,重要的是在进行备份时禁用平衡器,以确保块迁移不会影响备份过程捕获的备份内容。Using the procedure outlined in the section Disable the Balancer you can manually stop the balancer process temporarily. 使用禁用平衡器一节中概述的步骤,可以暂时手动停止平衡器进程。As an alternative, you can use the following procedure to define a balancing window so that the balancer is always disabled during your automated backup operation.作为替代方案,您可以使用以下过程定义平衡窗口,以便在自动备份操作期间始终禁用平衡器。
对于正在进行分片事务的4.2+分片集群,mongodump
and mongorestore
cannot be part of a backup strategy for 4.2+ sharded clusters that have sharded transactions in progress, as backups created with mongodump
do not maintain the atomicity guarantees of transactions across shards.mongodump
和mongorestore
不能作为备份策略的一部分,因为使用mongodump
创建的备份无法维持跨分片事务的原子性保证。
For 4.2+ sharded clusters with in-progress sharded transactions, use one of the following coordinated backup and restore processes which do maintain the atomicity guarantees of transactions across shards:对于具有进行中分片事务的4.2+分片群集,请使用以下协调的备份和恢复过程之一,这些过程确实维护了跨分片事务的原子性保证:
If you have an automated backup schedule, you can disable all balancing operations for a period of time. 如果有自动备份计划,可以在一段时间内禁用所有平衡操作。For instance, consider the following command:例如,考虑以下命令:
use config db.settings.updateOne( { _id : "balancer" }, { $set : { activeWindow : { start : "06:00", stop : "23:00" } } }, true )
This operation configures the balancer to run between 6:00am and 11:00pm, server time. 此操作将平衡器配置为在服务器时间上午6:00到晚上11:00之间运行。Schedule your backup operation to run and complete outside of this time. 安排备份操作在此时间之外运行和完成。Ensure that the backup can complete outside the window when the balancer is running and that the balancer can effectively balance the collection among the shards in the window allotted to each.确保在平衡器运行时,备份可以在窗口外完成,并且平衡器可以在分配给每个用户的窗口中的分片之间有效地平衡集合。