MongoDB Replication (Dwight Merriman)
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

MongoDB Replication (Dwight Merriman)

on

  • 9,692 views

 

Statistics

Views

Total Views
9,692
Views on SlideShare
9,126
Embed Views
566

Actions

Likes
19
Downloads
168
Comments
1

12 Embeds 566

http://www.slideshare.net 274
http://nosql.mypopescu.com 191
http://www.10gen.com 51
http://mongospanish.blogspot.com 21
http://blog.chinaunix.net 12
http://lanyrd.com 9
http://blogold.chinaunix.net 3
http://www.mongodb.org 1
http://static.slidesharecdn.com 1
http://www.hanrss.com 1
http://www.netvibes.com 1
http://www.cublog.cn 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

MongoDB Replication (Dwight Merriman) Presentation Transcript

  • 1. Replication and MongoDB
    Dwight Merriman (@dmerr)
    10gen
  • 2. Basics
    A bit like MySQL replication
    Asynchronous master/slave
    Let’s try it…
  • 3. Command Line
    --master [--oplogSize <MB>]
    --slave –source <host> [--only <db>]
  • 4. The local db
    Doesn’t replicate
    On master:
    local.oplog.$main
    local.slaves
    On slave:
    local.sources
    > use local
    > db.sources.find()
  • 5. Administration
    > // master
    > use local
    > db.printReplicationInfo()
    > db.slaves.find()
    > db.oplog.$main.findOne()
    // slave
    > use local
    > db.printSlaveReplicationInfo()
  • 6. Topologies
    M->S
    M->S
    ->S
    ->S
    M->S
    M-/
    M<->M *very restrictive
  • 7. Replica Pairs
    --pairwith
  • 8. Replica Pairs
    Replica Sets
    • A cluster of N servers
    • 9. Any (one) node can be primary
    • 10. Consensus election of primary
    • 11. Automatic failover
    • 12. Automatic recovery
    • 13. All writes to primary
    • 14. Reads can be to primary or a second
    • 15. Rack and data center aware
    • 16. ETA: v1.6 July 2010 (“stable”)
  • Replica Sets – Design Concepts
    A write is only truly committed once it has replicated to a majority of servers in the set.  (We can wait for confirmation for this though, with getLastError.)
    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).
  • 17. A Set
    Member 1
    Member 3
    Member 2
  • 18. A Set
    Member 1
    Member 3
    Member 2
    PRIMARY
  • 19. A Set
    Member 1
    Member 3
    PRIMARY
    Member 2
    DOWN
  • 20. A Set
    Member 1
    Member 3
    PRIMARY
    Member 2
    RECOVER-ING
  • 21. A Set
    Member 1
    Member 3
    PRIMARY
    Member 2
  • 22. Configuration
    {
    _id : <setname>,
    members: [
    {
    _id : <ordinal>,
    host : <hostname[:port]>,
    [, priority: <priority>]
    [, arbiterOnly : true]
    [, votes : n]
    }
    , ...
    ],
    settings: {
    [heartbeatSleep : <seconds>]
    [, heartbeatTimeout : <seconds>]
    [, heartbeatConnRetries : <n>]
    [, getLastErrorDefaults: <lasterrdefaults>]
    }
    }
  • 23. Initiation
    > cfg = {
    ... _id : "acme_a",
    ... members : [
    ... { _id : 0, host : "sf1.acme.com" },
    ... { _id : 1, host : "sf2.acme.com" },
    ... { _id : 2, host : "sf3.acme.com" } ] }
    > use admin
    > db.runCommand({replSetInitiate:cfg})
  • 24. Commands
    { isMaster : 1 }
    Checks if the node to which we are connecting is currently primary. Most drivers do this check automatically and then send requires to the current primary.
    { replSetGetStatus : 1 }
    Status information on the replica set from this node's point of view.
    http://localhost:28017/replSetGetStatus?text
    { replSetInitiate : <config> }
    Initiate a replica set.
    { replSetFreeze : <bool> }
    Freezing a replica set prevents failovers from occurring. This can be useful during maintenance.
  • 25. Set Member Types
    Normal
    DR (priority < 1.0)
    Passive (priority == 0)
    Arbiter (no data, but can vote)
  • 26. With Sharding
  • 27. Docs: http://www.mongodb.org/display/DOCS/Replica+Sets
    Questions?
    Email dwight@10gen.com if you would like
    to be a replica set beta tester.
    10gen is hiring.