mySQL Replication Cheat sheet

15 Sep 2010 by Misha Dragojevic

This document is just a quick cheat sheet for DB admin on how to setup mySQL replication.
Detailed instructions can be found on mySQL site and should be followed to the letter.

Step 1: Configure mySQL for replication

Edit mySQL configuration file, usually /etc/mysql/my.cnf. You need to configure both master and slave.

NOTE: server-id above needs to be unique, i.e. you can set master mySQL server with server-id=1 and slave server with server-id=2 *Step 2*: Configure Master

Example of “SHOW MASTER STATUS” command

Write down values for "File" and "Position". Enable master to begin processing updates again:

Step 3: Dump database content, copy to slave

gzip and copy /tmp/dbdump.db to slave Master is done, go to slave. *Step 4*: Restore master DB on the slave

Step 5: Configure slave

*Step 6*: Check slave status

Make sure that “Seconds_Behind_Master” value is 0 (zero).

You are done, slave is replicating.

blog comments powered by Disqus