SlideShare a Scribd company logo
PHP Failover site / MySQL Failover
CubeXS Weatherly (Pvt) Ltd.
• What is Failover / DR / Redundant Site
• What is Replication
• How database replication works
• Advantages of Replication
• Types of Database Replications
• How to setup replication
• How to Monitor Replication
• Failover Steps
• Reverse Failover Steps
Index
Failover is a procedure by which a system automatically transfers control to
a duplicate system when it detects a fault or failure. A failover can be
Automatic or Manual
What is Failover?
Replication enables data from one server (the master) to be replicated to
one or more servers (the slaves).
What is Replication?
MySQL Replication is asynchronous. slaves need not be connected
permanently to receive updates from the master. This means that updates
can occur over long-distance connections. Depending on the configuration,
you can replicate all databases, selected databases, or even selected tables
within a database
How MySQL Database
Replication works?
• Scale-out solutions
spreading the load among multiple slaves to improve performance. In this
environment, all writes and updates must take place on the master server.
Reads, however, may take place on one or more slaves. This model can improve
the performance of writes (since the master is dedicated to updates), while
dramatically increasing read speed across an increasing number of slaves.
• Data security
because data is replicated to the slave, and the slave can pause the replication
process, it is possible to run backup services on the slave without corrupting the
corresponding master data.
• Analytics
live data can be created on the master, while the analysis of the information
can take place on the slave without affecting the performance of the master.
• Long-distance data distribution
if a branch office would like to work with a copy of your main data, you can use
replication to create a local copy of the data for their use without requiring
permanent access to the master.
Advantages of MySQL
Database Replication
• Unidirectional Replication
• Bi-Directional Replication
• Directed Replication
• Multi Slave Replication
• Circular Replication
Types of MySQL Database
Replication
Data is replicated from single master to single slave server, it involves 2
servers. This setup is usually used for backups.
Unidirectional Replication
This setup involves 2 servers, both being masters to the other as well as
both being slaves to the other. This setup can be used as failover.
Bi-Directional Replication
This setup involves minimum 3 servers, “Server A” being master, “Server B”
and “Server C” being slave to “Server A”.
Multi Slave Replication
This setup involves minimum 3 servers, “Server A” being master, “Server B”
being slave to “Server A” as well as master to all other Slaves. This setup
increases performance of “Server A”, because All slaves are directly
connected to “Server B” and “Server A” only serves “Server B” for
replication
Directed Replication
This setup involves minimum 3 servers, “Server A” being master, “Server B”
being slave to “Server A” as well as master to “Server C”, and “Server C”
being slave to “Server B” as well as master to “Server A”
Circular Replication
1. Add below directives in MySQL configuration file (my.cnf) and restart
MySQL services
server-id=1
log-bin=mysql-bin
log-error=mysql-bin.err
2. Connect Master Server and Add Replication User (Recommended)
3. Connect each Slave Server and execute below command
mysql> CHANGE MASTER TO MASTER_HOST=‘master_ip',
MASTER_USER='replication_username', MASTER_PASSWORD='replication_password‘;
mysql> Start Slave;
How to Setup Replication
1. Connect to Slave Server and execute below statement to monitor status.
mysql> Show Slave Status;
2. Value of ‘Slave_IO_Running’ and ‘Slave_SQL_Running’ should be “YES”.
3. If either is “No”, There are possibilities that MySQL Replication is
broken.
How to Monitor Replication
If multiple slaves exists and all were configured to get updates from the “Slave A”.
(“Slave A” is down and we are switching our updates to “Slave B”) and we have to
configure “Slave C” to get updates from “Slave B”
1. On all slave server(s)
• mysql> STOP SLAVE IO_THREAD;
• mysql> SHOW SLAVE STATUS;
Wait for value of `Slave_IO_State` to be “Has read all relay log”
• mysql> STOP SLAVE;
2. On “Slave C”
• mysql> CHANGE MASTER TO MASTER_HOST=‘SLAVE_B_IP',
MASTER_USER=‘REPLICATION_USER',
MASTER_PASSWORD=‘REPLICATION_PASSWORD’;
• mysql> START SLAVE;
Failover Steps
If your initial master server is live again and you want to make it master (may be this
server is more powerful in aspect of computing power). You may follow below steps.
1. On all initial master server.
mysql> CHANGE MASTER TO MASTER_HOST=‘CURRENT_MASTER_IP',
MASTER_USER=‘REPLICATION_USER', MASTER_PASSWORD=‘REPLICATION_PASSWORD';
mysql> START SLAVE;
Wait for initial master to update it self.
mysql> Stop Slave;
2. Now you can follow failover steps for initial master server.
Reverse Failover Steps
www.cubexsweatherly.com
sales@cubexsweatherly.com
+92 21 111-282-397

More Related Content

PPTX
MySqL Failover by Weatherly Cloud Computing USA
PPT
Intro to MySQL Master Slave Replication
PDF
Time Machine
PPTX
MySQL Replication Overview -- PHPTek 2016
PPTX
Mule with stored procedure
PDF
SUSE Manager with Salt - Deploy and Config Management for MariaDB
PDF
My sql indo_comm
PPTX
Mysql data replication
MySqL Failover by Weatherly Cloud Computing USA
Intro to MySQL Master Slave Replication
Time Machine
MySQL Replication Overview -- PHPTek 2016
Mule with stored procedure
SUSE Manager with Salt - Deploy and Config Management for MariaDB
My sql indo_comm
Mysql data replication

What's hot (16)

PPTX
Stored Procedure With In Out Parameters in Mule 3.6
PPTX
N:1 Replication meets MHA
PPT
Download presentation
PDF
Introduction to Galera Cluster
PPTX
Distributed Performance testing by funkload
PPTX
Mule database connector
PPTX
Mule quartz hari_gatadi
PDF
Introduction to ClustrixDB
PPTX
Mule HDFS Connector
PPT
Oreilly Webcast Jan 09, 2009
PPTX
Easy MySQL Replication Setup and Troubleshooting
PPT
Galera webinar migration to galera cluster from my sql async replication
PDF
Introduction to Galera
PPTX
Mule Batch Commit
PPT
Using galera replication to create geo distributed clusters on the wan
Stored Procedure With In Out Parameters in Mule 3.6
N:1 Replication meets MHA
Download presentation
Introduction to Galera Cluster
Distributed Performance testing by funkload
Mule database connector
Mule quartz hari_gatadi
Introduction to ClustrixDB
Mule HDFS Connector
Oreilly Webcast Jan 09, 2009
Easy MySQL Replication Setup and Troubleshooting
Galera webinar migration to galera cluster from my sql async replication
Introduction to Galera
Mule Batch Commit
Using galera replication to create geo distributed clusters on the wan
Ad

Similar to MySQL Failover - Cubexs Weatherly (20)

DOCX
Mater,slave on mysql
PPT
MySQL Replication Basics
PDF
MySQL database replication
PPT
Mysql replication @ gnugroup
ODP
MySQL 101 PHPTek 2017
PDF
Highly Available Load Balanced Galera MySql Cluster
ODP
Mysql
PPT
Download presentation
PPT
Download presentation531
PDF
Webinar Slides: MySQL Multi-Site Multi-Master Done Right
PPTX
Alibaba patches in MariaDB
PPTX
ConFoo MySQL Replication Evolution : From Simple to Group Replication
ODP
Mysql S&M
ODP
Database Replication
ODP
Sharding and scale out
PPTX
MySQL Replication Evolution -- Confoo Montreal 2017
PDF
MariaDB Auto-Clustering, Vertical and Horizontal Scaling within Jelastic PaaS
PDF
Scaling MySQL -- Swanseacon.co.uk
PDF
MySQL Replication Update -- Zendcon 2016
PDF
Mysql Replication Excerpt 5.1 En
Mater,slave on mysql
MySQL Replication Basics
MySQL database replication
Mysql replication @ gnugroup
MySQL 101 PHPTek 2017
Highly Available Load Balanced Galera MySql Cluster
Mysql
Download presentation
Download presentation531
Webinar Slides: MySQL Multi-Site Multi-Master Done Right
Alibaba patches in MariaDB
ConFoo MySQL Replication Evolution : From Simple to Group Replication
Mysql S&M
Database Replication
Sharding and scale out
MySQL Replication Evolution -- Confoo Montreal 2017
MariaDB Auto-Clustering, Vertical and Horizontal Scaling within Jelastic PaaS
Scaling MySQL -- Swanseacon.co.uk
MySQL Replication Update -- Zendcon 2016
Mysql Replication Excerpt 5.1 En
Ad

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPT
Teaching material agriculture food technology
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PPTX
1. Introduction to Computer Programming.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Machine Learning_overview_presentation.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Spectroscopy.pptx food analysis technology
PDF
Mushroom cultivation and it's methods.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
A comparative analysis of optical character recognition models for extracting...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Teaching material agriculture food technology
Heart disease approach using modified random forest and particle swarm optimi...
1. Introduction to Computer Programming.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
Advanced methodologies resolving dimensionality complications for autism neur...
Machine Learning_overview_presentation.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectroscopy.pptx food analysis technology
Mushroom cultivation and it's methods.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Group 1 Presentation -Planning and Decision Making .pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Programs and apps: productivity, graphics, security and other tools
A comparative analysis of optical character recognition models for extracting...

MySQL Failover - Cubexs Weatherly

  • 1. PHP Failover site / MySQL Failover CubeXS Weatherly (Pvt) Ltd.
  • 2. • What is Failover / DR / Redundant Site • What is Replication • How database replication works • Advantages of Replication • Types of Database Replications • How to setup replication • How to Monitor Replication • Failover Steps • Reverse Failover Steps Index
  • 3. Failover is a procedure by which a system automatically transfers control to a duplicate system when it detects a fault or failure. A failover can be Automatic or Manual What is Failover?
  • 4. Replication enables data from one server (the master) to be replicated to one or more servers (the slaves). What is Replication?
  • 5. MySQL Replication is asynchronous. slaves need not be connected permanently to receive updates from the master. This means that updates can occur over long-distance connections. Depending on the configuration, you can replicate all databases, selected databases, or even selected tables within a database How MySQL Database Replication works?
  • 6. • Scale-out solutions spreading the load among multiple slaves to improve performance. In this environment, all writes and updates must take place on the master server. Reads, however, may take place on one or more slaves. This model can improve the performance of writes (since the master is dedicated to updates), while dramatically increasing read speed across an increasing number of slaves. • Data security because data is replicated to the slave, and the slave can pause the replication process, it is possible to run backup services on the slave without corrupting the corresponding master data. • Analytics live data can be created on the master, while the analysis of the information can take place on the slave without affecting the performance of the master. • Long-distance data distribution if a branch office would like to work with a copy of your main data, you can use replication to create a local copy of the data for their use without requiring permanent access to the master. Advantages of MySQL Database Replication
  • 7. • Unidirectional Replication • Bi-Directional Replication • Directed Replication • Multi Slave Replication • Circular Replication Types of MySQL Database Replication
  • 8. Data is replicated from single master to single slave server, it involves 2 servers. This setup is usually used for backups. Unidirectional Replication
  • 9. This setup involves 2 servers, both being masters to the other as well as both being slaves to the other. This setup can be used as failover. Bi-Directional Replication
  • 10. This setup involves minimum 3 servers, “Server A” being master, “Server B” and “Server C” being slave to “Server A”. Multi Slave Replication
  • 11. This setup involves minimum 3 servers, “Server A” being master, “Server B” being slave to “Server A” as well as master to all other Slaves. This setup increases performance of “Server A”, because All slaves are directly connected to “Server B” and “Server A” only serves “Server B” for replication Directed Replication
  • 12. This setup involves minimum 3 servers, “Server A” being master, “Server B” being slave to “Server A” as well as master to “Server C”, and “Server C” being slave to “Server B” as well as master to “Server A” Circular Replication
  • 13. 1. Add below directives in MySQL configuration file (my.cnf) and restart MySQL services server-id=1 log-bin=mysql-bin log-error=mysql-bin.err 2. Connect Master Server and Add Replication User (Recommended) 3. Connect each Slave Server and execute below command mysql> CHANGE MASTER TO MASTER_HOST=‘master_ip', MASTER_USER='replication_username', MASTER_PASSWORD='replication_password‘; mysql> Start Slave; How to Setup Replication
  • 14. 1. Connect to Slave Server and execute below statement to monitor status. mysql> Show Slave Status; 2. Value of ‘Slave_IO_Running’ and ‘Slave_SQL_Running’ should be “YES”. 3. If either is “No”, There are possibilities that MySQL Replication is broken. How to Monitor Replication
  • 15. If multiple slaves exists and all were configured to get updates from the “Slave A”. (“Slave A” is down and we are switching our updates to “Slave B”) and we have to configure “Slave C” to get updates from “Slave B” 1. On all slave server(s) • mysql> STOP SLAVE IO_THREAD; • mysql> SHOW SLAVE STATUS; Wait for value of `Slave_IO_State` to be “Has read all relay log” • mysql> STOP SLAVE; 2. On “Slave C” • mysql> CHANGE MASTER TO MASTER_HOST=‘SLAVE_B_IP', MASTER_USER=‘REPLICATION_USER', MASTER_PASSWORD=‘REPLICATION_PASSWORD’; • mysql> START SLAVE; Failover Steps
  • 16. If your initial master server is live again and you want to make it master (may be this server is more powerful in aspect of computing power). You may follow below steps. 1. On all initial master server. mysql> CHANGE MASTER TO MASTER_HOST=‘CURRENT_MASTER_IP', MASTER_USER=‘REPLICATION_USER', MASTER_PASSWORD=‘REPLICATION_PASSWORD'; mysql> START SLAVE; Wait for initial master to update it self. mysql> Stop Slave; 2. Now you can follow failover steps for initial master server. Reverse Failover Steps