Wednesday, April 9, 2008

Mysql data replication

Chapter 15 of mysql manual (version 5.0) deals with this.

At the master server: (Assumption: Mysql is installed and running)

1. Edit /etc/my.cnf
1.1 Add the following into [mysqld] section
2. Add a user for replication

grant replication slave on *.* to 'slaveuser'@'192.168.1.%' identified by 'slavepass';

3. Restart service at the master
service mysqld restart

4. Find the position of the current log

flush tables with read lock;
show master status;
(Note the position of the log file. This will be used at slave)

At the slave server:

1. Add the following to /etc/my.cnf in the [mysqld] section
2. Add the master information to slave server.

change master to MASTER_HOST='', MASTER_USER='slaveuser', MASTER_PASSWORD='slavepass', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=90;

Noticed this issue: After reboot, the log filename changes. How to fix this issue?

No comments: