SlideShare une entreprise Scribd logo
1  sur  17
MySQL Replication
19 April 2014
Abdul Manaf
Agenda
• Basics of Replication
• Why Replication needed
• Types Of Replication
• Replication For MySQL
• Configuring MySQL Replication
• Test a Replicated MySQL System
Basics of Replication
• Master / Slave, Master / Master and Circular replication
• Master writes all DDL and DML statements in the binary log
• Slaves read the binary log from the master and run the queries
locally
• A master can have many slaves
• A slave can have only one master
• A server can be both a master and a slave
• MySQL Replication is asynchronous
Master - Slave and Master-Master Replication Architecture
Master – Slave
Master – Master
Circular Replication Architecture
Why Replication needed
• Using Replication for Backups : 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 touching the corresponding master data.
• Using Replication with Different Master and Slave Storage Engines for
performance
• Using Replication for Scale-Out i.e Splitting load between servers
Distributing READ and WRITE.
• Creating reporting system on slave
Types Of Replication
• Synchronous Replication
• Asynchronous Replication
Synchronous Replication
• Master Server waits for the data to have been recorded on the duplicated
systems.
• Write either completes on both sides or not at all
• Uses the two-phase commit technology to protect data integrity
• Synchronous replication is essential for failover of transactional applications.
With synchronous replication, all committed data on the disk of the first server
are on the disk of the second server.
• Not in MySQL
Asynchronous Replication
• Write is considered complete as soon as local storage acknowledges.
• Performance is greatly increased. No need for two-phase commit protocol.
• In case of losing a local storage, the remote storage is not guaranteed to
have the current copy of data.
• Slaves need not be connected permanently to receive updates from the
master
Considerations before setting replication
• MySQL version of servers should be same.
• Master and slave should be able to commuincate with each other, create a test use
on master and try to connect from slave.
How to set MySQL replication
• Configure replication account on the master i.e create a mysql replication
user.
• Enable binary log and set server-id on the master my.cnf file
• Restart mysql master server
• Take backup from master server
• Configure slave for replication
• Restore backup on slave server
• Start replication using CHANGE MASTER and START SLAVE
Configure my.cnf
• Enable binary logging on the master
• Setup a server-id for the master
• Ensure that the skip-networking option has not been enabled, so that slave
can communicate with it
Configure my.cnf
Configure my.cnf
Configure slave server
• Setup a server-id on slave as we have done on master, it should be
different from master.
• Other variables like for configuring slave MASTER_HOST ,
MASTER_USER , MASTER_PASSWORD etc. We will be setting them by
executing CHNAGE master
CHANGE MASTER TO
MASTER_HOST = '192.168.9.236'
MASTER_USER = 'repl'
MASTER_PASSWORD = 'repl@123'
MASTER_LOG_FILE = 'mysql-bin.000004'
MASTER_LOG_POS = 108;
Known issues and their resolutions
• MySQL replication can fail silently, that is data can drift out of sync with the
master without your knowing, You need to regularly monitor your replication
setups.
• Use checksum tools from Percona to verify & compare tables on master &
slave servers.
• Use rigorous monitoring to watch error logs, and checksum logs hourly if
necessary.
• Use Percona sync tools to resync tables if they get out of sync.
• Be especially vigilant if you’re taking backups off the slave server
THANK YOU ALL

Contenu connexe

Tendances

MySQL Performance Secrets
MySQL Performance SecretsMySQL Performance Secrets
MySQL Performance SecretsOSSCube
 
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 DBAsNelson Calero
 
InnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter ZaitsevInnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter ZaitsevFuenteovejuna
 

Tendances (6)

MySQL database
MySQL databaseMySQL database
MySQL database
 
My sql
My sqlMy sql
My sql
 
MySQL Performance Secrets
MySQL Performance SecretsMySQL Performance Secrets
MySQL Performance Secrets
 
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
 
InnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter ZaitsevInnoDB Architecture and Performance Optimization, Peter Zaitsev
InnoDB Architecture and Performance Optimization, Peter Zaitsev
 
MySQL Backup & Recovery
MySQL Backup & RecoveryMySQL Backup & Recovery
MySQL Backup & Recovery
 

En vedette

R rsk003 07
R rsk003 07R rsk003 07
R rsk003 07li_jama
 
Baromètre de l'économie mai 2015
Baromètre de l'économie mai 2015Baromètre de l'économie mai 2015
Baromètre de l'économie mai 2015barbaraannoni
 
Welcome to v doxp
Welcome to v doxpWelcome to v doxp
Welcome to v doxpvdoxpmil
 
Primeros fotomontajes
Primeros fotomontajesPrimeros fotomontajes
Primeros fotomontajesAna Cabellos
 
MariaDB Galera Cluster
MariaDB Galera ClusterMariaDB Galera Cluster
MariaDB Galera ClusterAbdul Manaf
 
Topic 4 - Cell Theory and Natural Selection
Topic 4 - Cell Theory and Natural SelectionTopic 4 - Cell Theory and Natural Selection
Topic 4 - Cell Theory and Natural Selectionmelissamercer
 
Controle da via aérea e ventilação
Controle da via aérea e ventilaçãoControle da via aérea e ventilação
Controle da via aérea e ventilaçãoArthur Ricachenevsky
 
Sharing your treasure technology in the 21st century
Sharing your treasure  technology in the 21st centurySharing your treasure  technology in the 21st century
Sharing your treasure technology in the 21st centurynthomas25
 

En vedette (9)

R rsk003 07
R rsk003 07R rsk003 07
R rsk003 07
 
Baromètre de l'économie mai 2015
Baromètre de l'économie mai 2015Baromètre de l'économie mai 2015
Baromètre de l'économie mai 2015
 
Welcome to v doxp
Welcome to v doxpWelcome to v doxp
Welcome to v doxp
 
OnLine Production
OnLine ProductionOnLine Production
OnLine Production
 
Primeros fotomontajes
Primeros fotomontajesPrimeros fotomontajes
Primeros fotomontajes
 
MariaDB Galera Cluster
MariaDB Galera ClusterMariaDB Galera Cluster
MariaDB Galera Cluster
 
Topic 4 - Cell Theory and Natural Selection
Topic 4 - Cell Theory and Natural SelectionTopic 4 - Cell Theory and Natural Selection
Topic 4 - Cell Theory and Natural Selection
 
Controle da via aérea e ventilação
Controle da via aérea e ventilaçãoControle da via aérea e ventilação
Controle da via aérea e ventilação
 
Sharing your treasure technology in the 21st century
Sharing your treasure  technology in the 21st centurySharing your treasure  technology in the 21st century
Sharing your treasure technology in the 21st century
 

Similaire à MySQL Replication: Set Up Master-Slave Configuration

Download presentation
Download presentationDownload presentation
Download presentationRachit Gaur
 
Download presentation531
Download presentation531Download presentation531
Download presentation531Indra Pratap
 
MySqL Failover by Weatherly Cloud Computing USA
MySqL Failover by Weatherly Cloud Computing USAMySqL Failover by Weatherly Cloud Computing USA
MySqL Failover by Weatherly Cloud Computing USAHarry Gonzalez
 
MySQL database replication
MySQL database replicationMySQL database replication
MySQL database replicationPoguttuezhiniVP
 
Alibaba patches in MariaDB
Alibaba patches in MariaDBAlibaba patches in MariaDB
Alibaba patches in MariaDBLixun Peng
 
Mysql replication @ gnugroup
Mysql replication @ gnugroupMysql replication @ gnugroup
Mysql replication @ gnugroupJayant Chutke
 
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance TuningWebinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance TuningSeveralnines
 
Mater,slave on mysql
Mater,slave on mysqlMater,slave on mysql
Mater,slave on mysqlVasudeva Rao
 
Lesson 1 configuring
Lesson 1   configuringLesson 1   configuring
Lesson 1 configuringRam Kedem
 
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...xKinAnx
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)Aurimas Mikalauskas
 
Intro to MySQL Master Slave Replication
Intro to MySQL Master Slave ReplicationIntro to MySQL Master Slave Replication
Intro to MySQL Master Slave Replicationsatejsahu
 
MySQL replication best practices 105-232-931
MySQL replication best practices 105-232-931MySQL replication best practices 105-232-931
MySQL replication best practices 105-232-931Baruch Osoveskiy
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerkuchinskaya
 
Perforce Administration: Optimization, Scalability, Availability and Reliability
Perforce Administration: Optimization, Scalability, Availability and ReliabilityPerforce Administration: Optimization, Scalability, Availability and Reliability
Perforce Administration: Optimization, Scalability, Availability and ReliabilityPerforce
 
Professional sql server dba online training
Professional sql server dba online trainingProfessional sql server dba online training
Professional sql server dba online trainingsssql
 
MySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAsMySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAsSveta Smirnova
 

Similaire à MySQL Replication: Set Up Master-Slave Configuration (20)

Download presentation
Download presentationDownload presentation
Download presentation
 
Download presentation531
Download presentation531Download presentation531
Download presentation531
 
MySqL Failover by Weatherly Cloud Computing USA
MySqL Failover by Weatherly Cloud Computing USAMySqL Failover by Weatherly Cloud Computing USA
MySqL Failover by Weatherly Cloud Computing USA
 
MySQL Failover - Cubexs Weatherly
MySQL Failover - Cubexs WeatherlyMySQL Failover - Cubexs Weatherly
MySQL Failover - Cubexs Weatherly
 
MySQL database replication
MySQL database replicationMySQL database replication
MySQL database replication
 
Mysql
MysqlMysql
Mysql
 
Alibaba patches in MariaDB
Alibaba patches in MariaDBAlibaba patches in MariaDB
Alibaba patches in MariaDB
 
Mysql replication @ gnugroup
Mysql replication @ gnugroupMysql replication @ gnugroup
Mysql replication @ gnugroup
 
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance TuningWebinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
 
Mater,slave on mysql
Mater,slave on mysqlMater,slave on mysql
Mater,slave on mysql
 
Disaster Recovery Site Implementation with MySQL
Disaster Recovery Site Implementation with MySQLDisaster Recovery Site Implementation with MySQL
Disaster Recovery Site Implementation with MySQL
 
Lesson 1 configuring
Lesson 1   configuringLesson 1   configuring
Lesson 1 configuring
 
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...
Ibm spectrum scale fundamentals workshop for americas part 2 IBM Spectrum Sca...
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
 
Intro to MySQL Master Slave Replication
Intro to MySQL Master Slave ReplicationIntro to MySQL Master Slave Replication
Intro to MySQL Master Slave Replication
 
MySQL replication best practices 105-232-931
MySQL replication best practices 105-232-931MySQL replication best practices 105-232-931
MySQL replication best practices 105-232-931
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
 
Perforce Administration: Optimization, Scalability, Availability and Reliability
Perforce Administration: Optimization, Scalability, Availability and ReliabilityPerforce Administration: Optimization, Scalability, Availability and Reliability
Perforce Administration: Optimization, Scalability, Availability and Reliability
 
Professional sql server dba online training
Professional sql server dba online trainingProfessional sql server dba online training
Professional sql server dba online training
 
MySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAsMySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAs
 

MySQL Replication: Set Up Master-Slave Configuration

  • 1. MySQL Replication 19 April 2014 Abdul Manaf
  • 2. Agenda • Basics of Replication • Why Replication needed • Types Of Replication • Replication For MySQL • Configuring MySQL Replication • Test a Replicated MySQL System
  • 3. Basics of Replication • Master / Slave, Master / Master and Circular replication • Master writes all DDL and DML statements in the binary log • Slaves read the binary log from the master and run the queries locally • A master can have many slaves • A slave can have only one master • A server can be both a master and a slave • MySQL Replication is asynchronous
  • 4. Master - Slave and Master-Master Replication Architecture Master – Slave Master – Master
  • 6. Why Replication needed • Using Replication for Backups : 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 touching the corresponding master data. • Using Replication with Different Master and Slave Storage Engines for performance • Using Replication for Scale-Out i.e Splitting load between servers Distributing READ and WRITE. • Creating reporting system on slave
  • 7. Types Of Replication • Synchronous Replication • Asynchronous Replication
  • 8. Synchronous Replication • Master Server waits for the data to have been recorded on the duplicated systems. • Write either completes on both sides or not at all • Uses the two-phase commit technology to protect data integrity • Synchronous replication is essential for failover of transactional applications. With synchronous replication, all committed data on the disk of the first server are on the disk of the second server. • Not in MySQL
  • 9. Asynchronous Replication • Write is considered complete as soon as local storage acknowledges. • Performance is greatly increased. No need for two-phase commit protocol. • In case of losing a local storage, the remote storage is not guaranteed to have the current copy of data. • Slaves need not be connected permanently to receive updates from the master
  • 10. Considerations before setting replication • MySQL version of servers should be same. • Master and slave should be able to commuincate with each other, create a test use on master and try to connect from slave.
  • 11. How to set MySQL replication • Configure replication account on the master i.e create a mysql replication user. • Enable binary log and set server-id on the master my.cnf file • Restart mysql master server • Take backup from master server • Configure slave for replication • Restore backup on slave server • Start replication using CHANGE MASTER and START SLAVE
  • 12. Configure my.cnf • Enable binary logging on the master • Setup a server-id for the master • Ensure that the skip-networking option has not been enabled, so that slave can communicate with it
  • 15. Configure slave server • Setup a server-id on slave as we have done on master, it should be different from master. • Other variables like for configuring slave MASTER_HOST , MASTER_USER , MASTER_PASSWORD etc. We will be setting them by executing CHNAGE master CHANGE MASTER TO MASTER_HOST = '192.168.9.236' MASTER_USER = 'repl' MASTER_PASSWORD = 'repl@123' MASTER_LOG_FILE = 'mysql-bin.000004' MASTER_LOG_POS = 108;
  • 16. Known issues and their resolutions • MySQL replication can fail silently, that is data can drift out of sync with the master without your knowing, You need to regularly monitor your replication setups. • Use checksum tools from Percona to verify & compare tables on master & slave servers. • Use rigorous monitoring to watch error logs, and checksum logs hourly if necessary. • Use Percona sync tools to resync tables if they get out of sync. • Be especially vigilant if you’re taking backups off the slave server