Documenation Projects Articles
Home Contact
 

Instructions for setting up Mysql Replication:


By: michael earls - 2000-12-25 16:19:03
This article has been read: 8493 times.

Synopsis:
This documentation assumes two functional MySQL servers that are new enough to
support replication. It is preferred that your MySQL servers be identical
versions.

Preparation of Master Server:
Select a master server. It can be either one.
Make sure all databases that you want to replicate to the slave already exist!
The easiest way is to just copy the database dir inside your MySQL data
directory intact over to your slave, and then recursively chown them to "mysql:mysql".

Remember, the binary structures are file-system dependant, so you can't do this
between MySQL servers on different OS's.  In this instance you will want to use
mysqldump most likely.

Create /etc/my.cnf if you do not already have one:

[mysqld]
socket=/tmp/mysql.sock enter YOUR path to mysql.sock
here]server-id=1
log-bin


Permit your slave server to replicate by issuing the following SQL command
(substituting your slave's IP and preferred password):

mysql> GRANT FILE ON *.* TO replicate@192.168.1.2 IDENTIFIED BY 'somepass';


Shut down and restart MySQL daemon and verify that all is functional.
Preparation of Slave:

Create /etc/my.cnf if you do not already have one:

[mysqld]
socket=/tmp/mysql.sock
[enter YOUR path to mysql.sock here]
server-id=2 [MUST be different to master]
master-host=192.168.1.1
master-user=replicate
master-password=somepass


Shut down and restart MySQL on slave.
Issue the following SQL command to check status:

Testing:
Just update some data on the master, and query that record on the slave.
The update should be instantaneous.

 
     

Copyright (c) 2012 Vermeer.org. All rights reserved.

Powered By SnapBlox.com