0% found this document useful (0 votes)
95 views

Configuring Mysql Master-Slave Replication On Ubuntu Linux

This document provides instructions for configuring MySQL master-slave replication between two Ubuntu servers. The master server is configured to allow binary logging and bind to an IP address. A replication user is created with appropriate privileges. A database snapshot is taken and copied to the slave server. The slave is installed with MySQL and configured to connect to the master. It restores the snapshot and is started as a slave, with its status checked to confirm replication is occurring. Multi-master clustering is mentioned as an advanced topic.

Uploaded by

Ajay YA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views

Configuring Mysql Master-Slave Replication On Ubuntu Linux

This document provides instructions for configuring MySQL master-slave replication between two Ubuntu servers. The master server is configured to allow binary logging and bind to an IP address. A replication user is created with appropriate privileges. A database snapshot is taken and copied to the slave server. The slave is installed with MySQL and configured to connect to the master. It restores the snapshot and is started as a slave, with its status checked to confirm replication is occurring. Multi-master clustering is mentioned as an advanced topic.

Uploaded by

Ajay YA
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Configuring​ ​MySQL​ ​Master-Slave 

Replication​ ​on​ ​Ubuntu​ ​Linux 


 
Master​ ​Server​ ​Configuration 
Install​ ​MySQL​ ​Server: 
 
sudo​ ​apt-get​ ​install​ ​-y​ ​mysql-server
 

Add​ ​the​ ​following​ ​to​ ​/etc/mysql/my.conf​: 


 
bind-address​ ​=​ ​10.11.12.101
server-id​ ​=​ ​1
log_bin​ ​=​ ​/var/log/mysql/mysql-bin.log
 

Restart​ ​MySQL: 
 
sudo​ ​service​ ​mysql​ ​restart 
 

Create​ ​a​ ​replication​ ​user: 


 
mysql​ ​-u​ ​root
CREATE​ ​USER​ ​'repl'@'%'​ ​IDENTIFIED​ B ​ Y​ ​'slavepassword';
GRANT​ ​REPLICATION​ ​SLAVE​ ​ON​ ​*.*​ ​TO​ '​ repl'@'%';
exit 
 

Create​ ​a​ ​snapshot​ ​and​ ​copy​ ​it​ ​to​ ​the​ ​slave​ ​server: 
 
mysqldump​ ​-u​ ​root​ ​--all-databases​ ​--master-data​ ​>​ ​masterdump.sql
scp​ ​masterdump.sql​ ​10.11.12.102: 
 

 
 
   

LinuxTrainingAcademy.com 
Slave​ ​Server​ ​Configuration 
On​ ​the​ ​slave,​ ​install​ ​MySQL​ ​Server: 
 
sudo​ ​apt-get​ ​install​ ​-y​ ​mysql-server
 

Add​ ​the​ ​following​ ​to​ ​/etc/mysql/my.conf: 


 
bind-address​ ​=​ ​10.11.12.102
server-id​ ​=​ ​2 
 

Restart​ ​MySQL: 
 
sudo​ ​service​ ​mysql​ ​restart
 

Tell​ ​the​ ​slave​ ​what​ ​user,​ ​password,​ ​and​ ​host​ ​to​ ​use​ ​for​ ​the​ ​master​ ​server: 
 
mysql​ ​-u​ ​root
CHANGE​ ​MASTER​ ​TO
MASTER_HOST='10.11.12.101',
MASTER_USER='repl',
MASTER_PASSWORD='slavepassword';
exit 
 

Restore​ ​the​ ​snapshot: 


 
mysql​ ​-uroot​ ​<​ ​masterdump.sql
 

Start​ ​the​ ​slave: 


 
mysql​ ​-u​ ​root
start​ ​slave;
show​ ​slave​ ​status\G;

 
Taking​ ​it​ ​to​ ​the​ ​next​ ​level…​ ​(Multi-master​ ​Clustering) 
If​ ​you​ ​want​ ​to​ ​learn​ ​how​ ​to​ ​create​ ​a​ ​true​ ​multi-master​ ​MySQL​ ​database​ ​cluster,​ ​check​ ​out​ H
​ igh​ ​Availability​ ​for 
the​ ​LAMP​ ​Stack​. 

LinuxTrainingAcademy.com 

You might also like