SlideShare una empresa de Scribd logo
1 de 39
Descargar para leer sin conexión
Sridhar Nanjundeswaran, 10gen
           sridhar@10gen.com
                   @snanjund
              October 21, 2012

          1
• Introduction to Replica Sets
• Developing with Replica Sets
• Operational Considerations
• Miscellaneous




                      2
Introduction to Replica Sets




                            Why?
                        What is it?
             Configuration Options
• How many have faced node failures?
• How many have been woken to do fail overs?
• How many have experienced issues due to n/w
  latency?
• Different uses for data
  – Normal processing
  – Simple analytics




                         4
Node 1            Node 2




         Node 3




            5
Node 1                          Node 2
Secondary           Heartbeat   Secondary



                    Node 3
                    Primary         Replication
      Replication



                          6
Primary Election
 Node 1                         Node 2
Secondary    Heartbeat         Secondary



              Node 3
              Primary



                     7
Replication




 Node 1                   Node 2
Secondary   Heartbeat     Primary



             Node 3
             Primary



                   8
Replication



 Node 1                   Node 2
Secondary   Heartbeat     Primary



             Node 3
            Secondary        Replication



                   9
Node 1                         Node 2
Secondary           Heartbeat   Arbiterr



                    Node 3
                    Primary
      Replication



                          10
> conf = {
   _id : "mySet",
   members : [
      {_id : 0, host : "A”, priority : 3},
      {_id : 1, host : "B", priority : 2},
      {_id : 2, host : "C”},
      {_id : 3, host : "D", hidden : true},
      {_id : 4, host : "E", hidden : true, slaveDelay : 3600}
    ]
}

> rs.initiate(conf)



                                  11
> conf = {
   _id : "mySet”,                                   Primary DC
   members : [
      {_id : 0, host : "A”, priority : 3},
      {_id : 1, host : "B", priority : 2},
      {_id : 2, host : "C”},
      {_id : 3, host : "D", hidden : true},
      {_id : 4, host : "E", hidden : true, slaveDelay : 3600}
    ]
}

> rs.initiate(conf)



                                  12
> conf = {
   _id : "mySet”,
   members : [
      {_id : 0, host : "A”, priority : 3},
      {_id : 1, host : "B", priority : 2},          Secondary DC
      {_id : 2, host : "C”},                        Default priority = 1
      {_id : 3, host : "D", hidden : true},
      {_id : 4, host : "E", hidden : true, slaveDelay : 3600}
    ]
}

> rs.initiate(conf)



                                   13
> conf = {
   _id : "mySet”,
                                                    Analytics node
   members : [
      {_id : 0, host : "A”, priority : 3},
      {_id : 1, host : "B", priority : 2},
      {_id : 2, host : "C”},
      {_id : 3, host : "D", hidden : true},
      {_id : 4, host : "E", hidden : true, slaveDelay : 3600}
    ]
}

> rs.initiate(conf)



                                  14
> conf = {
   _id : "mySet”,
   members : [
      {_id : 0, host : "A”, priority : 3},
      {_id : 1, host : "B", priority : 2},
      {_id : 2, host : "C”},
      {_id : 3, host : "D", hidden : true},
      {_id : 4, host : "E", hidden : true, slaveDelay : 3600}
    ]
}
                                                  Backup node
> rs.initiate(conf)



                                  15
Developing with Replica Sets




                        Consistency
                    Write Preference
                    Read Preference
Write


         Driver
Client                          Primary
                  Read

                               Secondary


                               Secondary




                          17
Write
Client Application
                                            Primary
                     Driver


                                           Secondary
                              Read


                                           Secondary
                              Read



                                      18
•   Fire and forget
•   Wait for error
•   Wait for journal sync
•   Wait for replication




                            19
Driver           Primary
         write


                           apply in memory




          20
Driver           Primary


     getLastError
                           apply in memory




            21
Driver           Primary
         write
     getLastError
                           apply in memory
        j:true
                           Write to journal




            22
Driver          Primary                     Secondary
         write
     getLastError
                          apply in memory
        W:majority
                              replicate




                              23
• Since 2.0.0
• Control over where data is written to
• Each member can have one or more tags e.g.
• tags: {dc: "ny"}
• tags: {dc: "ny",
     ip: "192.168",
      rack:
  "row3rk7"}
• Replica set defines rules for where data resides
• Rules can change without changing app code



                          24
{
    _id : "mySet",
    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 : {
       getLastErrorModes : {
          allDCs : {"dc" : 3},
          someDCs : {"dc" : 2}} }
}

> db.blogs.insert({...})
> db.runCommand({getLastError : 1, w : "allDCs"})


                                             25
Driver        Primary (sf)           Secondary (ny)   Secondary
         write                                         (cloud)
     getLastError       apply in
                        memory
        W:allDCs
                             replicate


                             replicate




                                26
• 5 modes (new in 2.2)
  – primary (only) - Default
  – primaryPreferred
  – secondary
  – secondaryPreferred
  – nearest




                         27
• Custom read preferences
• Control where you read from
  – E.g. { "disk": "ssd", "use": "reporting" }
• Use in conjunction with standard read
  preferences
  – Except primary




                          28
Operational Considerations




                  Upgrade/Maintenance
           Common Deployment Scenarios
• No downtime
• Rolling upgrade/maintenance
  – Start with Secondary
  – Primary last




                       30
• Single datacenter
                • Single switch & power
Member 1        • Points of failure:
                  –   Power
Member 2          –   Network
                  –   Datacenter
Member 3          –   Two node failure
                • Automatic recovery of
                  single node crash

           31
• Multi datacenter
DC
     Member 1
                     • DR node for safety
1                    • Can’t do multi data
     Member 2          center durable write
                       safely since only 1
                       node in distant DC
DC
     Member 3
2




                32
• Three data centers
DC                     • Can survive full data
     Member 1
1
                         center loss
     Member 2
                       • Can do w= { dc : 2 } to
                         guarantee write in 2
DC   Member 3
2
                         data centers (with
     Member 4
                         tags)

DC   Member 5 -
3       DR


                  33
Behind the Curtain




              Schema
                Oplog
• Heartbeat every 2 seconds
  – Times out in 10 seconds
• Local DB (not replicated)
  – system.replset
  – oplog.rs
     • Capped collection
     • Idempotent version of operation stored




                           35
> db.replsettest.insert({_id:1,value:1})
{ "ts" : Timestamp(1350539727000, 1), "h" :
NumberLong("6375186941486301201"), "op" : "i", "ns" :
"test.replsettest", "o" : { "_id" : 1, "value" : 1 } }

> db.replsettest.update({_id:1},{$inc:{value:10}})
{ "ts" : Timestamp(1350539786000, 1), "h" :
NumberLong("5484673652472424968"), "op" : "u", "ns" :
"test.replsettest", "o2" : { "_id" : 1 }, "o" : { "$set" : { "value" :
11 } } }




                                   36
> db.replsettest.update({},{$set:{name : ”foo”}, false, true})
{ "ts" : Timestamp(1350540395000, 1), "h" : NumberLong("-
4727576249368135876"), "op" : "u", "ns" : "test.replsettest", "o2" : {
"_id" : 2 }, "o" : { "$set" : { "name" : "foo" } } }
{ "ts" : Timestamp(1350540395000, 2), "h" : NumberLong("-
7292949613259260138"), "op" : "u", "ns" : "test.replsettest", "o2" : {
"_id" : 3 }, "o" : { "$set" : { "name" : "foo" } } }
{ "ts" : Timestamp(1350540395000, 3), "h" : NumberLong("-
1888768148831990635"), "op" : "u", "ns" : "test.replsettest", "o2" : {
"_id" : 1 }, "o" : { "$set" : { "name" : "foo" } } }




                                    37
• Use replica sets
• Easy to setup
  – Try on a single machine
• Check doc page for RS tutorials
  – http://docs.mongodb.org/manual/replication/#t
    utorials




                       38
download at mongodb.org
                                      We’re Hiring !
                              sridhar@10gen.com    @snanjund


               conferences, appearances, and meetups
                               http://www.10gen.com/events



            Facebook |                   Twitter        | LinkedIn
       http://bit.ly/mongofb           @mongodb        http://linkd.in/joinmongo




© Copyright 2010 10gen Inc.
                                            39

Más contenido relacionado

La actualidad más candente

Webinar: General Technical Overview of MongoDB
Webinar: General Technical Overview of MongoDBWebinar: General Technical Overview of MongoDB
Webinar: General Technical Overview of MongoDBMongoDB
 
Design of bare metal proxy compute node
Design of bare metal proxy compute nodeDesign of bare metal proxy compute node
Design of bare metal proxy compute nodeLorin Hochstein
 
Replication
ReplicationReplication
ReplicationMongoDB
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica setsRandall Hunt
 
Replication MongoDB Days 2013
Replication MongoDB Days 2013Replication MongoDB Days 2013
Replication MongoDB Days 2013Randall Hunt
 
Intro to the Hadoop Stack @ April 2011 JavaMUG
Intro to the Hadoop Stack @ April 2011 JavaMUGIntro to the Hadoop Stack @ April 2011 JavaMUG
Intro to the Hadoop Stack @ April 2011 JavaMUGDavid Engfer
 
20141011 mastering mysqlnd
20141011 mastering mysqlnd20141011 mastering mysqlnd
20141011 mastering mysqlnddo_aki
 
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...MongoDB
 
Manage cloud infrastructures using Zend Framework 2 (and ZF1)
Manage cloud infrastructures using Zend Framework 2 (and ZF1)Manage cloud infrastructures using Zend Framework 2 (and ZF1)
Manage cloud infrastructures using Zend Framework 2 (and ZF1)Enrico Zimuel
 
What's New in the PHP Driver
What's New in the PHP DriverWhat's New in the PHP Driver
What's New in the PHP DriverMongoDB
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use CasesFabrizio Farinacci
 
NoSQL - how it works (@pavlobaron)
NoSQL - how it works (@pavlobaron)NoSQL - how it works (@pavlobaron)
NoSQL - how it works (@pavlobaron)Pavlo Baron
 
Replication and Replica Sets
Replication and Replica SetsReplication and Replica Sets
Replication and Replica SetsMongoDB
 
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...PROIDEA
 
Redis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational DatabasesRedis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational DatabasesKarel Minarik
 
Pandora FMS: PostgreSQL Plugin
Pandora FMS: PostgreSQL PluginPandora FMS: PostgreSQL Plugin
Pandora FMS: PostgreSQL PluginPandora FMS
 
Paris Redis Meetup Introduction
Paris Redis Meetup IntroductionParis Redis Meetup Introduction
Paris Redis Meetup IntroductionGregory Boissinot
 

La actualidad más candente (20)

Webinar: General Technical Overview of MongoDB
Webinar: General Technical Overview of MongoDBWebinar: General Technical Overview of MongoDB
Webinar: General Technical Overview of MongoDB
 
Mongo db roma replication and sharding
Mongo db roma replication and shardingMongo db roma replication and sharding
Mongo db roma replication and sharding
 
Design of bare metal proxy compute node
Design of bare metal proxy compute nodeDesign of bare metal proxy compute node
Design of bare metal proxy compute node
 
Replication
ReplicationReplication
Replication
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica sets
 
Replication MongoDB Days 2013
Replication MongoDB Days 2013Replication MongoDB Days 2013
Replication MongoDB Days 2013
 
Intro to the Hadoop Stack @ April 2011 JavaMUG
Intro to the Hadoop Stack @ April 2011 JavaMUGIntro to the Hadoop Stack @ April 2011 JavaMUG
Intro to the Hadoop Stack @ April 2011 JavaMUG
 
20141011 mastering mysqlnd
20141011 mastering mysqlnd20141011 mastering mysqlnd
20141011 mastering mysqlnd
 
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
 
Manage cloud infrastructures using Zend Framework 2 (and ZF1)
Manage cloud infrastructures using Zend Framework 2 (and ZF1)Manage cloud infrastructures using Zend Framework 2 (and ZF1)
Manage cloud infrastructures using Zend Framework 2 (and ZF1)
 
What's New in the PHP Driver
What's New in the PHP DriverWhat's New in the PHP Driver
What's New in the PHP Driver
 
Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use Cases
 
NoSQL - how it works (@pavlobaron)
NoSQL - how it works (@pavlobaron)NoSQL - how it works (@pavlobaron)
NoSQL - how it works (@pavlobaron)
 
The Internals of "Hello World" Program
The Internals of "Hello World" ProgramThe Internals of "Hello World" Program
The Internals of "Hello World" Program
 
Replication and Replica Sets
Replication and Replica SetsReplication and Replica Sets
Replication and Replica Sets
 
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
 
Redis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational DatabasesRedis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational Databases
 
Hadoop Inside
Hadoop InsideHadoop Inside
Hadoop Inside
 
Pandora FMS: PostgreSQL Plugin
Pandora FMS: PostgreSQL PluginPandora FMS: PostgreSQL Plugin
Pandora FMS: PostgreSQL Plugin
 
Paris Redis Meetup Introduction
Paris Redis Meetup IntroductionParis Redis Meetup Introduction
Paris Redis Meetup Introduction
 

Destacado

Bringing Spatial Love to Your Java Application
Bringing Spatial Love to Your Java ApplicationBringing Spatial Love to Your Java Application
Bringing Spatial Love to Your Java ApplicationMongoDB
 
Webinar: Building Web Applications with MongoDB and Spring
Webinar: Building Web Applications with MongoDB and Spring Webinar: Building Web Applications with MongoDB and Spring
Webinar: Building Web Applications with MongoDB and Spring MongoDB
 
Mongo @ homeshop18
Mongo @ homeshop18Mongo @ homeshop18
Mongo @ homeshop18MongoDB
 
Webinar: What's New in Aggregation
Webinar: What's New in AggregationWebinar: What's New in Aggregation
Webinar: What's New in AggregationMongoDB
 
Webinar: Operational Best Practices
Webinar: Operational Best PracticesWebinar: Operational Best Practices
Webinar: Operational Best PracticesMongoDB
 
Morning with MongoDB Paris 2012 - Accueil et Introductions
Morning with MongoDB Paris 2012 - Accueil et IntroductionsMorning with MongoDB Paris 2012 - Accueil et Introductions
Morning with MongoDB Paris 2012 - Accueil et IntroductionsMongoDB
 
Building Your First Java Application with MongoDB
Building Your First Java Application with MongoDBBuilding Your First Java Application with MongoDB
Building Your First Java Application with MongoDBMongoDB
 
Schema & Design
Schema & DesignSchema & Design
Schema & DesignMongoDB
 
A Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: IntroductionA Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: IntroductionMongoDB
 
Morning with MongoDB Paris 2012 - MongoDB Cas d'utilisation au Figaro
Morning with MongoDB Paris 2012 - MongoDB Cas d'utilisation au FigaroMorning with MongoDB Paris 2012 - MongoDB Cas d'utilisation au Figaro
Morning with MongoDB Paris 2012 - MongoDB Cas d'utilisation au FigaroMongoDB
 
MongoDC 2012: Taming Social Media with MongoDB
MongoDC 2012: Taming Social Media with MongoDBMongoDC 2012: Taming Social Media with MongoDB
MongoDC 2012: Taming Social Media with MongoDBMongoDB
 
An Evening with MongoDB Detroit 2013
An Evening with MongoDB Detroit 2013An Evening with MongoDB Detroit 2013
An Evening with MongoDB Detroit 2013MongoDB
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverMongoDB
 
The Spring Data MongoDB Project
The Spring Data MongoDB ProjectThe Spring Data MongoDB Project
The Spring Data MongoDB ProjectMongoDB
 
Morning with MongoDB Paris 2012 - MongoDB Basic Concepts
Morning with MongoDB Paris 2012 - MongoDB Basic ConceptsMorning with MongoDB Paris 2012 - MongoDB Basic Concepts
Morning with MongoDB Paris 2012 - MongoDB Basic ConceptsMongoDB
 
MongoDB in FS
MongoDB in FSMongoDB in FS
MongoDB in FSMongoDB
 
MongoDB and Fractal Tree Indexes
MongoDB and Fractal Tree IndexesMongoDB and Fractal Tree Indexes
MongoDB and Fractal Tree IndexesMongoDB
 
Webinar: A Total Cost of Ownership Analysis for MongoDB
Webinar: A Total Cost of Ownership Analysis for MongoDBWebinar: A Total Cost of Ownership Analysis for MongoDB
Webinar: A Total Cost of Ownership Analysis for MongoDBMongoDB
 

Destacado (18)

Bringing Spatial Love to Your Java Application
Bringing Spatial Love to Your Java ApplicationBringing Spatial Love to Your Java Application
Bringing Spatial Love to Your Java Application
 
Webinar: Building Web Applications with MongoDB and Spring
Webinar: Building Web Applications with MongoDB and Spring Webinar: Building Web Applications with MongoDB and Spring
Webinar: Building Web Applications with MongoDB and Spring
 
Mongo @ homeshop18
Mongo @ homeshop18Mongo @ homeshop18
Mongo @ homeshop18
 
Webinar: What's New in Aggregation
Webinar: What's New in AggregationWebinar: What's New in Aggregation
Webinar: What's New in Aggregation
 
Webinar: Operational Best Practices
Webinar: Operational Best PracticesWebinar: Operational Best Practices
Webinar: Operational Best Practices
 
Morning with MongoDB Paris 2012 - Accueil et Introductions
Morning with MongoDB Paris 2012 - Accueil et IntroductionsMorning with MongoDB Paris 2012 - Accueil et Introductions
Morning with MongoDB Paris 2012 - Accueil et Introductions
 
Building Your First Java Application with MongoDB
Building Your First Java Application with MongoDBBuilding Your First Java Application with MongoDB
Building Your First Java Application with MongoDB
 
Schema & Design
Schema & DesignSchema & Design
Schema & Design
 
A Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: IntroductionA Morning with MongoDB Barcelona: Introduction
A Morning with MongoDB Barcelona: Introduction
 
Morning with MongoDB Paris 2012 - MongoDB Cas d'utilisation au Figaro
Morning with MongoDB Paris 2012 - MongoDB Cas d'utilisation au FigaroMorning with MongoDB Paris 2012 - MongoDB Cas d'utilisation au Figaro
Morning with MongoDB Paris 2012 - MongoDB Cas d'utilisation au Figaro
 
MongoDC 2012: Taming Social Media with MongoDB
MongoDC 2012: Taming Social Media with MongoDBMongoDC 2012: Taming Social Media with MongoDB
MongoDC 2012: Taming Social Media with MongoDB
 
An Evening with MongoDB Detroit 2013
An Evening with MongoDB Detroit 2013An Evening with MongoDB Detroit 2013
An Evening with MongoDB Detroit 2013
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET Driver
 
The Spring Data MongoDB Project
The Spring Data MongoDB ProjectThe Spring Data MongoDB Project
The Spring Data MongoDB Project
 
Morning with MongoDB Paris 2012 - MongoDB Basic Concepts
Morning with MongoDB Paris 2012 - MongoDB Basic ConceptsMorning with MongoDB Paris 2012 - MongoDB Basic Concepts
Morning with MongoDB Paris 2012 - MongoDB Basic Concepts
 
MongoDB in FS
MongoDB in FSMongoDB in FS
MongoDB in FS
 
MongoDB and Fractal Tree Indexes
MongoDB and Fractal Tree IndexesMongoDB and Fractal Tree Indexes
MongoDB and Fractal Tree Indexes
 
Webinar: A Total Cost of Ownership Analysis for MongoDB
Webinar: A Total Cost of Ownership Analysis for MongoDBWebinar: A Total Cost of Ownership Analysis for MongoDB
Webinar: A Total Cost of Ownership Analysis for MongoDB
 

Similar a Replication and Replica Sets

Basic Replication in MongoDB
Basic Replication in MongoDBBasic Replication in MongoDB
Basic Replication in MongoDBMongoDB
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica SetsMongoDB
 
Advanced Replication
Advanced ReplicationAdvanced Replication
Advanced ReplicationMongoDB
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsServer Density
 
MongoDB for Time Series Data Part 3: Sharding
MongoDB for Time Series Data Part 3: ShardingMongoDB for Time Series Data Part 3: Sharding
MongoDB for Time Series Data Part 3: ShardingMongoDB
 
Mongosv 2011 - Replication
Mongosv 2011 - ReplicationMongosv 2011 - Replication
Mongosv 2011 - ReplicationJared Rosoff
 
High Availability With DRBD & Heartbeat
High Availability With DRBD & HeartbeatHigh Availability With DRBD & Heartbeat
High Availability With DRBD & HeartbeatChris Barber
 
Jvm profiling under the hood
Jvm profiling under the hoodJvm profiling under the hood
Jvm profiling under the hoodRichardWarburton
 
Maintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsMaintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsIgor Donchovski
 
MongoDB Best Practices in AWS
MongoDB Best Practices in AWS MongoDB Best Practices in AWS
MongoDB Best Practices in AWS Chris Harris
 
NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013Server Density
 
Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0Jarod Wang
 
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...MongoDB
 
Deploying MongoDB for the Win
Deploying MongoDB for the WinDeploying MongoDB for the Win
Deploying MongoDB for the WinMongoDB
 
Webinar Back to Basics 3 - Introduzione ai Replica Set
Webinar Back to Basics 3 - Introduzione ai Replica SetWebinar Back to Basics 3 - Introduzione ai Replica Set
Webinar Back to Basics 3 - Introduzione ai Replica SetMongoDB
 
MySQL HA with Pacemaker
MySQL HA with  PacemakerMySQL HA with  Pacemaker
MySQL HA with PacemakerKris Buytaert
 
Linux-HA with Pacemaker
Linux-HA with PacemakerLinux-HA with Pacemaker
Linux-HA with PacemakerKris Buytaert
 
WiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeWiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeSveta Smirnova
 

Similar a Replication and Replica Sets (20)

Basic Replication in MongoDB
Basic Replication in MongoDBBasic Replication in MongoDB
Basic Replication in MongoDB
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica Sets
 
Advanced Replication
Advanced ReplicationAdvanced Replication
Advanced Replication
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & Analytics
 
NoSQL Infrastructure
NoSQL InfrastructureNoSQL Infrastructure
NoSQL Infrastructure
 
MongoDB for Time Series Data Part 3: Sharding
MongoDB for Time Series Data Part 3: ShardingMongoDB for Time Series Data Part 3: Sharding
MongoDB for Time Series Data Part 3: Sharding
 
Mongosv 2011 - Replication
Mongosv 2011 - ReplicationMongosv 2011 - Replication
Mongosv 2011 - Replication
 
High Availability With DRBD & Heartbeat
High Availability With DRBD & HeartbeatHigh Availability With DRBD & Heartbeat
High Availability With DRBD & Heartbeat
 
Jvm profiling under the hood
Jvm profiling under the hoodJvm profiling under the hood
Jvm profiling under the hood
 
Maintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica SetsMaintenance for MongoDB Replica Sets
Maintenance for MongoDB Replica Sets
 
MongoDB Best Practices in AWS
MongoDB Best Practices in AWS MongoDB Best Practices in AWS
MongoDB Best Practices in AWS
 
NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013
 
Mongodb replication
Mongodb replicationMongodb replication
Mongodb replication
 
Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0Solaris Kernel Debugging V1.0
Solaris Kernel Debugging V1.0
 
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
 
Deploying MongoDB for the Win
Deploying MongoDB for the WinDeploying MongoDB for the Win
Deploying MongoDB for the Win
 
Webinar Back to Basics 3 - Introduzione ai Replica Set
Webinar Back to Basics 3 - Introduzione ai Replica SetWebinar Back to Basics 3 - Introduzione ai Replica Set
Webinar Back to Basics 3 - Introduzione ai Replica Set
 
MySQL HA with Pacemaker
MySQL HA with  PacemakerMySQL HA with  Pacemaker
MySQL HA with Pacemaker
 
Linux-HA with Pacemaker
Linux-HA with PacemakerLinux-HA with Pacemaker
Linux-HA with Pacemaker
 
WiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-TreeWiredTiger In-Memory vs WiredTiger B-Tree
WiredTiger In-Memory vs WiredTiger B-Tree
 

Más de MongoDB

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump StartMongoDB
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB
 

Más de MongoDB (20)

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
 

Replication and Replica Sets

  • 1. Sridhar Nanjundeswaran, 10gen sridhar@10gen.com @snanjund October 21, 2012 1
  • 2. • Introduction to Replica Sets • Developing with Replica Sets • Operational Considerations • Miscellaneous 2
  • 3. Introduction to Replica Sets Why? What is it? Configuration Options
  • 4. • How many have faced node failures? • How many have been woken to do fail overs? • How many have experienced issues due to n/w latency? • Different uses for data – Normal processing – Simple analytics 4
  • 5. Node 1 Node 2 Node 3 5
  • 6. Node 1 Node 2 Secondary Heartbeat Secondary Node 3 Primary Replication Replication 6
  • 7. Primary Election Node 1 Node 2 Secondary Heartbeat Secondary Node 3 Primary 7
  • 8. Replication Node 1 Node 2 Secondary Heartbeat Primary Node 3 Primary 8
  • 9. Replication Node 1 Node 2 Secondary Heartbeat Primary Node 3 Secondary Replication 9
  • 10. Node 1 Node 2 Secondary Heartbeat Arbiterr Node 3 Primary Replication 10
  • 11. > conf = { _id : "mySet", members : [ {_id : 0, host : "A”, priority : 3}, {_id : 1, host : "B", priority : 2}, {_id : 2, host : "C”}, {_id : 3, host : "D", hidden : true}, {_id : 4, host : "E", hidden : true, slaveDelay : 3600} ] } > rs.initiate(conf) 11
  • 12. > conf = { _id : "mySet”, Primary DC members : [ {_id : 0, host : "A”, priority : 3}, {_id : 1, host : "B", priority : 2}, {_id : 2, host : "C”}, {_id : 3, host : "D", hidden : true}, {_id : 4, host : "E", hidden : true, slaveDelay : 3600} ] } > rs.initiate(conf) 12
  • 13. > conf = { _id : "mySet”, members : [ {_id : 0, host : "A”, priority : 3}, {_id : 1, host : "B", priority : 2}, Secondary DC {_id : 2, host : "C”}, Default priority = 1 {_id : 3, host : "D", hidden : true}, {_id : 4, host : "E", hidden : true, slaveDelay : 3600} ] } > rs.initiate(conf) 13
  • 14. > conf = { _id : "mySet”, Analytics node members : [ {_id : 0, host : "A”, priority : 3}, {_id : 1, host : "B", priority : 2}, {_id : 2, host : "C”}, {_id : 3, host : "D", hidden : true}, {_id : 4, host : "E", hidden : true, slaveDelay : 3600} ] } > rs.initiate(conf) 14
  • 15. > conf = { _id : "mySet”, members : [ {_id : 0, host : "A”, priority : 3}, {_id : 1, host : "B", priority : 2}, {_id : 2, host : "C”}, {_id : 3, host : "D", hidden : true}, {_id : 4, host : "E", hidden : true, slaveDelay : 3600} ] } Backup node > rs.initiate(conf) 15
  • 16. Developing with Replica Sets Consistency Write Preference Read Preference
  • 17. Write Driver Client Primary Read Secondary Secondary 17
  • 18. Write Client Application Primary Driver Secondary Read Secondary Read 18
  • 19. Fire and forget • Wait for error • Wait for journal sync • Wait for replication 19
  • 20. Driver Primary write apply in memory 20
  • 21. Driver Primary getLastError apply in memory 21
  • 22. Driver Primary write getLastError apply in memory j:true Write to journal 22
  • 23. Driver Primary Secondary write getLastError apply in memory W:majority replicate 23
  • 24. • Since 2.0.0 • Control over where data is written to • Each member can have one or more tags e.g. • tags: {dc: "ny"} • tags: {dc: "ny",
 ip: "192.168",
 rack: "row3rk7"} • Replica set defines rules for where data resides • Rules can change without changing app code 24
  • 25. { _id : "mySet", 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 : { getLastErrorModes : { allDCs : {"dc" : 3}, someDCs : {"dc" : 2}} } } > db.blogs.insert({...}) > db.runCommand({getLastError : 1, w : "allDCs"}) 25
  • 26. Driver Primary (sf) Secondary (ny) Secondary write (cloud) getLastError apply in memory W:allDCs replicate replicate 26
  • 27. • 5 modes (new in 2.2) – primary (only) - Default – primaryPreferred – secondary – secondaryPreferred – nearest 27
  • 28. • Custom read preferences • Control where you read from – E.g. { "disk": "ssd", "use": "reporting" } • Use in conjunction with standard read preferences – Except primary 28
  • 29. Operational Considerations Upgrade/Maintenance Common Deployment Scenarios
  • 30. • No downtime • Rolling upgrade/maintenance – Start with Secondary – Primary last 30
  • 31. • Single datacenter • Single switch & power Member 1 • Points of failure: – Power Member 2 – Network – Datacenter Member 3 – Two node failure • Automatic recovery of single node crash 31
  • 32. • Multi datacenter DC Member 1 • DR node for safety 1 • Can’t do multi data Member 2 center durable write safely since only 1 node in distant DC DC Member 3 2 32
  • 33. • Three data centers DC • Can survive full data Member 1 1 center loss Member 2 • Can do w= { dc : 2 } to guarantee write in 2 DC Member 3 2 data centers (with Member 4 tags) DC Member 5 - 3 DR 33
  • 34. Behind the Curtain Schema Oplog
  • 35. • Heartbeat every 2 seconds – Times out in 10 seconds • Local DB (not replicated) – system.replset – oplog.rs • Capped collection • Idempotent version of operation stored 35
  • 36. > db.replsettest.insert({_id:1,value:1}) { "ts" : Timestamp(1350539727000, 1), "h" : NumberLong("6375186941486301201"), "op" : "i", "ns" : "test.replsettest", "o" : { "_id" : 1, "value" : 1 } } > db.replsettest.update({_id:1},{$inc:{value:10}}) { "ts" : Timestamp(1350539786000, 1), "h" : NumberLong("5484673652472424968"), "op" : "u", "ns" : "test.replsettest", "o2" : { "_id" : 1 }, "o" : { "$set" : { "value" : 11 } } } 36
  • 37. > db.replsettest.update({},{$set:{name : ”foo”}, false, true}) { "ts" : Timestamp(1350540395000, 1), "h" : NumberLong("- 4727576249368135876"), "op" : "u", "ns" : "test.replsettest", "o2" : { "_id" : 2 }, "o" : { "$set" : { "name" : "foo" } } } { "ts" : Timestamp(1350540395000, 2), "h" : NumberLong("- 7292949613259260138"), "op" : "u", "ns" : "test.replsettest", "o2" : { "_id" : 3 }, "o" : { "$set" : { "name" : "foo" } } } { "ts" : Timestamp(1350540395000, 3), "h" : NumberLong("- 1888768148831990635"), "op" : "u", "ns" : "test.replsettest", "o2" : { "_id" : 1 }, "o" : { "$set" : { "name" : "foo" } } } 37
  • 38. • Use replica sets • Easy to setup – Try on a single machine • Check doc page for RS tutorials – http://docs.mongodb.org/manual/replication/#t utorials 38
  • 39. download at mongodb.org We’re Hiring ! sridhar@10gen.com @snanjund conferences, appearances, and meetups http://www.10gen.com/events Facebook | Twitter | LinkedIn http://bit.ly/mongofb @mongodb http://linkd.in/joinmongo © Copyright 2010 10gen Inc. 39