SlideShare a Scribd company logo
1 of 32
Download to read offline
Exploring the replication in
MongoDB
Date: Oct-4-2016
About us
Lead Database Consultant @Pythian
OSDB managed services since 2014
https://mk.linkedin.com/in/igorle
@igorLE
Database Consultant @Pythian
OSDB managed services since 2014
https://tr.linkedin.com/in/okanbuyukyilmaz
Overview
• Why Replication, replication definition
• How replication works, replication concepts
• Replica set features, deployment architectures
• Replica set configuration options
• Key metrics to monitor when running replica set
• MySQL replication compared to MongoDB replication
• Galera replication compared to MongoDB replication
Definition
• Group of mongod processes that maintain the same
data set
• Redundancy and high availability
• Increased read capacity
Replication concept
• Write operations go to the Primary node
• All changes are recorded into operations log - oplog
• Asynchronous replication
• Secondaries replicate the Primary oplog
• Secondary can use sync source other Secondary
• One Arbiter node per replica set
• Automatic failover. Any node can become Primary
Replication concept
Replica set oplog
• Special capped collection that keeps a rolling record of
all operations that modify the data stored in the
databases
• Idempotent
• Default oplog size
For Unix and Windows systems
Storage Engine Default Oplog Size Lower Bound Upper Bound
In-memory 5% of physical memory 50MB 50GB
WiredTiger 5% of free disk space 990MB 50GB
MMAPv1 5% of free disk space 990MB 50GB
Replica set oplog
● Workloads that might require larger oplog size
○ updates to multiple documents at once
○ Deletions equal the same amount of data as inserts
○ Significant number of in-place updates
● Oplog status
○ rs.printReplicationInfo() - on a Secondary node
○ rs.printSlaveReplicationInfo() - on a Primary node
○ db.getReplicationInfo() - by using the local database
Deployment
MongoDB configuration file: /etc/mongod.conf
Before MongoDB 3.0
replSet=MyRepl
oplogSize=4096MB
YAML format since 3.0
replication:
replSetName: MyRepl
oplogSizeMB: 4096
Deployment
• 3 node replica set
Node1
Node2 Node3
Deployment
Node1
/usr/bin/mongod -f mongod.conf
> rs.initialize()
Node2 Node3
Primary
Deployment
• rs.add()
• rs.add(“node2:27017”)
Node3
Deployment
• rs.add()
• rs.add(“node3:27017”)
Replica set maintenance
• rs.status()
• rs.conf()
• rs.reconfig()
• rs.remove()
• rs.stepDown()
• rs.freeze()
• rs.isMaster()
• rs.syncFrom()
• rs.printReplicationInfo()
• rs.printSlaveReplicationInfo()
Configuration options
• 50 members per replica set (7 voting members)
• Arbiter node
• Hidden node
• Priority 0 node
• Delayed node
• Build indexes
• Fault tolerance
• Write concern
• Read preference
Configuration options
rsTest:PRIMARY> rs.conf()
{ "_id" : "rsTest",
"version" : 2,
"members" : [
{
"_id" : 0,
"host" : "node1:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {"dc" : "apac"},
"slaveDelay" : 0,
"votes" : 1
},
Arbiter node
• Votes in elections
• Does not hold copy of data
{
"_id" : <num>
"host" : <hostname:port>,
"arbiterOnly" : true,
….
}
hidden : true
Hidden node
• Never becomes primary
• Not visible to application
• Use cases
○ reporting
○ backups
{
"_id" : <num>
"host" : <hostname:port>,
"priority" : 0,
"hidden" : true
}
hidden : true
Priority 0 node
Priority - floating point (i.e. decimal) number between 0 and 1000
• Hidden members and Delayed slave with priority 0 by default
• Never becomes primary
• Visible to application
{
"_id" : <num>
"host" : <hostname:port>,
"priority" : 0
}
Delayed node
• must be priority 0 member
• should be hidden member (not mandatory)
• has votes 1 by default
• considerations (oplog size)
• mainly used for backups
{
"_id" : <num>,
"host" : <hostname:port>,
"priority" : 0,
"slaveDelay" : <seconds>,
"hidden" : true
}
Build indexes
members[n].buildIndexes : false
• Can be only set when adding a member to a replica set
• Can not be changed on running node
• Indexes on _id will still exist
• Priority must be set to 0, recommended as hidden:true
Useful when
• Node is used for backups using mongodump
• Node does not receive queries from clients
• Adding indexes and maintenance overburdens the host
system
Fault tolerance
Number of members Majority Required to Elect new Primary Fault Tolerance
3 2 1
4 3 1
5 3 2
6 4 2
7 4 3
Write concern
Write concern
Write concern specification
{ w: <value>, j: <boolean>, wtimeout: <number> }
• w - number
– Option for “majority”
• j - write operation has been written to the journal
• wtimeout - time limit, in milliseconds, for the write concern
Replica set get write concern setting
rsTest:PRIMARY> rs.conf().settings['getLastErrorDefaults']
{ "w" : 1, "wtimeout" : 0 }
Read preference
• primary
• primaryPreferred
• secondary
• secondaryPreferred
• nearest
Key metrics to monitor for RS
• Replica set has no Primary
• Number of healthy/unhealthy members
• Replication Oplog Window
• Replication lag
What is MySQL
Mysql is…
● Transactional
● Relational
● Well documented
● Open source
MySQL replication
Mysql Replication can be...
● Asynchronous
○ Built-in replication feature
○ Semi-synchronous by plugin rpl_semi_sync_master
● Synchronous
○ Galera setup with wsrep api
MySQL replication
• Group of mysqld processes that maintain the same data set
• Write operations go to the Master node, reads can go to
Slave
• All changes are recorded into binary log on the master
• Asynchronous replication, Semi-Synchronous replication
• Slave node replicates the events by copying binary logs as
relay logs
– IO Thread, SQL Thread
– Binary Logs format - Statement, Row, Mixed
• Expire logs days dynamic
• Replication filters
MySQL replication
MySQL Master
MySQL Process
Binary LogsMySQL Data
MySQL Slave
MySQL Process
SQL Thread
Relay logs
IO Thread MySQL Data
Questions?
We’re Hiring!
https://pythian.com

More Related Content

What's hot

2014 05-07-fr - add dev series - session 6 - deploying your application-2
2014 05-07-fr - add dev series - session 6 - deploying your application-22014 05-07-fr - add dev series - session 6 - deploying your application-2
2014 05-07-fr - add dev series - session 6 - deploying your application-2
MongoDB
 
Basic Sharding in MongoDB presented by Shaun Verch
Basic Sharding in MongoDB presented by Shaun VerchBasic Sharding in MongoDB presented by Shaun Verch
Basic Sharding in MongoDB presented by Shaun Verch
MongoDB
 
MongoDB Roadmap
MongoDB RoadmapMongoDB Roadmap
MongoDB Roadmap
MongoDB
 

What's hot (20)

Sharding
ShardingSharding
Sharding
 
MongoDB Sharding Fundamentals
MongoDB Sharding Fundamentals MongoDB Sharding Fundamentals
MongoDB Sharding Fundamentals
 
Back to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production DeploymentBack to Basics Webinar 6: Production Deployment
Back to Basics Webinar 6: Production Deployment
 
NoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB World
NoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB WorldNoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB World
NoSQL Analytics: JSON Data Analysis and Acceleration in MongoDB World
 
2014 05-07-fr - add dev series - session 6 - deploying your application-2
2014 05-07-fr - add dev series - session 6 - deploying your application-22014 05-07-fr - add dev series - session 6 - deploying your application-2
2014 05-07-fr - add dev series - session 6 - deploying your application-2
 
MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...
MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...
MongoDB San Francisco 2013: Basic Sharding in MongoDB presented by Brandon Bl...
 
Basic Sharding in MongoDB presented by Shaun Verch
Basic Sharding in MongoDB presented by Shaun VerchBasic Sharding in MongoDB presented by Shaun Verch
Basic Sharding in MongoDB presented by Shaun Verch
 
Back to Basics 2017: Introduction to Sharding
Back to Basics 2017: Introduction to ShardingBack to Basics 2017: Introduction to Sharding
Back to Basics 2017: Introduction to Sharding
 
Sharding Methods for MongoDB
Sharding Methods for MongoDBSharding Methods for MongoDB
Sharding Methods for MongoDB
 
Everything You Need to Know About Sharding
Everything You Need to Know About ShardingEverything You Need to Know About Sharding
Everything You Need to Know About Sharding
 
MongoDB Auto-Sharding at Mongo Seattle
MongoDB Auto-Sharding at Mongo SeattleMongoDB Auto-Sharding at Mongo Seattle
MongoDB Auto-Sharding at Mongo Seattle
 
Sharding
ShardingSharding
Sharding
 
Scaling with MongoDB
Scaling with MongoDBScaling with MongoDB
Scaling with MongoDB
 
Performance Tuning and Optimization
Performance Tuning and OptimizationPerformance Tuning and Optimization
Performance Tuning and Optimization
 
Mongodb sharding
Mongodb shardingMongodb sharding
Mongodb sharding
 
Migrating to MongoDB: Best Practices
Migrating to MongoDB: Best PracticesMigrating to MongoDB: Best Practices
Migrating to MongoDB: Best Practices
 
Challenges with MongoDB
Challenges with MongoDBChallenges with MongoDB
Challenges with MongoDB
 
MongoDB - External Authentication
MongoDB - External AuthenticationMongoDB - External Authentication
MongoDB - External Authentication
 
Webinar: Was ist neu in MongoDB 2.4
Webinar: Was ist neu in MongoDB 2.4Webinar: Was ist neu in MongoDB 2.4
Webinar: Was ist neu in MongoDB 2.4
 
MongoDB Roadmap
MongoDB RoadmapMongoDB Roadmap
MongoDB Roadmap
 

Similar to Exploring the replication in MongoDB

Back to Basics: Build Something Big With MongoDB
Back to Basics: Build Something Big With MongoDB Back to Basics: Build Something Big With MongoDB
Back to Basics: Build Something Big With MongoDB
MongoDB
 
Deployment Strategy
Deployment StrategyDeployment Strategy
Deployment Strategy
MongoDB
 
Webinar: Serie Operazioni per la vostra applicazione - Sessione 6 - Installar...
Webinar: Serie Operazioni per la vostra applicazione - Sessione 6 - Installar...Webinar: Serie Operazioni per la vostra applicazione - Sessione 6 - Installar...
Webinar: Serie Operazioni per la vostra applicazione - Sessione 6 - Installar...
MongoDB
 
Back tobasicswebinar part6-rev.
Back tobasicswebinar part6-rev.Back tobasicswebinar part6-rev.
Back tobasicswebinar part6-rev.
MongoDB
 
Monitoring MongoDB’s Engines in the Wild
Monitoring MongoDB’s Engines in the WildMonitoring MongoDB’s Engines in the Wild
Monitoring MongoDB’s Engines in the Wild
Tim Vaillancourt
 
MongoDB at MapMyFitness from a DevOps Perspective
MongoDB at MapMyFitness from a DevOps PerspectiveMongoDB at MapMyFitness from a DevOps Perspective
MongoDB at MapMyFitness from a DevOps Perspective
MongoDB
 
The Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb ClusterThe Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb Cluster
Chris Henry
 

Similar to Exploring the replication in MongoDB (20)

Evolution Of MongoDB Replicaset
Evolution Of MongoDB ReplicasetEvolution Of MongoDB Replicaset
Evolution Of MongoDB Replicaset
 
Evolution of MongoDB Replicaset and Its Best Practices
Evolution of MongoDB Replicaset and Its Best PracticesEvolution of MongoDB Replicaset and Its Best Practices
Evolution of MongoDB Replicaset and Its Best Practices
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica sets
 
Introduction to Mongodb
Introduction to MongodbIntroduction to Mongodb
Introduction to Mongodb
 
Replication, Durability, and Disaster Recovery
Replication, Durability, and Disaster RecoveryReplication, Durability, and Disaster Recovery
Replication, Durability, and Disaster Recovery
 
Back to Basics: Build Something Big With MongoDB
Back to Basics: Build Something Big With MongoDB Back to Basics: Build Something Big With MongoDB
Back to Basics: Build Something Big With MongoDB
 
MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014
 
Deployment Strategy
Deployment StrategyDeployment Strategy
Deployment Strategy
 
Webinar: Serie Operazioni per la vostra applicazione - Sessione 6 - Installar...
Webinar: Serie Operazioni per la vostra applicazione - Sessione 6 - Installar...Webinar: Serie Operazioni per la vostra applicazione - Sessione 6 - Installar...
Webinar: Serie Operazioni per la vostra applicazione - Sessione 6 - Installar...
 
Collaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAsCollaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAs
 
Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)
 
Back tobasicswebinar part6-rev.
Back tobasicswebinar part6-rev.Back tobasicswebinar part6-rev.
Back tobasicswebinar part6-rev.
 
Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101
 
Silicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Silicon Valley Code Camp 2015 - Advanced MongoDB - The SequelSilicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
Silicon Valley Code Camp 2015 - Advanced MongoDB - The Sequel
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
Monitoring MongoDB’s Engines in the Wild
Monitoring MongoDB’s Engines in the WildMonitoring MongoDB’s Engines in the Wild
Monitoring MongoDB’s Engines in the Wild
 
MongoDB at MapMyFitness from a DevOps Perspective
MongoDB at MapMyFitness from a DevOps PerspectiveMongoDB at MapMyFitness from a DevOps Perspective
MongoDB at MapMyFitness from a DevOps Perspective
 
Deployment Strategies
Deployment StrategiesDeployment Strategies
Deployment Strategies
 
The Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb ClusterThe Care + Feeding of a Mongodb Cluster
The Care + Feeding of a Mongodb Cluster
 
OrigoDB - take the red pill
OrigoDB - take the red pillOrigoDB - take the red pill
OrigoDB - take the red pill
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Exploring the replication in MongoDB

  • 1. Exploring the replication in MongoDB Date: Oct-4-2016
  • 2. About us Lead Database Consultant @Pythian OSDB managed services since 2014 https://mk.linkedin.com/in/igorle @igorLE Database Consultant @Pythian OSDB managed services since 2014 https://tr.linkedin.com/in/okanbuyukyilmaz
  • 3. Overview • Why Replication, replication definition • How replication works, replication concepts • Replica set features, deployment architectures • Replica set configuration options • Key metrics to monitor when running replica set • MySQL replication compared to MongoDB replication • Galera replication compared to MongoDB replication
  • 4. Definition • Group of mongod processes that maintain the same data set • Redundancy and high availability • Increased read capacity
  • 5. Replication concept • Write operations go to the Primary node • All changes are recorded into operations log - oplog • Asynchronous replication • Secondaries replicate the Primary oplog • Secondary can use sync source other Secondary • One Arbiter node per replica set • Automatic failover. Any node can become Primary
  • 7. Replica set oplog • Special capped collection that keeps a rolling record of all operations that modify the data stored in the databases • Idempotent • Default oplog size For Unix and Windows systems Storage Engine Default Oplog Size Lower Bound Upper Bound In-memory 5% of physical memory 50MB 50GB WiredTiger 5% of free disk space 990MB 50GB MMAPv1 5% of free disk space 990MB 50GB
  • 8. Replica set oplog ● Workloads that might require larger oplog size ○ updates to multiple documents at once ○ Deletions equal the same amount of data as inserts ○ Significant number of in-place updates ● Oplog status ○ rs.printReplicationInfo() - on a Secondary node ○ rs.printSlaveReplicationInfo() - on a Primary node ○ db.getReplicationInfo() - by using the local database
  • 9. Deployment MongoDB configuration file: /etc/mongod.conf Before MongoDB 3.0 replSet=MyRepl oplogSize=4096MB YAML format since 3.0 replication: replSetName: MyRepl oplogSizeMB: 4096
  • 10. Deployment • 3 node replica set Node1 Node2 Node3
  • 11. Deployment Node1 /usr/bin/mongod -f mongod.conf > rs.initialize() Node2 Node3 Primary
  • 14. Replica set maintenance • rs.status() • rs.conf() • rs.reconfig() • rs.remove() • rs.stepDown() • rs.freeze() • rs.isMaster() • rs.syncFrom() • rs.printReplicationInfo() • rs.printSlaveReplicationInfo()
  • 15. Configuration options • 50 members per replica set (7 voting members) • Arbiter node • Hidden node • Priority 0 node • Delayed node • Build indexes • Fault tolerance • Write concern • Read preference
  • 16. Configuration options rsTest:PRIMARY> rs.conf() { "_id" : "rsTest", "version" : 2, "members" : [ { "_id" : 0, "host" : "node1:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 1, "tags" : {"dc" : "apac"}, "slaveDelay" : 0, "votes" : 1 },
  • 17. Arbiter node • Votes in elections • Does not hold copy of data { "_id" : <num> "host" : <hostname:port>, "arbiterOnly" : true, …. } hidden : true
  • 18. Hidden node • Never becomes primary • Not visible to application • Use cases ○ reporting ○ backups { "_id" : <num> "host" : <hostname:port>, "priority" : 0, "hidden" : true } hidden : true
  • 19. Priority 0 node Priority - floating point (i.e. decimal) number between 0 and 1000 • Hidden members and Delayed slave with priority 0 by default • Never becomes primary • Visible to application { "_id" : <num> "host" : <hostname:port>, "priority" : 0 }
  • 20. Delayed node • must be priority 0 member • should be hidden member (not mandatory) • has votes 1 by default • considerations (oplog size) • mainly used for backups { "_id" : <num>, "host" : <hostname:port>, "priority" : 0, "slaveDelay" : <seconds>, "hidden" : true }
  • 21. Build indexes members[n].buildIndexes : false • Can be only set when adding a member to a replica set • Can not be changed on running node • Indexes on _id will still exist • Priority must be set to 0, recommended as hidden:true Useful when • Node is used for backups using mongodump • Node does not receive queries from clients • Adding indexes and maintenance overburdens the host system
  • 22. Fault tolerance Number of members Majority Required to Elect new Primary Fault Tolerance 3 2 1 4 3 1 5 3 2 6 4 2 7 4 3
  • 24. Write concern Write concern specification { w: <value>, j: <boolean>, wtimeout: <number> } • w - number – Option for “majority” • j - write operation has been written to the journal • wtimeout - time limit, in milliseconds, for the write concern Replica set get write concern setting rsTest:PRIMARY> rs.conf().settings['getLastErrorDefaults'] { "w" : 1, "wtimeout" : 0 }
  • 25. Read preference • primary • primaryPreferred • secondary • secondaryPreferred • nearest
  • 26. Key metrics to monitor for RS • Replica set has no Primary • Number of healthy/unhealthy members • Replication Oplog Window • Replication lag
  • 27. What is MySQL Mysql is… ● Transactional ● Relational ● Well documented ● Open source
  • 28. MySQL replication Mysql Replication can be... ● Asynchronous ○ Built-in replication feature ○ Semi-synchronous by plugin rpl_semi_sync_master ● Synchronous ○ Galera setup with wsrep api
  • 29. MySQL replication • Group of mysqld processes that maintain the same data set • Write operations go to the Master node, reads can go to Slave • All changes are recorded into binary log on the master • Asynchronous replication, Semi-Synchronous replication • Slave node replicates the events by copying binary logs as relay logs – IO Thread, SQL Thread – Binary Logs format - Statement, Row, Mixed • Expire logs days dynamic • Replication filters
  • 30. MySQL replication MySQL Master MySQL Process Binary LogsMySQL Data MySQL Slave MySQL Process SQL Thread Relay logs IO Thread MySQL Data