SlideShare a Scribd company logo
Prepared By: Ram Gautam email to :ramgau@gmail.com
Contents
1. Introduction ....................................................................................................................................2
2. Scope...............................................................................................................................................2
3. Intendant audience..........................................................................................................................2
4. Point to be considered/Further research .........................................................................................2
5. High Level diagram ..........................................................................................................................3
6. Used tools .......................................................................................................................................4
7. Configuration and setup ..................................................................................................................4
7.1 Asynchronous Communication between Master/Slave ..................................................................4
7.2 Percona XtraDB Cluster Configurations: .........................................................................................4
7.3 Master/Slave configuration for Asynchronous DB replication.........................................................5
STEP 1: Make a backup on TheMaster and prepare it.......................................................................5
STEP 2: Copy backed up data to TheSlave ........................................................................................7
STEP 3: Configure The Master’s MySQL server .................................................................................7
STEP 4: Start the replication.............................................................................................................8
STEP 5: Check the Master/Slave status.............................................................................................8
8. References.......................................................................................................................................8
Prepared By: Ram Gautam email to :ramgau@gmail.com
1. Introduction
This document is giving high level configuration about Percona 5.7, 3 node cluster with Master/Slave
database Replication for Disaster Recovery (DR) between Production Data Center (DC) and Disaster
Recovery Data Center.
2. Scope
This document covers about to configure Master/Save Database (DB) replication in centos using Percona
technologies.
3. Intendant audience
All configuration and setup are being done on Centos 6, Linux platform. So Database Administrator or
System Administrator or Developer should have basic knowledge of Linux command, MySQL database,
and Master /slave information to follow this document.
4. Point to be considered/Further research
Before start doing DB replication configuration, there may be following points to be considered.
 Network stability between Production Datacenter and DR Datacenter
 MySQL version at both Production DB and DR DB
 DB replication strategy for MySQL storage ENGINE. Like InnoDB, MyISAM
 Running query by Application.
Prepared By: Ram Gautam email to :ramgau@gmail.com
5. High Level diagram
This high level digram is showing two Application sets. i.e Production Set at Production Dataceter and
DR Set at Disaster Recovery Datacenter. Based on DR platform configuration we need to create identical
sets of components between Production and DR platform. For this, web server/Application server, Load
Balancer for both App & DB, and DB Cluster are the identified components for platform setup. Running
application does not often change compare to DB. So we are focusing on DB synchronization between
Production and DR platform. We cannot put synchronous communication medium to synch DB due to
network latency, each transaction cycle in DB. Due to this, we need to use Asynchronous mechanism for
DB synch.
In above figure, Red highlighted rectangle is detonated as the Virtual Private Network (VPN) between
Production DC and DR DC. Perconca tools to make Asynchronous DB replication/Hot Backup between
Production DB cluster and DR DB cluster. There is used Master/Slave concept for db replication as
source and destination DB server. One of the node from Production 3 node cluster as Master and One of
the node from DR Node Cluster.
Prepared By: Ram Gautam email to :ramgau@gmail.com
6. Used tools
 Percona 5.7 cluster
 Innobackupex/ xtrabackup
 Yum
7. Configuration and setup
7.1 Asynchronous Communication between Master/Slave
Asynchronous Replication uses the approach of lazy replication. The master database asynchronously
propagates replica updates to other slave nodes. Percona comes with a tool that allows you to perform
Asynchronous DB replication/Hot Backup s of a running MySQL database, with no blocking. It’s able to
do this because of Innodb & multi-version concurrency control (MVCC). Luckily we don’t need to dig into
the guts to enjoy the benefits of this great technology.
7.2 Percona XtraDB Cluster Configurations:
Percona is an open source software company specializing in MySQL, MongoDB, and other open source
database support, consulting, managed services, and training.
Percona XtraDB Cluster is an active/active high availability and high scalability open source solution for
MySQL clustering. It integrates Percona Server and Percona XtraBackup with the Codership Galera
library of MySQL high availability solutions in a single package that enables you to create a cost-effective
MySQL high availability cluster.
We can found more information
https://www.percona.com/software/mysql-database/percona-xtradb-cluster
Installation Documentation: https://www.percona.com/downloads/Percona-XtraDB-Cluster-57/LATEST/
In other document already described about how to configure Percona cluster 5.7 cluster with High
Availability. This document consists about configuration about DB replication between two sets of db
cluster. Each Cluster consists 3 nodes because 3 nodes clusters is best practice for clustering. DB
replication configuration step starts once all Cluster successfully configuration at both Production DC and
DR DC. Then we will pick one node as Master form Production DC and one node as from DR DC
Prepared By: Ram Gautam email to :ramgau@gmail.com
7.3 Master/Slave configuration for Asynchronous DB replication
Based on High level diagram, configuration will be as follows:
- TheMaster ,Node at Production Cluster-Node3 (192.168.2.6)
- TheSlave ,Node at DR Cluster – Node 1 (192.168.3.4)
TheMaster, A system with a MySQL-based server installed, configured and running. This system will be
called TheMaster, as it is where your data is stored and the one to be replicated. We will assume the
following about this system:
 the MySQL server is able to communicate with others by the standard TCP/IP port;
 the SSH server is installed and configured;
 you have a user account in the system with the appropriate permissions;
 you have a MySQL’s user account with appropriate privileges.
 server has binlogs enabled and unique server-id set up.
TheSlave Another system, with a MySQL-based server installed on it. We will refer to this machine as
TheSlave and we will assume the same things we did about TheMaster, except that the server-id on
TheSlave .
Percona XtraBackup, The backup tool we will use. It should be installed in both computers for
convenience.
STEP 1: Make a backup on TheMaster and prepare it
Binary logs on PXC
Binary logs are not strictly needed in PXC for replication, but you may be using them for backups or for
asynchronous slaves of the cluster. To set them up properly, we need the following settings added to
our config . For this, following configuration needs to be added in TheMaster, my.cnf config file.
# In order for Galera to work correctly binlog format should be ROW
binlog_format=ROW
#For DB replication
server_id=19216826
#binlog_format=ROW
log_slave_updates=1
log_bin=binlog
Prepared By: Ram Gautam email to :ramgau@gmail.com
Sample TheMaster, My.cnf will be ,After adding Replication parameter
[mysqld]
datadir=/var/lib/mysql
user=mysql
#log-error=/var/log/mysqld.log
# Path to Galera library
wsrep_provider=/usr/lib64/libgalera_smm.so
# Cluster connection URL contains the IPs of node#1, node#2 and
node#3wsrep_cluster_address=gcomm://192.168.2.4,192.168.2.5,192.168.2.6
# In order for Galera to work correctly binlog format should be ROW
binlog_format=ROW
#For DB replication
server_id=19216826
#binlog_format=ROW
log_slave_updates=1
log_bin=binlog
#gtid_mode=ON
#enforce_gtid_consistency=1
# MyISAM storage engine has only experimental support
default_storage_engine=InnoDB
# This InnoDB autoincrement locking mode is a requirement for Galera
innodb_autoinc_lock_mode=2
# Node 1 address
wsrep_node_address=192.168.2.6
# SST method
wsrep_sst_method=xtrabackup-v2
# Cluster name
wsrep_cluster_name=test_5_7cluster_node
# Authentication for SST method
wsrep_sst_auth="sstuser:s3cret"
Prepared By: Ram Gautam email to :ramgau@gmail.com
TO get snapshot from Master DB:
TheMaster # innobackupex --host=127.0.0.1 --user=bkpuser --password=bkppassword --port=3306
/data/backups/new_backup/
After this is finished you should get :
innobackupex: completed OK!
This will make a copy of your MySQL data dir to the /data/backups/new_backup/$TIMESTAMP. You
have told Percona XtraBackup (through the innobackupex script) to connect to the database server
using your database user and password, and do a hot backup of all your data in it (all MyISAM, InnoDB
tables and indexes in them).
In order for snapshot to be consistent you need to prepare the data:
TheMaster # innobackupex --apply-log --host=127.0.0.1 --user=bkpuser --password=bkppassword
/data/backups/new_backup/$TIMESTAMP
STEP 2: Copy backed up data to TheSlave
 TheMaster # scp -r /data/backups/new_backup/$TIMESTAMP root@ TheSlave:/data/
 Stop mysql at slave after successfully copied file from Master
 At minimum you need to set the server_id to a unique value. The IP address with the
periods removed can make a good server_id. Like 19216834
 Update mysql data directory with just copied from Master.
TheSlave$ mv /path/to/mysql/datadir /path/to/mysql/datadir_bak
and move the snapshot from TheMaster in its place:
TheSlave$ mv /path/to/mysql/$TIMESTAMP /path/to/mysql/datadir
After you copy data over, make sure MySQL has proper permissions to access them.
TheSlave$ chown mysql:mysql /path/to/mysql/datadir
In case the ibdata and iblog files are located in different directories outside of the datadir,
you will have to put them in their proper place after the logs have been applied
STEP 3: Configure The Master’s MySQL server
Add the appropriate grant in order for slave to be able to connect to master:
TheMaster|mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'$slaveip' IDENTIFIED BY '$slavepass';
Also make sure that firewall rules are correct and that TheSlave can connect to TheMaster. Test that you
can run the mysql client on TheSlave, connect to TheMaster, and authenticate.
TheSlave$ mysql --host=TheMaster --user=repl --password=$slavepass
Verify the privileges.
mysql> SHOW GRANTS;
Prepared By: Ram Gautam email to :ramgau@gmail.com
STEP 4: Start the replication
 Start/restat MySQL on TheSlave
 Look at the content of the file xtrabackup_binlog_info, it will be something like:
TheSlave$ cat /var/lib/mysql/xtrabackup_binlog_info
TheMaster-bin.000001 481
 Execute the CHANGE MASTER statement on a MySQL console and use the username and
password you’ve set up in STEP 3:
TheSlave|mysql> CHANGE MASTER TO
MASTER_HOST='$masterip',
MASTER_USER='repl',
MASTER_PASSWORD='$slavepass',
MASTER_LOG_FILE='TheMaster-bin.000001',
MASTER_LOG_POS=481;
 and start the slave:
TheSlave|mysql> START SLAVE;
STEP 5: Check the Master/Slave status
You should check that everything went OK with:
TheSlave|mysql> SHOW SLAVE STATUS G
...
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
...
Seconds_Behind_Master: 13
...
8. References
https://www.percona.com/blog/2015/07/16/bypassing-sst-pxc-binary-logs/
https://www.percona.com/doc/percona-xtrabackup/2.1/howtos/setting_up_replication.html
https://www.handybackup.net/mysql-replication.shtml
http://www.iheavy.com/2012/04/17/easy-mysql-replication-with-hotbackups-2/

More Related Content

PPTX
PostGreSQL Performance Tuning
Maven Logix
 
PPT
Architecting cloud
Tahsin Hasan
 
PDF
Webinar: MariaDB Provides the Solution to Ease Multi-Source Replication
Wagner Bianchi
 
PPTX
Couchbase Orchestration and Scaling a Caching Infrastructure At LinkedIn.
Issa Fattah
 
PDF
NY Meetup: Scaling MariaDB with Maxscale
Wagner Bianchi
 
PDF
MySQL Advanced Administrator 2021 - 네오클로바
NeoClova
 
PPTX
MySQL8.0_performance_schema.pptx
NeoClova
 
PDF
Tutorial all pp_pg_admin_backup_restore
Ganesh Sawant
 
PostGreSQL Performance Tuning
Maven Logix
 
Architecting cloud
Tahsin Hasan
 
Webinar: MariaDB Provides the Solution to Ease Multi-Source Replication
Wagner Bianchi
 
Couchbase Orchestration and Scaling a Caching Infrastructure At LinkedIn.
Issa Fattah
 
NY Meetup: Scaling MariaDB with Maxscale
Wagner Bianchi
 
MySQL Advanced Administrator 2021 - 네오클로바
NeoClova
 
MySQL8.0_performance_schema.pptx
NeoClova
 
Tutorial all pp_pg_admin_backup_restore
Ganesh Sawant
 

What's hot (20)

PDF
Security features In MySQL 8.0
Mydbops
 
DOCX
Upgrading mysql version 5.5.30 to 5.6.10
Vasudeva Rao
 
PDF
Parallel Query in AWS Aurora MySQL
Mydbops
 
PDF
Postgres plus cloud_database_getting_started_guide
ice1oog
 
PDF
Percona XtraDB 集群文档
YUCHENG HU
 
PDF
M|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
MariaDB plc
 
PDF
How to Become Cloud Backup Provider
Cloudian
 
PDF
How to become cloud backup provider
CLOUDIAN KK
 
PDF
Database Tools by Skype
elliando dias
 
PDF
PostgreSQL Performance Tuning
elliando dias
 
DOCX
My sql storage engines
Vasudeva Rao
 
PDF
Inside HDFS Append
Yue Chen
 
PDF
MySQL High Availability Deep Dive
hastexo
 
PDF
Installing and configuring a dhcp on windows server 2016 step by step
Ahmed Abdelwahed
 
PPTX
Streaming Replication Made Easy in v9.3
Sameer Kumar
 
PDF
Parnassus data recovery manager for oracle database user guide v0.3
maclean liu
 
PDF
HBase 2.0 cluster topology
Mikhail Antonov
 
PDF
Fast Incremental Backups with Percona Server and Percona XtraBackup / PLMCE 2014
Laurynas Biveinis
 
PPT
Mysql high availability and scalability
yin gong
 
PDF
Percona xtrabackup - MySQL Meetup @ Mumbai
Nilnandan Joshi
 
Security features In MySQL 8.0
Mydbops
 
Upgrading mysql version 5.5.30 to 5.6.10
Vasudeva Rao
 
Parallel Query in AWS Aurora MySQL
Mydbops
 
Postgres plus cloud_database_getting_started_guide
ice1oog
 
Percona XtraDB 集群文档
YUCHENG HU
 
M|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
MariaDB plc
 
How to Become Cloud Backup Provider
Cloudian
 
How to become cloud backup provider
CLOUDIAN KK
 
Database Tools by Skype
elliando dias
 
PostgreSQL Performance Tuning
elliando dias
 
My sql storage engines
Vasudeva Rao
 
Inside HDFS Append
Yue Chen
 
MySQL High Availability Deep Dive
hastexo
 
Installing and configuring a dhcp on windows server 2016 step by step
Ahmed Abdelwahed
 
Streaming Replication Made Easy in v9.3
Sameer Kumar
 
Parnassus data recovery manager for oracle database user guide v0.3
maclean liu
 
HBase 2.0 cluster topology
Mikhail Antonov
 
Fast Incremental Backups with Percona Server and Percona XtraBackup / PLMCE 2014
Laurynas Biveinis
 
Mysql high availability and scalability
yin gong
 
Percona xtrabackup - MySQL Meetup @ Mumbai
Nilnandan Joshi
 
Ad

Viewers also liked (6)

PDF
Percona Cluster Installation with High Availability
Ram Gautam
 
PPTX
Master and slave relationship in Robinson Crusoe
Dharaba Gohil
 
PDF
Industrial communication 2016 English
ifm electronic gmbh
 
PPT
Distributed system
Syed Zaid Irshad
 
PPTX
Distributed computing
Keshab Nath
 
PDF
Industrial Networking - Profibus
Yogesh Kumar
 
Percona Cluster Installation with High Availability
Ram Gautam
 
Master and slave relationship in Robinson Crusoe
Dharaba Gohil
 
Industrial communication 2016 English
ifm electronic gmbh
 
Distributed system
Syed Zaid Irshad
 
Distributed computing
Keshab Nath
 
Industrial Networking - Profibus
Yogesh Kumar
 
Ad

Similar to Percona Cluster with Master_Slave for Disaster Recovery (20)

PDF
Magento Hosting on AWS
Gaurav "GP" Pal
 
PDF
How to become cloud backup provider with Cloudian HyperStore and CloudBerry L...
Cloudian
 
PDF
Nt1330 Unit 1
Jenny Calhoon
 
PDF
Setting up mongodb sharded cluster in 30 minutes
Sudheer Kondla
 
PPTX
Configuring Your First Hadoop Cluster On EC2
benjaminwootton
 
PDF
Pandora FMS: Raven DB Plugin
Pandora FMS
 
PDF
Webcenter application performance tuning guide
Vinay Kumar
 
PDF
WebSphere Portal Version 6.0 Web Content Management and DB2 Tuning Guide
Tan Nguyen Phi
 
DOCX
MongoDB Replication and Sharding
Tharun Srinivasa
 
PDF
MariaDB Auto-Clustering, Vertical and Horizontal Scaling within Jelastic PaaS
Jelastic Multi-Cloud PaaS
 
DOCX
Network Manual
Jason Myers
 
PDF
Maxscale_메뉴얼
NeoClova
 
PPTX
Oracle Real Application Cluster ( RAC )
varasteh65
 
PPTX
Database Mirror for the exceptional DBA – David Izahk
sqlserver.co.il
 
PPT
How to scale your web app
Georgio_1999
 
PDF
MySQL database replication
PoguttuezhiniVP
 
PDF
Percona Xtrabackup - Highly Efficient Backups
Mydbops
 
PDF
Schema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdf
seo18
 
PPTX
CUBRID Developer's Course
CUBRID
 
DOCX
SAP SQL Anywhere High Availability Tutorial for Business Objects
Sitesh Patel
 
Magento Hosting on AWS
Gaurav "GP" Pal
 
How to become cloud backup provider with Cloudian HyperStore and CloudBerry L...
Cloudian
 
Nt1330 Unit 1
Jenny Calhoon
 
Setting up mongodb sharded cluster in 30 minutes
Sudheer Kondla
 
Configuring Your First Hadoop Cluster On EC2
benjaminwootton
 
Pandora FMS: Raven DB Plugin
Pandora FMS
 
Webcenter application performance tuning guide
Vinay Kumar
 
WebSphere Portal Version 6.0 Web Content Management and DB2 Tuning Guide
Tan Nguyen Phi
 
MongoDB Replication and Sharding
Tharun Srinivasa
 
MariaDB Auto-Clustering, Vertical and Horizontal Scaling within Jelastic PaaS
Jelastic Multi-Cloud PaaS
 
Network Manual
Jason Myers
 
Maxscale_메뉴얼
NeoClova
 
Oracle Real Application Cluster ( RAC )
varasteh65
 
Database Mirror for the exceptional DBA – David Izahk
sqlserver.co.il
 
How to scale your web app
Georgio_1999
 
MySQL database replication
PoguttuezhiniVP
 
Percona Xtrabackup - Highly Efficient Backups
Mydbops
 
Schema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdf
seo18
 
CUBRID Developer's Course
CUBRID
 
SAP SQL Anywhere High Availability Tutorial for Business Objects
Sitesh Patel
 

Percona Cluster with Master_Slave for Disaster Recovery

  • 1. Prepared By: Ram Gautam email to :[email protected] Contents 1. Introduction ....................................................................................................................................2 2. Scope...............................................................................................................................................2 3. Intendant audience..........................................................................................................................2 4. Point to be considered/Further research .........................................................................................2 5. High Level diagram ..........................................................................................................................3 6. Used tools .......................................................................................................................................4 7. Configuration and setup ..................................................................................................................4 7.1 Asynchronous Communication between Master/Slave ..................................................................4 7.2 Percona XtraDB Cluster Configurations: .........................................................................................4 7.3 Master/Slave configuration for Asynchronous DB replication.........................................................5 STEP 1: Make a backup on TheMaster and prepare it.......................................................................5 STEP 2: Copy backed up data to TheSlave ........................................................................................7 STEP 3: Configure The Master’s MySQL server .................................................................................7 STEP 4: Start the replication.............................................................................................................8 STEP 5: Check the Master/Slave status.............................................................................................8 8. References.......................................................................................................................................8
  • 2. Prepared By: Ram Gautam email to :[email protected] 1. Introduction This document is giving high level configuration about Percona 5.7, 3 node cluster with Master/Slave database Replication for Disaster Recovery (DR) between Production Data Center (DC) and Disaster Recovery Data Center. 2. Scope This document covers about to configure Master/Save Database (DB) replication in centos using Percona technologies. 3. Intendant audience All configuration and setup are being done on Centos 6, Linux platform. So Database Administrator or System Administrator or Developer should have basic knowledge of Linux command, MySQL database, and Master /slave information to follow this document. 4. Point to be considered/Further research Before start doing DB replication configuration, there may be following points to be considered.  Network stability between Production Datacenter and DR Datacenter  MySQL version at both Production DB and DR DB  DB replication strategy for MySQL storage ENGINE. Like InnoDB, MyISAM  Running query by Application.
  • 3. Prepared By: Ram Gautam email to :[email protected] 5. High Level diagram This high level digram is showing two Application sets. i.e Production Set at Production Dataceter and DR Set at Disaster Recovery Datacenter. Based on DR platform configuration we need to create identical sets of components between Production and DR platform. For this, web server/Application server, Load Balancer for both App & DB, and DB Cluster are the identified components for platform setup. Running application does not often change compare to DB. So we are focusing on DB synchronization between Production and DR platform. We cannot put synchronous communication medium to synch DB due to network latency, each transaction cycle in DB. Due to this, we need to use Asynchronous mechanism for DB synch. In above figure, Red highlighted rectangle is detonated as the Virtual Private Network (VPN) between Production DC and DR DC. Perconca tools to make Asynchronous DB replication/Hot Backup between Production DB cluster and DR DB cluster. There is used Master/Slave concept for db replication as source and destination DB server. One of the node from Production 3 node cluster as Master and One of the node from DR Node Cluster.
  • 4. Prepared By: Ram Gautam email to :[email protected] 6. Used tools  Percona 5.7 cluster  Innobackupex/ xtrabackup  Yum 7. Configuration and setup 7.1 Asynchronous Communication between Master/Slave Asynchronous Replication uses the approach of lazy replication. The master database asynchronously propagates replica updates to other slave nodes. Percona comes with a tool that allows you to perform Asynchronous DB replication/Hot Backup s of a running MySQL database, with no blocking. It’s able to do this because of Innodb & multi-version concurrency control (MVCC). Luckily we don’t need to dig into the guts to enjoy the benefits of this great technology. 7.2 Percona XtraDB Cluster Configurations: Percona is an open source software company specializing in MySQL, MongoDB, and other open source database support, consulting, managed services, and training. Percona XtraDB Cluster is an active/active high availability and high scalability open source solution for MySQL clustering. It integrates Percona Server and Percona XtraBackup with the Codership Galera library of MySQL high availability solutions in a single package that enables you to create a cost-effective MySQL high availability cluster. We can found more information https://www.percona.com/software/mysql-database/percona-xtradb-cluster Installation Documentation: https://www.percona.com/downloads/Percona-XtraDB-Cluster-57/LATEST/ In other document already described about how to configure Percona cluster 5.7 cluster with High Availability. This document consists about configuration about DB replication between two sets of db cluster. Each Cluster consists 3 nodes because 3 nodes clusters is best practice for clustering. DB replication configuration step starts once all Cluster successfully configuration at both Production DC and DR DC. Then we will pick one node as Master form Production DC and one node as from DR DC
  • 5. Prepared By: Ram Gautam email to :[email protected] 7.3 Master/Slave configuration for Asynchronous DB replication Based on High level diagram, configuration will be as follows: - TheMaster ,Node at Production Cluster-Node3 (192.168.2.6) - TheSlave ,Node at DR Cluster – Node 1 (192.168.3.4) TheMaster, A system with a MySQL-based server installed, configured and running. This system will be called TheMaster, as it is where your data is stored and the one to be replicated. We will assume the following about this system:  the MySQL server is able to communicate with others by the standard TCP/IP port;  the SSH server is installed and configured;  you have a user account in the system with the appropriate permissions;  you have a MySQL’s user account with appropriate privileges.  server has binlogs enabled and unique server-id set up. TheSlave Another system, with a MySQL-based server installed on it. We will refer to this machine as TheSlave and we will assume the same things we did about TheMaster, except that the server-id on TheSlave . Percona XtraBackup, The backup tool we will use. It should be installed in both computers for convenience. STEP 1: Make a backup on TheMaster and prepare it Binary logs on PXC Binary logs are not strictly needed in PXC for replication, but you may be using them for backups or for asynchronous slaves of the cluster. To set them up properly, we need the following settings added to our config . For this, following configuration needs to be added in TheMaster, my.cnf config file. # In order for Galera to work correctly binlog format should be ROW binlog_format=ROW #For DB replication server_id=19216826 #binlog_format=ROW log_slave_updates=1 log_bin=binlog
  • 6. Prepared By: Ram Gautam email to :[email protected] Sample TheMaster, My.cnf will be ,After adding Replication parameter [mysqld] datadir=/var/lib/mysql user=mysql #log-error=/var/log/mysqld.log # Path to Galera library wsrep_provider=/usr/lib64/libgalera_smm.so # Cluster connection URL contains the IPs of node#1, node#2 and node#3wsrep_cluster_address=gcomm://192.168.2.4,192.168.2.5,192.168.2.6 # In order for Galera to work correctly binlog format should be ROW binlog_format=ROW #For DB replication server_id=19216826 #binlog_format=ROW log_slave_updates=1 log_bin=binlog #gtid_mode=ON #enforce_gtid_consistency=1 # MyISAM storage engine has only experimental support default_storage_engine=InnoDB # This InnoDB autoincrement locking mode is a requirement for Galera innodb_autoinc_lock_mode=2 # Node 1 address wsrep_node_address=192.168.2.6 # SST method wsrep_sst_method=xtrabackup-v2 # Cluster name wsrep_cluster_name=test_5_7cluster_node # Authentication for SST method wsrep_sst_auth="sstuser:s3cret"
  • 7. Prepared By: Ram Gautam email to :[email protected] TO get snapshot from Master DB: TheMaster # innobackupex --host=127.0.0.1 --user=bkpuser --password=bkppassword --port=3306 /data/backups/new_backup/ After this is finished you should get : innobackupex: completed OK! This will make a copy of your MySQL data dir to the /data/backups/new_backup/$TIMESTAMP. You have told Percona XtraBackup (through the innobackupex script) to connect to the database server using your database user and password, and do a hot backup of all your data in it (all MyISAM, InnoDB tables and indexes in them). In order for snapshot to be consistent you need to prepare the data: TheMaster # innobackupex --apply-log --host=127.0.0.1 --user=bkpuser --password=bkppassword /data/backups/new_backup/$TIMESTAMP STEP 2: Copy backed up data to TheSlave  TheMaster # scp -r /data/backups/new_backup/$TIMESTAMP root@ TheSlave:/data/  Stop mysql at slave after successfully copied file from Master  At minimum you need to set the server_id to a unique value. The IP address with the periods removed can make a good server_id. Like 19216834  Update mysql data directory with just copied from Master. TheSlave$ mv /path/to/mysql/datadir /path/to/mysql/datadir_bak and move the snapshot from TheMaster in its place: TheSlave$ mv /path/to/mysql/$TIMESTAMP /path/to/mysql/datadir After you copy data over, make sure MySQL has proper permissions to access them. TheSlave$ chown mysql:mysql /path/to/mysql/datadir In case the ibdata and iblog files are located in different directories outside of the datadir, you will have to put them in their proper place after the logs have been applied STEP 3: Configure The Master’s MySQL server Add the appropriate grant in order for slave to be able to connect to master: TheMaster|mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'$slaveip' IDENTIFIED BY '$slavepass'; Also make sure that firewall rules are correct and that TheSlave can connect to TheMaster. Test that you can run the mysql client on TheSlave, connect to TheMaster, and authenticate. TheSlave$ mysql --host=TheMaster --user=repl --password=$slavepass Verify the privileges. mysql> SHOW GRANTS;
  • 8. Prepared By: Ram Gautam email to :[email protected] STEP 4: Start the replication  Start/restat MySQL on TheSlave  Look at the content of the file xtrabackup_binlog_info, it will be something like: TheSlave$ cat /var/lib/mysql/xtrabackup_binlog_info TheMaster-bin.000001 481  Execute the CHANGE MASTER statement on a MySQL console and use the username and password you’ve set up in STEP 3: TheSlave|mysql> CHANGE MASTER TO MASTER_HOST='$masterip', MASTER_USER='repl', MASTER_PASSWORD='$slavepass', MASTER_LOG_FILE='TheMaster-bin.000001', MASTER_LOG_POS=481;  and start the slave: TheSlave|mysql> START SLAVE; STEP 5: Check the Master/Slave status You should check that everything went OK with: TheSlave|mysql> SHOW SLAVE STATUS G ... Slave_IO_Running: Yes Slave_SQL_Running: Yes ... Seconds_Behind_Master: 13 ... 8. References https://www.percona.com/blog/2015/07/16/bypassing-sst-pxc-binary-logs/ https://www.percona.com/doc/percona-xtrabackup/2.1/howtos/setting_up_replication.html https://www.handybackup.net/mysql-replication.shtml http://www.iheavy.com/2012/04/17/easy-mysql-replication-with-hotbackups-2/