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
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 

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!