Sunday, July 22, 2012

Master to Slave Replication in MySQL server

This kind of replication is meant for replicating data from the master server to slave server.
Open my.cnf file & type server-id=1. It should be unique number for master server.

On master server open Mysql command prompt & type:

mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT TO *.* TO 'slave_user'@ '%' IDENTIFIED BY 'slave_password';

mysql> SHOW MASTER STATUS;

It will show a bin log file name & its position. Note it.

On Slave server machine's mysql terminal:-
mysql> CHANGE MASTER TO MASTER_HOST='IP_OF_MASTER', MASTER_USER='slave_user', MASTER_PASSWORD='slave_password', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=107;

mysql> START SLAVE;

mysql> SHOW SLAVE STATUS\G;

Repeat the steps for each master server.

No comments:

Post a Comment