Setting Replication on the Slave

Each server that participates in the replication setup needs to have a unique server-id.

Setup server-id

Change the slave server server-id in the options file /etc/mysql/my.cnf

[mysqld]
 server-id = 2

Restart the server for the option to take effect.

ubuntu@master:~$ sudo service mysql restart

Restore Database Backup

Restore the mysqldump file from the master server.

First create the database

mysql> create database employees;

On the shell, use mysqldump to do the restore

ubuntu@master:~$ mysqldump employees < employees.sql

Check if the slave_user can connect to master

try use the slave_user created in the previous step and connect to the master database

ubuntu@slave-01:~$ mysql -u slave_user -h master -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Setup the slave to point to the master

Use the CHANGE MASTER statement. Since we already provided the MASTER_LOG_FILE and MASTER_LOG_POS we won't need to specificy them here.

 CHANGE MASTER TO 
 MASTER_HOST='master', 
 MASTER_USER='slave_user', 
 MASTER_PASSWORD='password';

or alternatively specificy more options

CHANGE MASTER TO 
MASTER_HOST='master', 
MASTER_USER='slave_user', 
MASTER_PASSWORD='password', 
MASTER_LOG_FILE='master-bin', 
MASTER_LOG_POS=595;

results matching ""

    No results matching ""