发布于 2015-09-14 14:55:58 | 135 次阅读 | 评论: 0 | 来源: 网络整理

Overview

This document describes a procure for taking a backup of all components of a sharded cluster. This procedure uses file system snapshots to capture a copy of the mongod instance. An alternate procedure that uses mongodump to create binary database dumps when file-system snapshots are not available. See 创建带数据库转储的片式集群的备份 for the alternate procedure.

See Sharded Cluster Backup Considerations for a full higher level overview backing up a sharded cluster as well as links to other tutorials that provide alternate procedures.

重要

To capture a point-in-time backup from a sharded cluster you must stop all writes to the cluster. On a running production system, you can only capture an approximation of point-in-time snapshot.

Procedure

In this procedure, you will stop the cluster balancer and take a backup up of the config database, and then take backups of each shard in the cluster using a file-system snapshot tool. If you need an exact moment-in-time snapshot of the system, you will need to stop all application writes before taking the filesystem snapshots; otherwise the snapshot will only approximate a moment of in time.

For approximate point-in-time snapshots, you can improve the quality of the backup while minimizing impact on the cluster by taking the backup from a secondary member of the replica set that provides each shard.

  1. Disable the balancer process that equalizes the distribution of data among the shards. To disable the balancer, use the sh.stopBalancer() method in the mongo shell, and see the Disable the Balancer procedure.

    警告

    It is essential that you stop the balancer before creating backups. If the balancer remains active, your resulting backups could have duplicate data or miss some data, as chunks migrate while recording backups.

  2. Lock one member of each replica set in each shard so that your backups reflect the state of your database at the nearest possible approximation of a single moment in time. Lock these mongod instances in as short of an interval as possible.

    To lock or freeze a sharded cluster, you must:

    • use the db.fsyncLock() method in the mongo shell connected to a single secondary member of the replica set that provides shard mongod instance.
    • Shutdown one of the config servers, to prevent all metadata changes during the backup process.
  3. Use mongodump to backup one of the config servers. This backs up the cluster’s metadata. You only need to back up one config server, as they all hold the same data.

    Issue this command against one of the config mongod instances or via the mongos:

    mongodump --db config
    
  4. Back up the replica set members of the shards that you locked. You may back up the shards in parallel. For each shard, create a snapshot. Use the procedures in 使用文件系统快照备份和恢复MongoDB数据库.

  5. Unlock all locked replica set members of each shard using the db.fsyncUnlock() method in the mongo shell.

  6. Restore the balancer with the sh.startBalancer() method according to the Disable the Balancer procedure.

    Use the following command sequence when connected to the mongos with the mongo shell:

    use config
    sh.startBalancer()
    
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务