Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR
-
Upload
mongodb -
Category
Technology
-
view
252 -
download
0
description
Transcript of Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR
![Page 1: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/1.jpg)
Tugdual Grall (@tgrall) Alain Hélaïli (@AlainHelaili)
#MongoDBBasics @MongoDB
Construire une application avec MongoDB
Sauvegarde et disaster recovery
![Page 2: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/2.jpg)
2
• Résumé de l’épisode précédent
• Options de backup
• MMS
Agenda
![Page 3: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/3.jpg)
3
• Virtual Genius Bar– Utilisez la fenêtre de chat
– Tug & Alain dispo pendant, et après…
• MUGs à Paris, Toulouse, Bordeaux, Rennes, Lyon
• Groupes LinkedIn « MongoDB France » et « MongoDB » sur Viadeo
Q & A
@tgrall, [email protected] - @AlainHelaili, [email protected]
![Page 4: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/4.jpg)
Résumé de l’épisode précédent…
![Page 5: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/5.jpg)
5
Stratégies de déploiement
• Taille du “working set”
• Durabilité de la donnée• Replica Sets
• Tags
• Préférences de lecture
![Page 6: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/6.jpg)
6
Stratégies de déploiement
• Scalabilité horizontale
• Partitioning
• Distribution de la donnée
• Choix de la clé de sharding
• Sharding au moment opportun
![Page 7: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/7.jpg)
Options de backup
![Page 8: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/8.jpg)
8
• mongodump & mongorestore
• Copie du système de fichiers
• Snapshot du système de fichiers
• Replique cachée avec slaveDelay
• mongoimport & mongoexport n’est pas une solution de backup!
Outils & Approches
![Page 9: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/9.jpg)
9
• Crée un fichier de données bson plus un fichier de métadonneées JSON
• Fonctionne à travers le réseau ou directement sur le système de fichiers
Mongodump
>mongodump –h myhost -d cms -c articlesconnected to: myhost 2014-04-16T12:54:56.758+0100 DATABASE: cms to dump/cms2014-04-16T12:54:56.759+0100 cms.articles to dump/cms/articles.bson2014-04-16T12:54:56.816+0100 7 documents2014-04-16T12:54:56.817+0100 Metadata for cms.articles to dump/cms/articles.metadata.json
![Page 10: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/10.jpg)
10
• Back up réseau peut introduire des page faults
• Primaire et Secondaire identiques– A la latence près
• Préférer les secondaires – Eventuellement cachés
Où faire ce backup
mongodump
![Page 11: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/11.jpg)
11
• Inconsistence potentielle des données– mongodump lit les fichiers de manière séquentielle– Déplacement de document suite à update, objets liés…
• 3 options pour maintenir la consistence– Option –oplog de mongodump.– Verrouiller la DB pour empêcher les écritures– Isoler un noeud secondaire
Consistence des données
![Page 12: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/12.jpg)
12
--oplog & --oplogRestore
//Backup with –oplog//--oplog requires that you backup all databases / collections on the server>mongodump –h myhost –oplog
//To restore use mongorestore with the –oplogRelay switch for example>mongorestore –h myhost –oplogReplay ./cms/dump
![Page 13: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/13.jpg)
13
• Pour les primaires or secondaires– Déverse la données sur le disque et verrouille– db.fsyncLock() & db.fsyncUnlock()
Verrouiller la DB en écriture
//use fsync and lock from the mongo shell> db.fsyncLock(){
"info" : "now locked against writes, use db.fsyncUnlock() to unlock",
"seeAlso" : "http://dochub.mongodb.org/core/fsynccommand","ok" : 1
}//Perform file system backup… then unlock with… unlocked secondaries will catchup.> db.fsyncUnlock(){ "ok" : 1, "info" : "unlock completed" }
![Page 14: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/14.jpg)
14
• Copie des fichiers du dbpath (e.g. /data/db)– Utiliser fsync+lock
• Snpashot au niveau système de fichiers ou stockage bloc
– Par example LVM snapshots– Backup/restore le plus rapide
• Considérations– Journal, Consistence– Granularité (système complet ou DB individuelle)– Ops expertise– Stockage des snapshots et fichiers de données
Backup niveau système de fichiers
![Page 15: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/15.jpg)
15
• Arrêter le process balancer– Attendre la fin des migrations en cours
– Backup de chaque shard
– Ne pas oublier les config servers!
Backup d’un cluster shardé
//Switch the balancer off…mongos> sh.setBalancerState(false)
//Check to see if the balance is currently doing any migrations.mongos> sh.isBalancerRunning()
![Page 16: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/16.jpg)
MMS Backup
![Page 17: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/17.jpg)
17
• On premise
• In the cloud
What is MongoDB Management Service?
http://mms.mongodb.com
![Page 18: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/18.jpg)
18
MMS Backup Architecture
• Replication Data piped into MMS Backup
![Page 19: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/19.jpg)
19
• From the initial sync, we rebuild your data in our datacenters and take a snapshot
• We take snapshots every 6 hours
• Oplog is stored for 48 hours
How it works
![Page 20: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/20.jpg)
20
• Balancer paused every 6 hours
• A no-op token is inserted across all shards, mongoses and config servers
• Oplog applied to replica sets until point in which token was inserted
• Provides a consistent state of database across shards
Sharded Clusters
![Page 21: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/21.jpg)
Summary
![Page 22: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/22.jpg)
22
• Choisissez la meilleure stratégie pour vous
• Les snapshots sont rapides
• Pensez à l’intégrité
• MMS Backup sur le cloud ou sur site
Résumé
![Page 23: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/23.jpg)
23
– Monitoring– Tuning
– Outils
– Quelles sont les métriques importantes
Prochaine session – 3 juin
![Page 24: Webinar: Opérations pour votre application - Session 7 - Sauvegarde et DR](https://reader033.fdocuments.net/reader033/viewer/2022052905/55869312d8b42abd068b474c/html5/thumbnails/24.jpg)