SlideShare una empresa de Scribd logo
1 de 40
Descargar para leer sin conexión
#MongoDBDays - @m4rcsch




Advanced Replication
Marc Schwering
Solutions Architect, 10gen
Notes to the presenter
Themes for this presentation:
•  Prepare your console use properly
Roles & Configuration
Node 1                         Node 2
       Secondary                      Arbiter
                          Heartbeat

           Re
              pli
                  cat
                  on  i

                          Node 3
                           Primary




Replica Set Roles
Configuration Options
> conf = {
        _id : "mySet",
        members : [
            {_id : 0, host : "A"},
            {_id : 1, host : "B"},
            {_id : 2, host : "C", "arbiter" : true}
    ]
}


> rs.initiate(conf)
Simple Setup Demo
Behind the Curtain
Implementation details
•  Heartbeat every 2 seconds
   –  Times out in 10 seconds

•  Local DB (not replicated)
   –  system.replset
   –  oplog.rs
      •  Capped collection
      •  Idempotent version of operation stored
Op(erations) Log
Op(erations) Log is idempotent
> 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 } } }
oplog and multi-updates
Single operation can have many
entries
> 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" } } }
Operations
Maintenance and Upgrade
•  No downtime
•  Rolling upgrade/maintenance
   –  Start with Secondary
   –  Primary last

   –  Commands:
      •  rs.stepDown(<secs>)
      •  db.version()
      •  db.serverBuildInfo()
Upgrade Demo
Replica Set – 1 Data Center
                    •  Single datacenter
      Datacenter
                    •  Single switch & power
      Member 1      •  Points of failure:
                       –  Power
      Member 2         –  Network
                       –  Data center
     Datacenter 2
      Member 3         –  Two node failure

                    •  Automatic recovery of
                     single node crash
Replica Set – 2 Data Centers
                    •  Multi data center
     Datacenter 1
                    •  DR node for safety
      Member 1
                    •  Can’t do multi data
      Member 2       center durable write
                     safely since only 1 node
                     in distant DC
     Datacenter 2

      Member 3
Replica Set – 2 Data Centers
                              •  Analytics
                              •  Disaster Recovery
                              •  Batch Jobs



 •  Options
    –  low or zero priority
    –  hidden
    –  slaveDelay
Replica Set – 3 Data Centers
     Datacenter 1   •  Three data centers
      Member 1

      Member 2
                    •  Can survive full data
                     center loss
     Datacenter 2
      Member 3      •  Can do w= { dc : 2 } to
      Member 4       guarantee write in 2
                     data centers (with tags)
     Datacenter 3
      Member 5
Replica Set – 3+ Data Centers

                             Secondary

                              Primary

                                         Secondary
                                                     Secondary
     Secondary                           delayed




                 Secondary

                                                       Secondary
Commands
•  Managing
   –  rs.conf()
   –  rs.initiate(<conf>) & rs.reconfig(<conf>)
   –  rs.add(host:<port>) & rs.addArb(host:<port>)
   –  rs.status()
   –  rs.stepDown(<secs>)

•  Minority reconfig
   –  rs.reconfig( cfg, { force : true} )
Options
•  Priorities
•  Hidden
•  Slave Delay
•  Disable indexes (on secondaries)
•  Default write concerns
Developing with Replica Sets
Client Application
                        Driver




                    Write




                                 Read
                       Primary



        Secondary                       Secondary



Strong Consistency
Client Application
                    Driver




                        Write
          ad




                                    Re
        Re




                                       ad
                    Primary



       Secondary                Secondary



Delayed Consistency
Write Concern
•  Network acknowledgement
•  Wait for error
•  Wait for journal sync
•  Wait for replication
   –  number
   –  majority
   –  Tags
Write Concern Demo
Datacenter awareness (Tagging)
•  Control where data is written to, and read from
•  Each member can have one or more tags
   –  tags: {dc: "ny"}
   –  tags: {dc: "ny",
            subnet: "192.168",
            rack: "row3rk7"}
•  Replica set defines rules for write concerns
•  Rules can change without changing app code
Tagging Example
{
    _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 : "someDCs"})
> db.getLastErrorObj({"someDCs"})
Driver




                              getLastError


                                             W:allDCs
                     write
  Primary (SF)




                                                        replicate
                             apply in
                              memory


 Secondary (NY)




                                                                    replicate
 Secondary (Cloud)




Wait for Replication
Write Concern with timeout
settings : {
        getLastErrorModes : {
               allDCs :   {"dc" : 3},
               someDCs : {"dc" : 2}} }
}
> db.getLastErrorObj({"allDCs"},100);
> db.getLastErrorObj({”someDCs"},500);
> db.getLastErrorObj(1,500);
Read Preference Modes
•  5 modes
   –  primary (only) - Default
   –  primaryPreferred
   –  secondary
   –  secondaryPreferred
   –  Nearest

   When more than one node is possible, closest node is used for
   reads (all modes but primary)
Tagged Read Preference
•  Custom read preferences
•  Control where you read from by (node) tags
   –  E.g. { "disk": "ssd", "use": "reporting" }

•  Use in conjunction with standard read preferences
   –  Except primary
Tags

{"dc.va": "rack1", disk:"ssd", ssd: "installed" }
{"dc.va": "rack2", disk:"raid"}
{"dc.gto": "rack1", disk:"ssd", ssd: "installed" }
{"dc.gto": "rack2", disk:"raid”}


> conf.settings = { getLastErrorModes: { MultipleDC :
{ "dc.va": 1, "dc.gto": 1}}


> conf.settings = {
                 "getLastErrorModes" : {
                         "ssd" : {
                                     "ssd" : 1
                         },...
Tagged Read Preference
{ disk: "ssd" }


JAVA:
ReadPreference tagged_pref =
    ReadPreference.secondaryPreferred(
         new BasicDBObject("disk", "ssd")
    );


DBObject result =
    coll.findOne(query, null, tagged_pref);
Tagged Read Preference
•  Grouping / Failover
 {dc : "LON", loc : "EU"}
 {dc : "FRA", loc : "EU"}
 {dc : "NY",   loc : "US”}
 DBObject t1 = new BasicDBObject("dc", "LON");
 DBObject t2 = new BasicDBObject("loc", "EU");


 ReadPreference pref =
     ReadPreference.primaryPreferred(t1, t2);
Tagging Demo
Conclusion
Best practices and tips
•  Odd number of set members
•  Read from the primary except for
   –  Geographically distribution
   –  Analytics (separate workload)

•  Use logical names not IP Addresses in configs
•  Set WriteConcern appropriately for what you are
 doing
•  Monitor secondaries for lag (Alerts in MMS)
#MongoDBDays - @m4rcsch




Thank You
Marc Schwering
Solutions Architect, 10gen

Más contenido relacionado

La actualidad más candente

Replication
ReplicationReplication
ReplicationMongoDB
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica setsRandall Hunt
 
Distributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevdayDistributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevdayodnoklassniki.ru
 
Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)MongoDB
 
Windows Remote Management - EN
Windows Remote Management - ENWindows Remote Management - EN
Windows Remote Management - ENKirill Nikolaev
 
High Availability With DRBD & Heartbeat
High Availability With DRBD & HeartbeatHigh Availability With DRBD & Heartbeat
High Availability With DRBD & HeartbeatChris Barber
 
Fatkulin presentation
Fatkulin presentationFatkulin presentation
Fatkulin presentationEnkitec
 
Lucene revolution 2011
Lucene revolution 2011Lucene revolution 2011
Lucene revolution 2011Takahiko Ito
 
MongoDB Database Replication
MongoDB Database ReplicationMongoDB Database Replication
MongoDB Database ReplicationMehdi Valikhani
 
Advanced Windows Debugging
Advanced Windows DebuggingAdvanced Windows Debugging
Advanced Windows DebuggingBala Subra
 
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedKernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedAnne Nicolas
 
Advanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMXAdvanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMXzznate
 
Kernel Recipes 2019 - XDP closer integration with network stack
Kernel Recipes 2019 -  XDP closer integration with network stackKernel Recipes 2019 -  XDP closer integration with network stack
Kernel Recipes 2019 - XDP closer integration with network stackAnne Nicolas
 
Inspection and maintenance tools (Linux / OpenStack)
Inspection and maintenance tools (Linux / OpenStack)Inspection and maintenance tools (Linux / OpenStack)
Inspection and maintenance tools (Linux / OpenStack)Gerard Braad
 
Linux Process & CF scheduling
Linux Process & CF schedulingLinux Process & CF scheduling
Linux Process & CF schedulingSangJung Woo
 
Linux kernel debugging(ODP format)
Linux kernel debugging(ODP format)Linux kernel debugging(ODP format)
Linux kernel debugging(ODP format)yang firo
 
Debugging & Tuning in Spark
Debugging & Tuning in SparkDebugging & Tuning in Spark
Debugging & Tuning in SparkShiao-An Yuan
 
glance replicator
glance replicatorglance replicator
glance replicatoririx_jp
 

La actualidad más candente (20)

Replication
ReplicationReplication
Replication
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica sets
 
Distributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevdayDistributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevday
 
Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)
 
Windows Remote Management - EN
Windows Remote Management - ENWindows Remote Management - EN
Windows Remote Management - EN
 
High Availability With DRBD & Heartbeat
High Availability With DRBD & HeartbeatHigh Availability With DRBD & Heartbeat
High Availability With DRBD & Heartbeat
 
Fatkulin presentation
Fatkulin presentationFatkulin presentation
Fatkulin presentation
 
Lucene revolution 2011
Lucene revolution 2011Lucene revolution 2011
Lucene revolution 2011
 
Understanding DPDK
Understanding DPDKUnderstanding DPDK
Understanding DPDK
 
MongoDB Database Replication
MongoDB Database ReplicationMongoDB Database Replication
MongoDB Database Replication
 
Upgrade & ndmp
Upgrade & ndmpUpgrade & ndmp
Upgrade & ndmp
 
Advanced Windows Debugging
Advanced Windows DebuggingAdvanced Windows Debugging
Advanced Windows Debugging
 
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all startedKernel Recipes 2019 - ftrace: Where modifying a running kernel all started
Kernel Recipes 2019 - ftrace: Where modifying a running kernel all started
 
Advanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMXAdvanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMX
 
Kernel Recipes 2019 - XDP closer integration with network stack
Kernel Recipes 2019 -  XDP closer integration with network stackKernel Recipes 2019 -  XDP closer integration with network stack
Kernel Recipes 2019 - XDP closer integration with network stack
 
Inspection and maintenance tools (Linux / OpenStack)
Inspection and maintenance tools (Linux / OpenStack)Inspection and maintenance tools (Linux / OpenStack)
Inspection and maintenance tools (Linux / OpenStack)
 
Linux Process & CF scheduling
Linux Process & CF schedulingLinux Process & CF scheduling
Linux Process & CF scheduling
 
Linux kernel debugging(ODP format)
Linux kernel debugging(ODP format)Linux kernel debugging(ODP format)
Linux kernel debugging(ODP format)
 
Debugging & Tuning in Spark
Debugging & Tuning in SparkDebugging & Tuning in Spark
Debugging & Tuning in Spark
 
glance replicator
glance replicatorglance replicator
glance replicator
 

Similar a 2013 london advanced-replication

Advanced Replication
Advanced ReplicationAdvanced Replication
Advanced ReplicationMongoDB
 
Basic Replication in MongoDB
Basic Replication in MongoDBBasic Replication in MongoDB
Basic Replication in MongoDBMongoDB
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsServer Density
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica SetsMongoDB
 
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
 
Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101MongoDB
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung MosbachJohannes Hoppe
 
OSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross LawleyOSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross LawleyNETWAYS
 
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
 
Getting started with Spark & Cassandra by Jon Haddad of Datastax
Getting started with Spark & Cassandra by Jon Haddad of DatastaxGetting started with Spark & Cassandra by Jon Haddad of Datastax
Getting started with Spark & Cassandra by Jon Haddad of DatastaxData Con LA
 
Replication and Replica Sets
Replication and Replica SetsReplication and Replica Sets
Replication and Replica SetsMongoDB
 
NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013Server Density
 
MongoDB London 2013 - Basic Replication
MongoDB London 2013 - Basic ReplicationMongoDB London 2013 - Basic Replication
MongoDB London 2013 - Basic ReplicationMarc Schwering
 
Speed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudSpeed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudRevolution Analytics
 
REDIS intro and how to use redis
REDIS intro and how to use redisREDIS intro and how to use redis
REDIS intro and how to use redisKris Jeong
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugginglibfetion
 
Scaling with MongoDB
Scaling with MongoDBScaling with MongoDB
Scaling with MongoDBMongoDB
 
Deploying MongoDB for the Win
Deploying MongoDB for the WinDeploying MongoDB for the Win
Deploying MongoDB for the WinMongoDB
 

Similar a 2013 london advanced-replication (20)

Advanced Replication
Advanced ReplicationAdvanced Replication
Advanced Replication
 
Basic Replication in MongoDB
Basic Replication in MongoDBBasic Replication in MongoDB
Basic Replication in MongoDB
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & Analytics
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica Sets
 
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
 
Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
 
NoSQL Infrastructure
NoSQL InfrastructureNoSQL Infrastructure
NoSQL Infrastructure
 
OSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross LawleyOSDC 2012 | Scaling with MongoDB by Ross Lawley
OSDC 2012 | Scaling with MongoDB by Ross Lawley
 
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...
 
Getting started with Spark & Cassandra by Jon Haddad of Datastax
Getting started with Spark & Cassandra by Jon Haddad of DatastaxGetting started with Spark & Cassandra by Jon Haddad of Datastax
Getting started with Spark & Cassandra by Jon Haddad of Datastax
 
Replication and Replica Sets
Replication and Replica SetsReplication and Replica Sets
Replication and Replica Sets
 
NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013NoSQL Infrastructure - Late 2013
NoSQL Infrastructure - Late 2013
 
MongoDB London 2013 - Basic Replication
MongoDB London 2013 - Basic ReplicationMongoDB London 2013 - Basic Replication
MongoDB London 2013 - Basic Replication
 
A22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle HaileyA22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle Hailey
 
Speed up R with parallel programming in the Cloud
Speed up R with parallel programming in the CloudSpeed up R with parallel programming in the Cloud
Speed up R with parallel programming in the Cloud
 
REDIS intro and how to use redis
REDIS intro and how to use redisREDIS intro and how to use redis
REDIS intro and how to use redis
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Scaling with MongoDB
Scaling with MongoDBScaling with MongoDB
Scaling with MongoDB
 
Deploying MongoDB for the Win
Deploying MongoDB for the WinDeploying MongoDB for the Win
Deploying MongoDB for the Win
 

Último

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 

Último (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 

2013 london advanced-replication

  • 1. #MongoDBDays - @m4rcsch Advanced Replication Marc Schwering Solutions Architect, 10gen
  • 2. Notes to the presenter Themes for this presentation: •  Prepare your console use properly
  • 4. Node 1 Node 2 Secondary Arbiter Heartbeat Re pli cat on i Node 3 Primary Replica Set Roles
  • 5. Configuration Options > conf = { _id : "mySet", members : [ {_id : 0, host : "A"}, {_id : 1, host : "B"}, {_id : 2, host : "C", "arbiter" : true} ] } > rs.initiate(conf)
  • 8. Implementation details •  Heartbeat every 2 seconds –  Times out in 10 seconds •  Local DB (not replicated) –  system.replset –  oplog.rs •  Capped collection •  Idempotent version of operation stored
  • 10. Op(erations) Log is idempotent > 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 } } }
  • 12. Single operation can have many entries > 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" } } }
  • 14. Maintenance and Upgrade •  No downtime •  Rolling upgrade/maintenance –  Start with Secondary –  Primary last –  Commands: •  rs.stepDown(<secs>) •  db.version() •  db.serverBuildInfo()
  • 16. Replica Set – 1 Data Center •  Single datacenter Datacenter •  Single switch & power Member 1 •  Points of failure: –  Power Member 2 –  Network –  Data center Datacenter 2 Member 3 –  Two node failure •  Automatic recovery of single node crash
  • 17. Replica Set – 2 Data Centers •  Multi data center Datacenter 1 •  DR node for safety Member 1 •  Can’t do multi data Member 2 center durable write safely since only 1 node in distant DC Datacenter 2 Member 3
  • 18. Replica Set – 2 Data Centers •  Analytics •  Disaster Recovery •  Batch Jobs •  Options –  low or zero priority –  hidden –  slaveDelay
  • 19. Replica Set – 3 Data Centers Datacenter 1 •  Three data centers Member 1 Member 2 •  Can survive full data center loss Datacenter 2 Member 3 •  Can do w= { dc : 2 } to Member 4 guarantee write in 2 data centers (with tags) Datacenter 3 Member 5
  • 20. Replica Set – 3+ Data Centers Secondary Primary Secondary Secondary Secondary delayed Secondary Secondary
  • 21. Commands •  Managing –  rs.conf() –  rs.initiate(<conf>) & rs.reconfig(<conf>) –  rs.add(host:<port>) & rs.addArb(host:<port>) –  rs.status() –  rs.stepDown(<secs>) •  Minority reconfig –  rs.reconfig( cfg, { force : true} )
  • 22. Options •  Priorities •  Hidden •  Slave Delay •  Disable indexes (on secondaries) •  Default write concerns
  • 24. Client Application Driver Write Read Primary Secondary Secondary Strong Consistency
  • 25. Client Application Driver Write ad Re Re ad Primary Secondary Secondary Delayed Consistency
  • 26. Write Concern •  Network acknowledgement •  Wait for error •  Wait for journal sync •  Wait for replication –  number –  majority –  Tags
  • 28. Datacenter awareness (Tagging) •  Control where data is written to, and read from •  Each member can have one or more tags –  tags: {dc: "ny"} –  tags: {dc: "ny", subnet: "192.168", rack: "row3rk7"} •  Replica set defines rules for write concerns •  Rules can change without changing app code
  • 29. Tagging Example { _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 : "someDCs"}) > db.getLastErrorObj({"someDCs"})
  • 30. Driver getLastError W:allDCs write Primary (SF) replicate apply in memory Secondary (NY) replicate Secondary (Cloud) Wait for Replication
  • 31. Write Concern with timeout settings : { getLastErrorModes : { allDCs : {"dc" : 3}, someDCs : {"dc" : 2}} } } > db.getLastErrorObj({"allDCs"},100); > db.getLastErrorObj({”someDCs"},500); > db.getLastErrorObj(1,500);
  • 32. Read Preference Modes •  5 modes –  primary (only) - Default –  primaryPreferred –  secondary –  secondaryPreferred –  Nearest When more than one node is possible, closest node is used for reads (all modes but primary)
  • 33. Tagged Read Preference •  Custom read preferences •  Control where you read from by (node) tags –  E.g. { "disk": "ssd", "use": "reporting" } •  Use in conjunction with standard read preferences –  Except primary
  • 34. Tags {"dc.va": "rack1", disk:"ssd", ssd: "installed" } {"dc.va": "rack2", disk:"raid"} {"dc.gto": "rack1", disk:"ssd", ssd: "installed" } {"dc.gto": "rack2", disk:"raid”} > conf.settings = { getLastErrorModes: { MultipleDC : { "dc.va": 1, "dc.gto": 1}} > conf.settings = { "getLastErrorModes" : { "ssd" : { "ssd" : 1 },...
  • 35. Tagged Read Preference { disk: "ssd" } JAVA: ReadPreference tagged_pref = ReadPreference.secondaryPreferred( new BasicDBObject("disk", "ssd") ); DBObject result = coll.findOne(query, null, tagged_pref);
  • 36. Tagged Read Preference •  Grouping / Failover {dc : "LON", loc : "EU"} {dc : "FRA", loc : "EU"} {dc : "NY", loc : "US”} DBObject t1 = new BasicDBObject("dc", "LON"); DBObject t2 = new BasicDBObject("loc", "EU"); ReadPreference pref = ReadPreference.primaryPreferred(t1, t2);
  • 39. Best practices and tips •  Odd number of set members •  Read from the primary except for –  Geographically distribution –  Analytics (separate workload) •  Use logical names not IP Addresses in configs •  Set WriteConcern appropriately for what you are doing •  Monitor secondaries for lag (Alerts in MMS)
  • 40. #MongoDBDays - @m4rcsch Thank You Marc Schwering Solutions Architect, 10gen