Database Manual / Self-Managed Deployments / Administration / Backup Methods / Restore Sharded Clusters

Schedule Backup Window for a Self-Managed Sharded Cluster为自我管理的分片集群安排备份窗口

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.但是,在从分片集群创建备份时,重要的是在进行备份时禁用平衡器,以确保块迁移不会影响备份过程捕获的备份内容。

Note

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还是安排在特定时间调用mongodump的任务。

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.使用“禁用平衡器”一节中概述的程序,您可以手动暂时停止平衡器进程。作为替代方案,您可以使用以下过程定义平衡窗口,以便在自动备份操作期间始终禁用平衡器。

Tip

To use mongodump and mongorestore as a backup strategy for sharded clusters, see Back Up a Self-Managed Sharded Cluster with a Database Dump.要使用mongodump和mongorestore作为分片集群的备份策略,请参阅使用数据库转储备份自管理分片集群

Sharded clusters can also use one of the following coordinated backup and restore processes, which maintain the atomicity guarantees of transactions across shards:分片集群还可以使用以下协调的备份和恢复过程之一,以维护跨分片事务的原子性保证:

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. Schedule your backup operation to run and complete outside of this time. 此操作将平衡器配置为在服务器时间上午6:00至晚上11:00之间运行。安排备份操作在此时间之外运行并完成。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.确保在平衡器运行时,备份可以在窗口外完成,并且平衡器可以有效地平衡分配给每个分片的窗口中的分片之间的集合。