Open source, high performance database Replication                                 Summer 2012                            ...
Why Have Replication?                        2
• High Availability (auto-failover)• Read Scaling (extra copies to read from)• Backups – Online, Delayed Copy (fat finger)...
Planned–   Hardware upgrade–   O/S or file-system tuning–   Relocation of data to new file-system / storage–   Software up...
• A cluster of N servers• All writes to primary• Reads can be to primary (default) or a  secondary• Any (one) node can be ...
Member 1                  Member 3                        Member 2• Replica Set is made up of 2 or more nodes             ...
Member 1              Member 3                    Member 2                    Primary• Election establishes the PRIMARY• D...
negotiate new                     master          Member 1                   Member 3                      Member 2       ...
negotiate new                     master                                     Member 3          Member 1                   ...
Member 3           Member 1                                    Primary                       Member 2                     ...
Member 3            Member 1                                  Primary                       Member 2• Replica Set re-estab...
Understanding automatic failover                               12
Primary    As long as a partitionSecondary            can see a majority            (>50%) of theSecondary   cluster, then...
Primary    66% of cluster visible.Secondary            Primary is elected  Failed   Node                                  ...
Secondary   33% of cluster visible.  Failed            Read only mode.   Node  Failed   Node                              ...
PrimarySecondarySecondary            16
Primary                        66% of cluster visible            Secondary                        Primary is elected Prima...
PrimarySecondary              Failed               Node              Failed               NodeSecondary            Seconda...
PrimarySecondarySecondarySecondary            19
Secondary                        50% of cluster visible Primary            Secondary   Read only mode.              Failed...
Primary              Failed               NodeSecondary              Failed               Node            SecondarySeconda...
Avoid single points of failure                            22
23
Primary  Secondary  SecondaryTop of rack switchRack falls over                     24
PrimarySecondarySecondaryLoss of internetBuilding burns dow                   25
San Francisco                 Primary                Secondary                Secondary   Dallas                          ...
San Francisco                                Primary    Priority 1                               Secondary   Priority 1   ...
San Francisco                New York    Primary                           Secondary   Dallas                  Secondary  ...
Fast recovery                29
PrimarySecondary             Is this a good idea?   Arbiter                                    30
1 PrimarySecondary    Arbiter              31
1             2 Primary       PrimarySecondary     Secondary    Arbiter       Arbiter                            32
1             2               3 Primary       Primary         Primary                                            Full Sync...
1 PrimarySecondarySecondary            34
1           2 Primary     PrimarySecondary   SecondarySecondary   Secondary                        35
1           2             3 Primary     Primary       PrimarySecondary   Secondary    Secondary   SecondarySecondary   Sec...
• Avoid single points of failure  – Separate racks  – Separate data centers• Avoid long recovery downtime  – Use journalin...
Q&A after this session                         38
Upcoming SlideShare
Loading in …5
×

Replication Online

827 views

Published on

Published in: Business, Education, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
827
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
23
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Change operations are written to the oplogThe oplog is a capped collection (fixed size)Must have enough space to allow new secondaries to catch up after copying from a primaryMust have enough space to cope with any applicable slaveDelaySecondaries query the primary's oplog and apply what they findAll replicas contain an oplog
  • Replication Online

    1. 1. Open source, high performance database Replication Summer 2012 1
    2. 2. Why Have Replication? 2
    3. 3. • High Availability (auto-failover)• Read Scaling (extra copies to read from)• Backups – Online, Delayed Copy (fat finger) – Point in Time (PiT) backups• Use (hidden) replica for secondary workload – Analytics – Data-processing – Integration with external systems 3
    4. 4. Planned– Hardware upgrade– O/S or file-system tuning– Relocation of data to new file-system / storage– Software upgradeUnplanned– Hardware failure– Data center failure– Region outage– Human error– Application corruption 4
    5. 5. • A cluster of N servers• All writes to primary• Reads can be to primary (default) or a secondary• Any (one) node can be primary• Consensus election of primary• Automatic failover• Automatic recovery 5
    6. 6. Member 1 Member 3 Member 2• Replica Set is made up of 2 or more nodes 6
    7. 7. Member 1 Member 3 Member 2 Primary• Election establishes the PRIMARY• Data replication from PRIMARY to SECONDARY 7
    8. 8. negotiate new master Member 1 Member 3 Member 2 DOWN• PRIMARY may fail• Automatic election of new PRIMARY if majority exists 8
    9. 9. negotiate new master Member 3 Member 1 Primary Member 2 DOWN• New PRIMARY elected• Replica Set re-established 9
    10. 10. Member 3 Member 1 Primary Member 2 Recovering• Automatic recovery 10
    11. 11. Member 3 Member 1 Primary Member 2• Replica Set re-established 11
    12. 12. Understanding automatic failover 12
    13. 13. Primary As long as a partitionSecondary can see a majority (>50%) of theSecondary cluster, then it will elect a primary. 13
    14. 14. Primary 66% of cluster visible.Secondary Primary is elected Failed Node 14
    15. 15. Secondary 33% of cluster visible. Failed Read only mode. Node Failed Node 15
    16. 16. PrimarySecondarySecondary 16
    17. 17. Primary 66% of cluster visible Secondary Primary is elected Primary FailedSecondary NodeSecondary 17
    18. 18. PrimarySecondary Failed Node Failed NodeSecondary Secondary 33% of cluster visible Read only mode. 18
    19. 19. PrimarySecondarySecondarySecondary 19
    20. 20. Secondary 50% of cluster visible Primary Secondary Read only mode. FailedSecondary Node Failed NodeSecondarySecondary 20
    21. 21. Primary Failed NodeSecondary Failed Node SecondarySecondary 50% of cluster visible Secondary Read only mode.Secondary 21
    22. 22. Avoid single points of failure 22
    23. 23. 23
    24. 24. Primary Secondary SecondaryTop of rack switchRack falls over 24
    25. 25. PrimarySecondarySecondaryLoss of internetBuilding burns dow 25
    26. 26. San Francisco Primary Secondary Secondary Dallas 26
    27. 27. San Francisco Primary Priority 1 Secondary Priority 1 Secondary Priority 0 Dallas Disaster recover data center. Will never become primary automatically. 27
    28. 28. San Francisco New York Primary Secondary Dallas Secondary 28
    29. 29. Fast recovery 29
    30. 30. PrimarySecondary Is this a good idea? Arbiter 30
    31. 31. 1 PrimarySecondary Arbiter 31
    32. 32. 1 2 Primary PrimarySecondary Secondary Arbiter Arbiter 32
    33. 33. 1 2 3 Primary Primary Primary Full SyncSecondary Secondary Secondary Secondary Arbiter Arbiter Arbiter Uh oh. Full Sync is going to use a lot of resources on the primary. So I may have downtime or degraded performance 33
    34. 34. 1 PrimarySecondarySecondary 34
    35. 35. 1 2 Primary PrimarySecondary SecondarySecondary Secondary 35
    36. 36. 1 2 3 Primary Primary PrimarySecondary Secondary Secondary SecondarySecondary Secondary Secondary Full Sync Sync can happen from secondary, which will not impact traffic on Primary. 36
    37. 37. • Avoid single points of failure – Separate racks – Separate data centers• Avoid long recovery downtime – Use journaling – Use 3+ replicas• Keep your actives close – Use priority to control where failovers happen 37
    38. 38. Q&A after this session 38

    ×