InterviewSolution
| 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.
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()
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()
Connect to secondary of config server replica set and run db.fsyncLock()
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()
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()
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) |
|