replica sets
play

Replica Sets Painless scaling and High Availability (HA) Viktor - PowerPoint PPT Presentation

Replica Sets Painless scaling and High Availability (HA) Viktor Petersson @vpetersson Who am I? { name : Viktor Petersson, description : [ geek, entrepreneur ], founder_of : wireload, twitter : @vpetersson,


  1. Replica Sets Painless scaling and High Availability (HA) Viktor Petersson @vpetersson

  2. Who am I? { name : ‘Viktor Petersson’, description : [ ‘geek’, ‘entrepreneur’ ], founder_of : ‘wireload’, twitter : ‘@vpetersson’, email : ‘vpetersson@wireload.net’, } @vpetersson

  3. What is MongoDB? • Key-value store • Schemas less • Distributed file system (GridFS) • Built-in Map/Reduce • Built to scale @vpetersson

  4. MongoDB 101 Database structure (simplified) Relational Database MongoDB Database Database Table Collection Row Document @vpetersson

  5. MongoDB 101 Node types Relational Database MongoDB Master Primary Slave Secondary Arbiter (Hidden) @vpetersson

  6. What are Replica Sets and why should I care? @vpetersson

  7. Typical failover with relational databases (two servers, can lose one) Normal Degraded Failover IP Failover IP Master Slave Master Slave Master @vpetersson

  8. More complex failover with relational databases (four servers, can lose one of each kind) Degraded Normal Failover IP Failover IP Proxies Database servers @vpetersson

  9. Failover with MongoDB (three servers, can lose two) Normal Degraded Driver Driver Primary Secondary Secondary Primary Secondary Secondary Primary @vpetersson

  10. Automatic recovery Down -> Recovering Recovering -> Secondary Driver Driver Primary Secondary Secondary Primary Secondary Secondary Recovering Primary Primary Secondary @vpetersson

  11. Real life example: Taking down the primary for maintenance. No dropped connections. Primary Secondary @vpetersson

  12. Creating a Replica Set is dead simple. All it takes is three servers (s0, s1, s2) and three commands ¹ . $ mongo > rs.initiate() > rs.add(‘s1’) > rs.add(‘s2’) @vpetersson 1. After adding “replSet=myRepSet” and “rest = true” to mongo.conf

  13. Live demo! 3 servers with 1 client @vpetersson

  14. Election 1. Most up to date 2. Highest priority 3. Less than 10s behind Primary @vpetersson

  15. Configure node priority $ cfg = rs.conf() $ cfg.members[x].priority = n $ rs.reconfig(cfg) x = Member id, n = Priority (0 - 100), default is 1. @vpetersson

  16. Leverage your secondary-nodes Read preference • Primary (default) • Secondary • Secondary_only @vpetersson Warning: Secondaries may be out-of-date.

  17. What happens when I’ve outgrown my Replica Set? @vpetersson

  18. Sharding mongos repset0 repset1 repsetN @vpetersson

  19. Useful commands View server status $ db.serverStatus() View the replication status $ rs.status() Step down as Primary $ rs.stepDown(n) @vpetersson

  20. What’s new in MongoDB 2.2? (released yesterday) • Improved location awareness • Improved concurrent capacity • TTL collections Full release notes: @vpetersson http://docs.mongodb.org/manual/release-notes/2.2/

  21. Summary • Replica Sets are extremely easy to set up • Doesn’t require failover IPs or custom scripts • Minimal maintenance • Built to scale @vpetersson

  22. Questions? @vpetersson

  23. Thanks to @vpetersson

  24. Contact me! email: info@viktorpetersson.com www: viktorpetersson.com twitter: @vpetersson This deck will be available at ViktorPetersson.com. Also visit WireLoad.net YippieMove.com @vpetersson

  25. Useful resources • MongoDB: GridFS, sharding and deploying in the cloud (http://goo.gl/1QAV1) • MongoDB Replica Set (http://goo.gl/D2pkq) • 10gen (http://goo.gl/3m4Kn) @vpetersson

Recommend


More recommend