1.

The db.collection.bulkWrite() provides the ability for bulk CRUD operations. During execution, if there is any error from an operation, do the remaining operations get processed?

Answer»

To backup sharded cluster we need to TAKE the backup for config database and individual shards.

  • Disable the balancer

First, we would need to disable the balancer from mongos. If we do not stop the balancer, the backup could duplicate data or OMIT data as CHUNKS migrate while recording backups.

USE config sh.stopBalancer()
  • Lock one secondary member of each replica set

For each shard replica set in the sharded cluster, connect a mongo shell to the secondary member’s mongod instance and run db.fsyncLock().

db.fsyncLock()
  • Lock config server replica set secondary

Connect to secondary of config server replica set and run

db.fsyncLock()
  • Backup one config server and then unlock the member

Now we will backup locked config secondary member. We are using mongodump for backup but we can also use any other method LIKE cp or rsync etc.

Once the backup is taken, we can unlock the member so that it starts getting oplog from config primary.

mongodump --oplog db.fsyncUnlock()
  • Back up a replica set member for each shard

Now we will backup locked member of each shard. We are using mongodump for backup but we can also use any other method like cp or rsync etc.

Once the backup is taken, we can unlock the member so that it starts getting oplog from shard primary.

mongodump --oplog db.fsyncUnlock()
  • Re-enable the balancer process

Once we have the backup from config and each shard we will enable the balancer by connecting to config database.

use config sh.setBalancerState(true)


Discussion

No Comment Found