Backup, Restore, and Disaster Recovery

34
Senior Solutions Architect, 10gen James Kerr #MongoDBDays Backup, Restore, and Disaster Recovery

description

Come learn about the different ways to back up your single servers, replica sets, and sharded clusters.

Transcript of Backup, Restore, and Disaster Recovery

  • 1. #MongoDBDaysBackup, Restore, andDisaster RecoveryJames KerrSenior Solutions Architect, 10gen

2. Agenda DR Overview Backup Restore Replication Know your options 3. DR Overview 4. Disasters do happen 5. Sometimes they are our fault 6. DR vs. HA Dont confuse the two Distinctly different business requirements Technical solutions may converge 7. Recovery Point ObjectiveHow much data can you afford to lose? 8. Recovery Time ObjectiveHow long can you afford to be off-line? 9. DR Solution Tradeoffs Complexity increases as RPO approaches zero Complexity increases as RTO approaches zero 10. Backup 11. Whats the most importantthing about making backups?Restoring them 12. If you dont ensure thatyour backups can berestored, theres nopoint in doing backups 13. Backup Options mongodump Copy files Snapshot disk 14. mongodump$ mongodump --helpExport MongoDB data to BSON files.options: --helpproduce help message -v [ --verbose ] be more verbose (include multiple times for moreverbosity e.g. -vvvvv) --versionprint the programs version and exit -h [ --host ] argmongo host to connect to ( /s1,s2 for --port arg server port. Can also use --host hostname -u [ --username ] arg username -p [ --password ] arg password --dbpath arg directly access mongod database files inpath, instead of connecting to a mongodneeds to lock the data directory, so canif a mongod is currently accessing the s -d [ --db ] arg database to use -c [ --collection ] arg collection to use (some commands) -o [ --out ] arg (=dump)output directory or "-" for stdout -q [ --query ] arg json query --oplogUse oplog for point-in-time snapshotting 15. mongodump Dumps collections to *.bson files Mirrors your structure --db to dump a specific database --collection to dump a specific collection --oplog to record oplog while backing up --query/filter selective dump 16. File System Backups Must use journaling Copy /data/db files Snapshot Seriously, always use journaling 17. Ensure Consistency fsyncLock - flush and stop accepting writes Dont forget to fsyncUnlock 18. File System Backups - Pros andCons Entire database Backup files will be large Fastest way to create a backup Fastest way to restore a backup 19. Restore 20. mongorestore mongorestore --oplogReplay replay oplog to point-in-time 21. File System Restores Restore all databases Restore selected databases 22. Example 23. Backup Example: ShardedCluster1. Stop Balancer (and wait)2. or no balancing window3. Stop one config server (data R/O)4. Backup Data (shards, config)5. Restart config server6. Resume Balancer 24. Tips and Tricks bsondump inspect data at console lvm snapshot time/space trade-off Multi volume backup clean up snapshots 25. Replication 26. Replica SetsDisaster Avoidance 27. Avoid single point of failure 28. Replica Set Configuration > rs.conf() {"_id" : "replSetName","version" : 3,"members" : [{"_id" : 0,"host" : "myhost1.dnsname.com:27017"},{"_id" : 1,"host" : "myhost2.dnsname.com:27017"},{"_id" : 2,"host" : "myhost3.dnsname.com:27017"}]} 29. Avoid single point of failure inreplica sets 30. Deploy a Resilient Topology Redundancy Multiple Datacenters Multiple Regions Delayed Replication Can support HA and DR requirements HA by providing intra and inter datacenter failover DR by creating geographically dispersed copies of data DR by configuring a delay between the primary and one or more secondaries 31. Summary 32. Choose the Right Tool RPO on the order of seconds or minutes? Use Replication RPO on the order of hours? Maybe backups will suffice RTO on the order of seconds or minutes? Use Replication RTO on the order of hours or days? Use backups with warm/cold standby Need HA and DR? 33. Use Replica SetsDesign a topology tosupport both HA and DR 34. #MongoDBDaysThank YouJames KerrSenior Solutions Architect, 10gen