SlideShare a Scribd company logo
Replica Sets (MongoDB v1.6) Dwight Merriman (@dmerr) 10gen dmerr.tumblr.com
Basics MongoDB replication is a bit like MySQL replication Asynchronous master/slave at its core Variations: Master / slave Replica Pairs (deprecated – use replica sets) Replica Sets (today’s topic)
Replica Sets A cluster of N servers Any (one) node can be primary Consensus election of primary Automatic failover Automatic recovery All writes to primary Reads can be to primary (default) or a secondary v1.6
With Sharding
Replica Sets – Design Concepts A write is only truly committed once it has replicated to a majority of servers in the set.   Thus, for important writes, the developer waits for confirmation of the cluster-wide commit with the getLastError command. Writes which are committed at the master of the set may be visible before the true cluster-wide commit has occurred.  This property, which is more relaxed than some traditional products, makes theoretically achievable performance and availability higher. On a failover, if there is data which has not replicated form the primary, the data is dropped (see #1).
A Set Member 1 Member 2 Member 3
A Set Member 1 Member 2 PRIMARY Member 3
A Set Member 1 Member 2 DOWN Member 3 PRIMARY negotiate new master
A Set Member 1 Member 2 DOWN Member 3 PRIMARY
A Set Member 1 Member 2 RECOVER-ING Member 3 PRIMARY
A Set Member 1 Member 2 Member 3 PRIMARY
Configuration { _id : <setname>, members: [ { _id : <ordinal>, host : <hostname[:port]>, [, priority: <priority>] [, arbiterOnly : true] [, votes : n]   [, slaveDelay : s] [, hidden : true ] } , ... ], settings: { [getLastErrorDefaults: <lasterrdefaults>] [, heartbeatSleep : <seconds>] [, heartbeatTimeout : <seconds>] [, heartbeatConnRetries : <n>] } }
Initiation > cfg = { ... _id : &quot;acme_a&quot;, ... members : [ ... { _id : 0, host : &quot;sf1.acme.com&quot; }, ... { _id : 1, host : &quot;sf2.acme.com&quot; }, ... { _id : 2, host : &quot;sf3.acme.com&quot; } ] } > use admin > db.runCommand({replSetInitiate:cfg})
Set Member Types Normal (priority == 1) Passive (priority == 0) DR (priority < 1.0)  (coming soon) Arbiter (no data, but can vote)
Commands {  isMaster  : 1 } {  replSetGetStatus  : 1 } { replSetInitiate : <config> } { replSetStepDown : true } { replSetReconfig : <config> } > rs.help()
Demo
Questions? Contact 10gen for on-site advisory sessions on MongoDB architecture, schema design, performance tuning, training… [email_address] irc://irc.freenode.net/#mongodb http://groups.google.com/group/mongodb-user

More Related Content

PDF
MongoDB World 2019: MongoDB Atlas Security 101 for Developers
MongoDB
 
PDF
CAPS: What's best for deploying and managing OpenStack? Chef vs. Ansible vs. ...
Animesh Singh
 
PDF
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
ScaleGrid.io
 
PDF
Build microservice with gRPC in golang
Ting-Li Chou
 
PDF
Microservices & API Gateways
Kong Inc.
 
PDF
Kubernetes Security with Calico and Open Policy Agent
CloudOps2005
 
PPTX
Attacking GraphQL
KavishaSheth1
 
PPTX
MongoDB at Scale
MongoDB
 
MongoDB World 2019: MongoDB Atlas Security 101 for Developers
MongoDB
 
CAPS: What's best for deploying and managing OpenStack? Chef vs. Ansible vs. ...
Animesh Singh
 
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
ScaleGrid.io
 
Build microservice with gRPC in golang
Ting-Li Chou
 
Microservices & API Gateways
Kong Inc.
 
Kubernetes Security with Calico and Open Policy Agent
CloudOps2005
 
Attacking GraphQL
KavishaSheth1
 
MongoDB at Scale
MongoDB
 

What's hot (20)

PPTX
Cypress Automation
Susantha Pathirana
 
PDF
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Jean-François Gagné
 
PDF
Docker swarm introduction
Evan Lin
 
PDF
eBPF - Observability In Deep
Mydbops
 
PDF
Ansible tips & tricks
bcoca
 
PPTX
Automating with Ansible
Ricardo Schmidt
 
PDF
Docker and the Linux Kernel
Docker, Inc.
 
PDF
Container Security Deep Dive & Kubernetes
Aqua Security
 
PDF
ClickHouse on Kubernetes! By Robert Hodges, Altinity CEO
Altinity Ltd
 
PDF
Kubernetes Introduction
Peng Xiao
 
PPTX
Redis and its Scaling and Obersvability
AbhishekDubey902839
 
PPTX
React workshop
Imran Sayed
 
PDF
New features in ProxySQL 2.0 (updated to 2.0.9) by Rene Cannao (ProxySQL)
Altinity Ltd
 
PPTX
Prometheus 101
Paul Podolny
 
PDF
A Hands-on Introduction to Docker
CodeOps Technologies LLP
 
PDF
Kubernetes in Docker
Docker, Inc.
 
PDF
gRPC and Microservices
Jonathan Gomez
 
PDF
Ansible - Hands on Training
Mehmet Ali Aydın
 
PDF
Replication Troubleshooting in Classic VS GTID
Mydbops
 
PDF
JMeter - Performance testing your webapp
Amit Solanki
 
Cypress Automation
Susantha Pathirana
 
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
Jean-François Gagné
 
Docker swarm introduction
Evan Lin
 
eBPF - Observability In Deep
Mydbops
 
Ansible tips & tricks
bcoca
 
Automating with Ansible
Ricardo Schmidt
 
Docker and the Linux Kernel
Docker, Inc.
 
Container Security Deep Dive & Kubernetes
Aqua Security
 
ClickHouse on Kubernetes! By Robert Hodges, Altinity CEO
Altinity Ltd
 
Kubernetes Introduction
Peng Xiao
 
Redis and its Scaling and Obersvability
AbhishekDubey902839
 
React workshop
Imran Sayed
 
New features in ProxySQL 2.0 (updated to 2.0.9) by Rene Cannao (ProxySQL)
Altinity Ltd
 
Prometheus 101
Paul Podolny
 
A Hands-on Introduction to Docker
CodeOps Technologies LLP
 
Kubernetes in Docker
Docker, Inc.
 
gRPC and Microservices
Jonathan Gomez
 
Ansible - Hands on Training
Mehmet Ali Aydın
 
Replication Troubleshooting in Classic VS GTID
Mydbops
 
JMeter - Performance testing your webapp
Amit Solanki
 
Ad

Viewers also liked (17)

PPTX
Advanced Replication
MongoDB
 
PDF
Setting up mongo replica set
Sudheer Kondla
 
PPTX
Webinar: MongoDB 2.4 Feature Demo and Q&A on Hash-based Sharding
MongoDB
 
PPTX
Lightning Talk: What You Need to Know Before You Shard in 20 Minutes
MongoDB
 
PPTX
Sharding Methods for MongoDB
MongoDB
 
PDF
Spring Data MongoDB Webiner
Hakan Özler
 
PPTX
Webinar: Replication and Replica Sets
MongoDB
 
PPTX
Getting started with replica set in MongoDB
Kishor Parkhe
 
PPTX
Back to Basics: Build Something Big With MongoDB
MongoDB
 
PDF
MongoDB Database Replication
Mehdi Valikhani
 
PPTX
MongoDB Replication (Dwight Merriman)
MongoSF
 
PDF
MongoDb scalability and high availability with Replica-Set
Vivek Parihar
 
PDF
Configuring MongoDB HA Replica Set on AWS EC2
ShepHertz
 
PDF
MongoDB Administration 101
MongoDB
 
PPT
Everything You Need to Know About Sharding
MongoDB
 
PPT
High Availabiltity & Replica Sets with mongoDB
Gareth Davies
 
PPTX
Back to Basics Webinar 3: Introduction to Replica Sets
MongoDB
 
Advanced Replication
MongoDB
 
Setting up mongo replica set
Sudheer Kondla
 
Webinar: MongoDB 2.4 Feature Demo and Q&A on Hash-based Sharding
MongoDB
 
Lightning Talk: What You Need to Know Before You Shard in 20 Minutes
MongoDB
 
Sharding Methods for MongoDB
MongoDB
 
Spring Data MongoDB Webiner
Hakan Özler
 
Webinar: Replication and Replica Sets
MongoDB
 
Getting started with replica set in MongoDB
Kishor Parkhe
 
Back to Basics: Build Something Big With MongoDB
MongoDB
 
MongoDB Database Replication
Mehdi Valikhani
 
MongoDB Replication (Dwight Merriman)
MongoSF
 
MongoDb scalability and high availability with Replica-Set
Vivek Parihar
 
Configuring MongoDB HA Replica Set on AWS EC2
ShepHertz
 
MongoDB Administration 101
MongoDB
 
Everything You Need to Know About Sharding
MongoDB
 
High Availabiltity & Replica Sets with mongoDB
Gareth Davies
 
Back to Basics Webinar 3: Introduction to Replica Sets
MongoDB
 
Ad

Similar to MongoDB Replica Sets (20)

PDF
Replication MongoDB Days 2013
Randall Hunt
 
PPTX
Basic Replication in MongoDB
MongoDB
 
PPTX
Replication and replica sets
Randall Hunt
 
PPTX
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
MongoDB
 
PDF
2013 london advanced-replication
Marc Schwering
 
PPTX
Scaling with MongoDB
MongoDB
 
PPTX
Python mongo db-training-europython-2011
Andreas Jung
 
PPTX
Webinar: Replication and Replica Sets
MongoDB
 
PPTX
Replication and Replica Sets
MongoDB
 
PDF
MariaDB, MySQL and Ansible: automating database infrastructures
Federico Razzoli
 
PPT
MySQL 5.1 Replication
Ligaya Turmelle
 
ODP
MySQL HA with PaceMaker
Kris Buytaert
 
PPTX
Replication and Replica Sets
MongoDB
 
PPTX
Analysis of Conf File Parameters in the Odoo 18
Celine George
 
PPT
A Life of breakpoint
Hajime Morrita
 
ODP
JUDCon London 2011 - Bin packing with drools planner by example
Geoffrey De Smet
 
ODP
High Availability in 37 Easy Steps
Tim Serong
 
PPT
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
addame
 
PDF
Valerii Vasylkov Erlang. measurements and benefits.
Аліна Шепшелей
 
PDF
SE2016 Exotic Valerii Vasylkov "Erlang. Measurements and benefits"
Inhacking
 
Replication MongoDB Days 2013
Randall Hunt
 
Basic Replication in MongoDB
MongoDB
 
Replication and replica sets
Randall Hunt
 
MongoDB London 2013: Basic Replication in MongoDB presented by Marc Schwering...
MongoDB
 
2013 london advanced-replication
Marc Schwering
 
Scaling with MongoDB
MongoDB
 
Python mongo db-training-europython-2011
Andreas Jung
 
Webinar: Replication and Replica Sets
MongoDB
 
Replication and Replica Sets
MongoDB
 
MariaDB, MySQL and Ansible: automating database infrastructures
Federico Razzoli
 
MySQL 5.1 Replication
Ligaya Turmelle
 
MySQL HA with PaceMaker
Kris Buytaert
 
Replication and Replica Sets
MongoDB
 
Analysis of Conf File Parameters in the Odoo 18
Celine George
 
A Life of breakpoint
Hajime Morrita
 
JUDCon London 2011 - Bin packing with drools planner by example
Geoffrey De Smet
 
High Availability in 37 Easy Steps
Tim Serong
 
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
addame
 
Valerii Vasylkov Erlang. measurements and benefits.
Аліна Шепшелей
 
SE2016 Exotic Valerii Vasylkov "Erlang. Measurements and benefits"
Inhacking
 

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
 

Recently uploaded (20)

PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 

MongoDB Replica Sets

  • 1. Replica Sets (MongoDB v1.6) Dwight Merriman (@dmerr) 10gen dmerr.tumblr.com
  • 2. Basics MongoDB replication is a bit like MySQL replication Asynchronous master/slave at its core Variations: Master / slave Replica Pairs (deprecated – use replica sets) Replica Sets (today’s topic)
  • 3. Replica Sets A cluster of N servers Any (one) node can be primary Consensus election of primary Automatic failover Automatic recovery All writes to primary Reads can be to primary (default) or a secondary v1.6
  • 5. Replica Sets – Design Concepts A write is only truly committed once it has replicated to a majority of servers in the set.  Thus, for important writes, the developer waits for confirmation of the cluster-wide commit with the getLastError command. Writes which are committed at the master of the set may be visible before the true cluster-wide commit has occurred.  This property, which is more relaxed than some traditional products, makes theoretically achievable performance and availability higher. On a failover, if there is data which has not replicated form the primary, the data is dropped (see #1).
  • 6. A Set Member 1 Member 2 Member 3
  • 7. A Set Member 1 Member 2 PRIMARY Member 3
  • 8. A Set Member 1 Member 2 DOWN Member 3 PRIMARY negotiate new master
  • 9. A Set Member 1 Member 2 DOWN Member 3 PRIMARY
  • 10. A Set Member 1 Member 2 RECOVER-ING Member 3 PRIMARY
  • 11. A Set Member 1 Member 2 Member 3 PRIMARY
  • 12. Configuration { _id : <setname>, members: [ { _id : <ordinal>, host : <hostname[:port]>, [, priority: <priority>] [, arbiterOnly : true] [, votes : n] [, slaveDelay : s] [, hidden : true ] } , ... ], settings: { [getLastErrorDefaults: <lasterrdefaults>] [, heartbeatSleep : <seconds>] [, heartbeatTimeout : <seconds>] [, heartbeatConnRetries : <n>] } }
  • 13. Initiation > cfg = { ... _id : &quot;acme_a&quot;, ... members : [ ... { _id : 0, host : &quot;sf1.acme.com&quot; }, ... { _id : 1, host : &quot;sf2.acme.com&quot; }, ... { _id : 2, host : &quot;sf3.acme.com&quot; } ] } > use admin > db.runCommand({replSetInitiate:cfg})
  • 14. Set Member Types Normal (priority == 1) Passive (priority == 0) DR (priority < 1.0) (coming soon) Arbiter (no data, but can vote)
  • 15. Commands { isMaster : 1 } { replSetGetStatus : 1 } { replSetInitiate : <config> } { replSetStepDown : true } { replSetReconfig : <config> } > rs.help()
  • 16. Demo
  • 17. Questions? Contact 10gen for on-site advisory sessions on MongoDB architecture, schema design, performance tuning, training… [email_address] irc://irc.freenode.net/#mongodb http://groups.google.com/group/mongodb-user