Mongosv 2011 - Replication

1,380 views

Published on

Replication talk from MongoSV 2011

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,380
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
20
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Mongosv 2011 - Replication

  1. 1. ReplicationJared Rosoff (@forjared)
  2. 2. Overview• Intro to replica sets• The oplog• Durability and Consistency• Common deployment scenarios• Advanced configuration
  3. 3. INTRO TO REPLICA SETS
  4. 4. Replica Sets Write Primary Read AsynchronousDriver Secondary Replication Read Secondary Read
  5. 5. Replica Sets PrimaryDriver Secondary Read Secondary Read
  6. 6. Replica Sets Primary Write AutomaticDriver Primary Leader Election Read Secondary Read
  7. 7. Replica Sets Secondary Read WriteDriver Primary Read Secondary Read
  8. 8. CONSISTENCY ANDDURABILITY
  9. 9. Strong Consistency WriteDriver Primary Read Secondary Secondary
  10. 10. Eventual Consistency Write PrimaryDriver Secondary Read Secondary Read
  11. 11. Durability• Fire and forget• Wait for error• Wait for fsync• Wait for journal sync• Wait for replication
  12. 12. Fire and forgetDriver Primary write apply in memory
  13. 13. Get last errorDriver Primary write getLastError apply in memory
  14. 14. Wait for Journal SyncDriver Primary write getLastError apply in memory j:true Write to journal
  15. 15. Wait for fsyncDriver Primary write getLastError apply in memory fsync:true fsync
  16. 16. Wait for replicationDriver Primary Secondary write getLastError apply in memory w:2 replicate
  17. 17. Write Concern OptionsValue Meaning<n:integer> Replicate to N members of replica set“majority” Replicate to a majority of replica set members<m:modeName> Use custom error mode name
  18. 18. Tagging { _id: “someSet”, members: [ { _id:0, host:”A”, tags: { dc: “ny”}}, { _id:1, host:”B”, tags: { dc: “ny”}}, { _id:2, host:”C”, tags: { dc: “sf”}}, { _id:3, host:”D”, tags: { dc: “sf”}}, { _id:4, host:”E”, tags: { dc: “cloud”}}, settings: {These are the getLastErrorModes: {modes you can veryImportant: { dc: 3 }, use in write sortOfImportant: { dc: 2 } concern } } }
  19. 19. REPLICA SET OPTIONS
  20. 20. Priorities• Between 0..1000• Highest member that is up to date wins – Up to date == within 10 seconds of primary• If a higher priority member catches up, it will force election and win Primary Secondary Secondary priority = 100 priority = 50 priority = 20
  21. 21. Slave Delay• Lags behind master by configurable time delay• Automatically hidden from clients• Protects against operator errors – Accidentally delete database – Application corrupts data
  22. 22. Arbiters• Vote in elections• Don’t store a copy of data• Use as tie breaker
  23. 23. COMMON DEPLOYMENTSCENARIOS
  24. 24. Typical Data CenterPrimary Secondary Secondary
  25. 25. Backup Node Data CenterPrimary Secondary Secondary hidden = true backups
  26. 26. Disaster Recovery Active Data Center Standby Data CenterPrimary Secondary Secondarypriority = 1 priority = 1
  27. 27. Multi Data CenterWest Coast DC Central DC East Coast DCSecondary Primary Secondary priority = 1

×