Image for post
Image for post

Introduction

Why replication ?

Replication methods

Image for post
Image for post
Image for post
Image for post

How to replicate ?

[mysqld]server-id    = 1
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = testdatabase
# bind-address = 127.0.0.1
binlog-do-db = testdatabase2
binlog-do-db = testdatabase3
binlog-do-db = testdatabase4
binlog-do-db = testdatabase5
> sudo service mysqld restart
> mysql -u root -p
mysql > create user ‘replicator’@’10.10.10.2' identified by “XXXXXX”;
mysql > grant replication slave on *.* to ‘replicator’@’10.10.10.2';
mysql > show master status\G
[mysqld]server-id    = 2
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = testdatabase
# bind-address = 127.0.0.1
> sudo service mysqld restart
> mysql -u root -p
mysql > stop slave; 
mysql > CHANGE MASTER TO MASTER_HOST = ‘10.10.10.1’, MASTER_USER = ‘replicator’, MASTER_PASSWORD = ‘XXXXXX’, MASTER_LOG_FILE = ‘mysql-bin.00000X’, MASTER_LOG_POS = XXX;
mysql > start slave;
mysql > show slave status\G
Image for post
Image for post
“show slave status\G” Sample output
mysql > create user ‘replicator’@’10.10.10.1' identified by “XXXXX”;
mysql > grant replication slave on *.* to ‘replicator’@’10.10.10.1';
mysql > show master status\G
mysql > stop slave; 
mysql > CHANGE MASTER TO MASTER_HOST = ‘10.10.10.2’, MASTER_USER = ‘replicator’, MASTER_PASSWORD = ‘XXXXX’, MASTER_LOG_FILE = ‘mysql-bin.00000X’, MASTER_LOG_POS = XXX;
mysql > start slave; 
mysql > show slave status\G

Senior Software Engineer | BSc (Hons) Engineering | CIMA | Autodidact | Knowledge-Seeker

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store