Thursday, December 1, 2011

Complete Master to Slave MySQL DB Replicate

My.ini/My.cnf configuration for Master
-------------------------------

log-bin=mysql-bin
server-id=1


--------------------------------

INNODB Specific options
--------------------------------
innodb_flush_log_at_trx_commit=1
sync_binlog=1

--------------------------------



Restart MySql Service


FLUSH PRIVILEGES;
-----------------------------------------

mysql>USE exampledb;

mysql>FLUSH TABLES WITH READ LOCK;


Take a backup (or MYSQLDUMP) of the DB to be replicated

Restore DB on Slave



************************************************** *********************************

Step 2 – Configure the Slave Server(Windows XP)


Edit the my.ini/my.cnf

server-id=2
replicate-do-db = exampledb


Step 3 – Restart Mysql Service



Restart mysql Service

mysql > Stop slave;

mysql>CHANGE MASTER TO MASTER_HOST='master_IP', MASTER_USER='user', MASTER_PASSWORD='password',MASTER_LOG_FILE='mysql-bin.000006',MASTER_LOG_POS=183;

mysql > Start slave;

mysql > show slave_status; [This command will show whether your replication is running fine.]

To know if your replication is working check output of above command.
IN Out put of above command value of these two running status should be yes.
Slave_IO_Running | Slave_SQL_Running
Yes | Yes |


If any of these is NO than your replication is not working. To resynchronize DB and start replication again contact your MYSQL DBA.

0 comments:

Post a Comment