I have two servers both running on MySQL 5.5.20 and I want to setup replication, so every update/insert on Master would reflect immediately on Slave machine.
I tried following this tutorial (I used instructions given on this website.) but it is not working. I found that after doing all this I couldn't … (((Please update this part with your experiences)))
Could you please suggest me a tested and an efficient way to do this in MySQL 5.5.20?
Best Answer
Please create this script
Fron the Linux prompt, open up an editor like vi
and add these lines to it
Next, make the file executable and run it
That's it !!!
Make sure you set the IP Address for
MYSQL_MASTER_HOST
andMYSQL_SLAVE_HOST
By the way, don't worry about the
dummy-file
in the master_log_file parameter forCHANGE MASTER TO
. Line 29 of the dump file should have the correct setting there due to the--master-data=1
. You can see it by doing this to the dump fileMake sure binary logging is already enabled on the master. Here is how you can tell: run
SHOW MASTER STATUS;
. If you get nothing back, you need to enable it like this:Add this to /etc/my.cnf
then restart mysql
OK that takes care of binary logging for the Master.
You also need to make sure the Master and the Slave have different server IDs. Here is how you can tell:
Run
SHOW VARIABLES LIKE 'server_id';
If the result comes up as1
, you must set it explicitly.Goto the Master and add this to /etc/my.cnf
Goto the Slave and add this to /etc/my.cnf
The main thing here is to make sure
server_id
is explicitly set in my.cnf on both Master and Slave. You must also make sure the server_id values are different from all other servers involved in the replication topology.If you are new to this, have a sysadmin join you to do this.