SlideShare a Scribd company logo
Replication Internals MongoBerlin 2010-10-4 Mathias Stearn [email_address]
Replication is Good! Use it! mongod --master mongod --slave --source host:port 30 second demo…
Basic Phases of a Slave If not empty skip to step 4 (--fastsync) Note master's position in OpLog Copy data from master ($snapshot) Replay OpLog to catch up Continue watching OpLog for new changes ??? Profit
The OpLog “ local.oplog.$main” for Master/Slave Only on Master “ local.oplog.rs” for ReplicaSets On all nodes Uses a capped collection (--oplogSize) “ Wraps” when full (LRI) Make sure it's large enough You can query it like  any other collection
OpLog Entries { "ts" : { "t" : 1286179802000, "i" : 1 }, "op" : "i", "ns" : "test.foo", "o" : { "_id":1, "a" : 1 } } Operations: I : insert U : update (modified to be idempotent) D : delete (one per object) C : command N : No-op (ignore these)
OpLog demo Insert and update an object Look at OpLog Use local db.oplog.$main.find({op:{$ne:'n'}}) sort({$natural:-1}) Show data on slave Add new slave and show data
Replication Optimizations All of these QueryOptions are used internally Exaust – Sends all data w/o GetMores Tailable – Leaves cursor open AwaitData – Query blocks for data (push) OplogReplay – Optimizes scan for entries newer than supplied timestamp so we don't need an index
Replica Pairs Deprecated by ReplSets in 1.6 Don't use!
Replica Sets Evolution of Replica Pairs Reflects “lessons learned” Any number of nodes All keep a copy of the OpLog At any time one node is Primay If Primary fails, remaining nodes elect a new Primary with newest data
Replica Set Gotchas When Primary fails, short period of time with no Primary Election requires a majority of nodes up Works best with 3 failure domains Writes not commited to quorum can be rolled-back Use getLastError with “W” Cascading not support yet (planned)
Questions? Ask away! #mongodb on irc.freenode.net [email_address] [email_address] Thanks for coming!

More Related Content

What's hot (20)

PDF
127 Ch 2: Stack overflows on Linux
Sam Bowne
 
KEY
Agile Iphone Development
Giordano Scalzo
 
PDF
Command line arguments that make you smile
Martin Melin
 
PDF
CNIT 127 Ch 2: Stack overflows on Linux
Sam Bowne
 
PDF
Top 10 Perl Performance Tips
Perrin Harkins
 
PDF
The Directions Pipeline at Mapbox - AWS Meetup Berlin June 2015
Johan
 
PDF
R Data Analysis/Rを使った人事データ分析入門
Takanori Omote
 
PDF
ECMA Script
NodeXperts
 
PPTX
Apache Spark Structured Streaming + Apache Kafka = ♡
Bartosz Konieczny
 
PPTX
Apache Flink Training: DataStream API Part 1 Basic
Flink Forward
 
PPT
Devel::NYTProf::Apache
Tokuhiro Matsuno
 
PPT
Stack linked list
bhargav0077
 
PPTX
Using Cerberus and PySpark to validate semi-structured datasets
Bartosz Konieczny
 
PPTX
ATS Internals
Chao Xu
 
DOCX
java copy file program
Glen Pais
 
PPTX
0.5mln packets per second with Erlang
Maxim Kharchenko
 
PDF
CNIT 127: Ch 8: Windows overflows (Part 2)
Sam Bowne
 
PDF
Using Apache Spark to Solve Sessionization Problem in Batch and Streaming
Databricks
 
PPTX
Apache Spark in your likeness - low and high level customization
Bartosz Konieczny
 
PPTX
Running GLM in R
Sri Ambati
 
127 Ch 2: Stack overflows on Linux
Sam Bowne
 
Agile Iphone Development
Giordano Scalzo
 
Command line arguments that make you smile
Martin Melin
 
CNIT 127 Ch 2: Stack overflows on Linux
Sam Bowne
 
Top 10 Perl Performance Tips
Perrin Harkins
 
The Directions Pipeline at Mapbox - AWS Meetup Berlin June 2015
Johan
 
R Data Analysis/Rを使った人事データ分析入門
Takanori Omote
 
ECMA Script
NodeXperts
 
Apache Spark Structured Streaming + Apache Kafka = ♡
Bartosz Konieczny
 
Apache Flink Training: DataStream API Part 1 Basic
Flink Forward
 
Devel::NYTProf::Apache
Tokuhiro Matsuno
 
Stack linked list
bhargav0077
 
Using Cerberus and PySpark to validate semi-structured datasets
Bartosz Konieczny
 
ATS Internals
Chao Xu
 
java copy file program
Glen Pais
 
0.5mln packets per second with Erlang
Maxim Kharchenko
 
CNIT 127: Ch 8: Windows overflows (Part 2)
Sam Bowne
 
Using Apache Spark to Solve Sessionization Problem in Batch and Streaming
Databricks
 
Apache Spark in your likeness - low and high level customization
Bartosz Konieczny
 
Running GLM in R
Sri Ambati
 

Similar to Repl internals (20)

PPTX
Replication and replica sets
Chris Westin
 
PDF
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
MongoDB Database Replication
Mehdi Valikhani
 
PPTX
Practical Replication June-2011
Chris Westin
 
PDF
Exploring the replication in MongoDB
Igor Donchovski
 
PDF
Evolution of MongoDB Replicaset and Its Best Practices
Mydbops
 
PDF
Evolution Of MongoDB Replicaset
M Malai
 
PPTX
MongoDB Replication fundamentals - Desert Code Camp - October 2014
clairvoyantllc
 
PPTX
MongoDB Replication fundamentals - Desert Code Camp - October 2014
Avinash Ramineni
 
KEY
MongoDB Administration ~ Kevin Hanson
hungarianhc
 
PDF
Replication MongoDB Days 2013
Randall Hunt
 
PPTX
Get expertise with mongo db
Amit Thakkar
 
PDF
Maintenance for MongoDB Replica Sets
Igor Donchovski
 
PDF
Replication Internals: The Life of a Write
MongoDB
 
DOCX
MongoDB Replication and Sharding
Tharun Srinivasa
 
PDF
Mongodb replication
PoguttuezhiniVP
 
KEY
Replication, Durability, and Disaster Recovery
Steven Francia
 
PPTX
Webinar: Replication and Replica Sets
MongoDB
 
PDF
MongoDB HA - what can go wrong
Igor Donchovski
 
PPTX
Basic Replication in MongoDB
MongoDB
 
Replication and replica sets
Chris Westin
 
Javantura v2 - Replication with MongoDB - what could go wrong... - Philipp Krenn
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
MongoDB Database Replication
Mehdi Valikhani
 
Practical Replication June-2011
Chris Westin
 
Exploring the replication in MongoDB
Igor Donchovski
 
Evolution of MongoDB Replicaset and Its Best Practices
Mydbops
 
Evolution Of MongoDB Replicaset
M Malai
 
MongoDB Replication fundamentals - Desert Code Camp - October 2014
clairvoyantllc
 
MongoDB Replication fundamentals - Desert Code Camp - October 2014
Avinash Ramineni
 
MongoDB Administration ~ Kevin Hanson
hungarianhc
 
Replication MongoDB Days 2013
Randall Hunt
 
Get expertise with mongo db
Amit Thakkar
 
Maintenance for MongoDB Replica Sets
Igor Donchovski
 
Replication Internals: The Life of a Write
MongoDB
 
MongoDB Replication and Sharding
Tharun Srinivasa
 
Mongodb replication
PoguttuezhiniVP
 
Replication, Durability, and Disaster Recovery
Steven Francia
 
Webinar: Replication and Replica Sets
MongoDB
 
MongoDB HA - what can go wrong
Igor Donchovski
 
Basic Replication in MongoDB
MongoDB
 
Ad

More from MongoDB (20)

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

Recently uploaded (20)

PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
Home Cleaning App Development Services.pdf
V3cube
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Survival Models: Proper Scoring Rule and Stochastic Optimization with Competi...
Paris Women in Machine Learning and Data Science
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
“ONNX and Python to C++: State-of-the-art Graph Compilation,” a Presentation ...
Edge AI and Vision Alliance
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
Evolution: How True AI is Redefining Safety in Industry 4.0
vikaassingh4433
 
PDF
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pdf
ghjghvhjgc
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Home Cleaning App Development Services.pdf
V3cube
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Survival Models: Proper Scoring Rule and Stochastic Optimization with Competi...
Paris Women in Machine Learning and Data Science
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Wondershare Filmora Crack Free Download 2025
josanj305
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
“ONNX and Python to C++: State-of-the-art Graph Compilation,” a Presentation ...
Edge AI and Vision Alliance
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Evolution: How True AI is Redefining Safety in Industry 4.0
vikaassingh4433
 
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pdf
ghjghvhjgc
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Digital Circuits, important subject in CS
contactparinay1
 

Repl internals

  • 1. Replication Internals MongoBerlin 2010-10-4 Mathias Stearn [email_address]
  • 2. Replication is Good! Use it! mongod --master mongod --slave --source host:port 30 second demo…
  • 3. Basic Phases of a Slave If not empty skip to step 4 (--fastsync) Note master's position in OpLog Copy data from master ($snapshot) Replay OpLog to catch up Continue watching OpLog for new changes ??? Profit
  • 4. The OpLog “ local.oplog.$main” for Master/Slave Only on Master “ local.oplog.rs” for ReplicaSets On all nodes Uses a capped collection (--oplogSize) “ Wraps” when full (LRI) Make sure it's large enough You can query it like any other collection
  • 5. OpLog Entries { "ts" : { "t" : 1286179802000, "i" : 1 }, "op" : "i", "ns" : "test.foo", "o" : { "_id":1, "a" : 1 } } Operations: I : insert U : update (modified to be idempotent) D : delete (one per object) C : command N : No-op (ignore these)
  • 6. OpLog demo Insert and update an object Look at OpLog Use local db.oplog.$main.find({op:{$ne:'n'}}) sort({$natural:-1}) Show data on slave Add new slave and show data
  • 7. Replication Optimizations All of these QueryOptions are used internally Exaust – Sends all data w/o GetMores Tailable – Leaves cursor open AwaitData – Query blocks for data (push) OplogReplay – Optimizes scan for entries newer than supplied timestamp so we don't need an index
  • 8. Replica Pairs Deprecated by ReplSets in 1.6 Don't use!
  • 9. Replica Sets Evolution of Replica Pairs Reflects “lessons learned” Any number of nodes All keep a copy of the OpLog At any time one node is Primay If Primary fails, remaining nodes elect a new Primary with newest data
  • 10. Replica Set Gotchas When Primary fails, short period of time with no Primary Election requires a majority of nodes up Works best with 3 failure domains Writes not commited to quorum can be rolled-back Use getLastError with “W” Cascading not support yet (planned)
  • 11. Questions? Ask away! #mongodb on irc.freenode.net [email_address] [email_address] Thanks for coming!