SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (20)

Sharding
ShardingSharding
Sharding
MongoDB
 
MongoDB Sharding Fundamentals
MongoDB Sharding Fundamentals MongoDB Sharding Fundamentals
MongoDB Sharding Fundamentals
Antonios Giannopoulos
 
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
MongoDB
 
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
Ajay Gupte
 
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
 
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...
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
 
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
MongoDB
 
Sharding Methods for MongoDB
Sharding Methods for MongoDBSharding Methods for MongoDB
Sharding Methods for MongoDB
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
 
MongoDB Auto-Sharding at Mongo Seattle
MongoDB Auto-Sharding at Mongo SeattleMongoDB Auto-Sharding at Mongo Seattle
MongoDB Auto-Sharding at Mongo Seattle
MongoDB
 
Sharding
ShardingSharding
Sharding
MongoDB
 
Scaling with MongoDB
Scaling with MongoDBScaling with MongoDB
Scaling with MongoDB
Rick Copeland
 
Performance Tuning and Optimization
Performance Tuning and OptimizationPerformance Tuning and Optimization
Performance Tuning and Optimization
MongoDB
 
Mongodb sharding
Mongodb shardingMongodb sharding
Mongodb sharding
xiangrong
 
Migrating to MongoDB: Best Practices
Migrating to MongoDB: Best PracticesMigrating to MongoDB: Best Practices
Migrating to MongoDB: Best Practices
MongoDB
 
Challenges with MongoDB
Challenges with MongoDBChallenges with MongoDB
Challenges with MongoDB
Stone Gao
 
MongoDB - External Authentication
MongoDB - External AuthenticationMongoDB - External Authentication
MongoDB - External Authentication
Jason Terpko
 
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
 
MongoDB Roadmap
MongoDB RoadmapMongoDB Roadmap
MongoDB Roadmap
MongoDB
 
Sharding
ShardingSharding
Sharding
MongoDB
 
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
MongoDB
 
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
Ajay Gupte
 
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
 
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...
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
 
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
MongoDB
 
Sharding Methods for MongoDB
Sharding Methods for MongoDBSharding Methods for MongoDB
Sharding Methods for MongoDB
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
 
MongoDB Auto-Sharding at Mongo Seattle
MongoDB Auto-Sharding at Mongo SeattleMongoDB Auto-Sharding at Mongo Seattle
MongoDB Auto-Sharding at Mongo Seattle
MongoDB
 
Sharding
ShardingSharding
Sharding
MongoDB
 
Scaling with MongoDB
Scaling with MongoDBScaling with MongoDB
Scaling with MongoDB
Rick Copeland
 
Performance Tuning and Optimization
Performance Tuning and OptimizationPerformance Tuning and Optimization
Performance Tuning and Optimization
MongoDB
 
Mongodb sharding
Mongodb shardingMongodb sharding
Mongodb sharding
xiangrong
 
Migrating to MongoDB: Best Practices
Migrating to MongoDB: Best PracticesMigrating to MongoDB: Best Practices
Migrating to MongoDB: Best Practices
MongoDB
 
Challenges with MongoDB
Challenges with MongoDBChallenges with MongoDB
Challenges with MongoDB
Stone Gao
 
MongoDB - External Authentication
MongoDB - External AuthenticationMongoDB - External Authentication
MongoDB - External Authentication
Jason Terpko
 
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
 
MongoDB Roadmap
MongoDB RoadmapMongoDB Roadmap
MongoDB Roadmap
MongoDB
 

Similar to Exploring the replication in MongoDB (20)

Evolution Of MongoDB Replicaset
Evolution Of MongoDB ReplicasetEvolution Of MongoDB Replicaset
Evolution Of MongoDB Replicaset
M Malai
 
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
Mydbops
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica sets
Chris Westin
 
Introduction to Mongodb
Introduction to MongodbIntroduction to Mongodb
Introduction to Mongodb
Harun Yardımcı
 
Replication, Durability, and Disaster Recovery
Replication, Durability, and Disaster RecoveryReplication, Durability, and Disaster Recovery
Replication, Durability, and Disaster Recovery
Steven Francia
 
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
 
MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014
Ryusuke Kajiyama
 
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
 
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
Nelson Calero
 
Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)
MongoDB
 
Back tobasicswebinar part6-rev.
Back tobasicswebinar part6-rev.Back tobasicswebinar part6-rev.
Back tobasicswebinar part6-rev.
MongoDB
 
Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101
MongoDB
 
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
Daniel Coupal
 
Mongo DB
Mongo DBMongo DB
Mongo DB
Karan Kukreja
 
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
 
Deployment Strategies
Deployment StrategiesDeployment Strategies
Deployment Strategies
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
 
OrigoDB - take the red pill
OrigoDB - take the red pillOrigoDB - take the red pill
OrigoDB - take the red pill
Robert Friberg
 
Evolution Of MongoDB Replicaset
Evolution Of MongoDB ReplicasetEvolution Of MongoDB Replicaset
Evolution Of MongoDB Replicaset
M Malai
 
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
Mydbops
 
Replication and replica sets
Replication and replica setsReplication and replica sets
Replication and replica sets
Chris Westin
 
Replication, Durability, and Disaster Recovery
Replication, Durability, and Disaster RecoveryReplication, Durability, and Disaster Recovery
Replication, Durability, and Disaster Recovery
Steven Francia
 
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
 
MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014MySQL Performance Tuning at COSCUP 2014
MySQL Performance Tuning at COSCUP 2014
Ryusuke Kajiyama
 
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
 
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
Nelson Calero
 
Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)
MongoDB
 
Back tobasicswebinar part6-rev.
Back tobasicswebinar part6-rev.Back tobasicswebinar part6-rev.
Back tobasicswebinar part6-rev.
MongoDB
 
Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101Ops Jumpstart: MongoDB Administration 101
Ops Jumpstart: MongoDB Administration 101
MongoDB
 
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
Daniel Coupal
 
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
 
Deployment Strategies
Deployment StrategiesDeployment Strategies
Deployment Strategies
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
 
OrigoDB - take the red pill
OrigoDB - take the red pillOrigoDB - take the red pill
OrigoDB - take the red pill
Robert Friberg
 
Ad

Recently uploaded (20)

TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
Ad

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