• Like

MongoDB Replica Sets

  • 14,802 views
Uploaded on

10gen CEO Dwight Merriman presents at the NoSQL meetup in NYC

10gen CEO Dwight Merriman presents at the NoSQL meetup in NYC

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
14,802
On Slideshare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
94
Comments
0
Likes
8

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Replica Sets (MongoDB v1.6) Dwight Merriman (@dmerr) 10gen dmerr.tumblr.com
  • 2. Basics
    • MongoDB replication is a bit like MySQL replication
      • Asynchronous master/slave at its core
    • Variations:
      • Master / slave
      • Replica Pairs (deprecated – use replica sets)
      • Replica Sets (today’s topic)
  • 3. Replica Sets
    • A cluster of N servers
    • Any (one) node can be primary
    • Consensus election of primary
    • Automatic failover
    • Automatic recovery
    • All writes to primary
    • Reads can be to primary (default) or a secondary
    • v1.6
  • 4. With Sharding
  • 5. Replica Sets – Design Concepts
    • A write is only truly committed once it has replicated to a majority of servers in the set. 
        • Thus, for important writes, the developer waits for confirmation of the cluster-wide commit with the getLastError command.
    • Writes which are committed at the master of the set may be visible before the true cluster-wide commit has occurred.  This property, which is more relaxed than some traditional products, makes theoretically achievable performance and availability higher.
    • On a failover, if there is data which has not replicated form the primary, the data is dropped (see #1).
  • 6. A Set Member 1 Member 2 Member 3
  • 7. A Set Member 1 Member 2 PRIMARY Member 3
  • 8. A Set Member 1 Member 2 DOWN Member 3 PRIMARY negotiate new master
  • 9. A Set Member 1 Member 2 DOWN Member 3 PRIMARY
  • 10. A Set Member 1 Member 2 RECOVER-ING Member 3 PRIMARY
  • 11. A Set Member 1 Member 2 Member 3 PRIMARY
  • 12. Configuration
    • {
    • _id : <setname>,
    • members: [
    • {
    • _id : <ordinal>,
    • host : <hostname[:port]>,
    • [, priority: <priority>]
    • [, arbiterOnly : true]
    • [, votes : n]
    • [, slaveDelay : s] [, hidden : true ]
    • }
    • , ...
    • ],
    • settings: {
    • [getLastErrorDefaults: <lasterrdefaults>]
    • [, heartbeatSleep : <seconds>]
    • [, heartbeatTimeout : <seconds>]
    • [, heartbeatConnRetries : <n>]
    • }
    • }
  • 13. Initiation
    • > cfg = {
    • ... _id : &quot;acme_a&quot;,
    • ... members : [
    • ... { _id : 0, host : &quot;sf1.acme.com&quot; },
    • ... { _id : 1, host : &quot;sf2.acme.com&quot; },
    • ... { _id : 2, host : &quot;sf3.acme.com&quot; } ] }
    • > use admin
    • > db.runCommand({replSetInitiate:cfg})
  • 14. Set Member Types
    • Normal (priority == 1)
    • Passive (priority == 0)
    • DR (priority < 1.0) (coming soon)
    • Arbiter (no data, but can vote)
  • 15. Commands
    • { isMaster : 1 }
    • { replSetGetStatus : 1 }
    • { replSetInitiate : <config> }
    • { replSetStepDown : true }
    • { replSetReconfig : <config> }
    • > rs.help()
  • 16. Demo
  • 17. Questions?
    • Contact 10gen for on-site advisory sessions on MongoDB architecture, schema design, performance tuning, training…
    • [email_address]
    • irc://irc.freenode.net/#mongodb
    • http://groups.google.com/group/mongodb-user