Schedule Backup Window for Sharded Clusters为分片群集安排备份窗口
On this page本页内容
Overview概述
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.但是,在从分片集群创建备份时,重要的是在进行备份时禁用平衡器,以确保区块迁移不会影响备份过程捕获的备份内容。
Disabling the balancer is only necessary when manually taking backups, either by calling 只有在手动进行备份时才需要禁用平衡器,无论是通过调用mongodump
or scheduling a task that calls mongodump
at a specific time.mongodump
还是安排在特定时间调用mongoump
的任务。
You do not have to disable the balancer when using coordinated backup and restore processes:在使用协调的备份和恢复过程时,您不必禁用平衡器:
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.使用禁用平衡器一节中概述的过程,您可以手动暂时停止平衡器进程。或者,您可以使用以下过程定义一个平衡窗口,以便在自动备份操作期间始终禁用平衡器。
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
不能作为4.2+正在进行分片事务的分片集群的备份策略的一部分,因为使用mongodumps
创建的备份不能维护跨分片事务原子性的保证。
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多个分片集群,请使用以下协调的备份和恢复过程之一,这些过程确实维护了跨分片的事务的原子性保证:
Procedure过程
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点到晚上11点之间运行。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.确保在平衡器运行时,备份可以在窗口外完成,并且平衡器可以在分配给每个平衡器的窗口中有效地平衡分片之间的集合。