In mysql master-slave Replication which server requests the other?

Posted on

Question :

I want to setup mysql replication between two servers one of them is my localhost and the other is online server.
I have all availability to make any one of them the master.
But according to that my localhost server doesn’t have a static IP, i need to know which server of the two (master & slave) is the one which requests the other for doing updates.
Does the master sends the binlog updates, or the slave is the one which requests for new updates periodically ? so i will make it the localhost.
thank you in advance.

Answer :

according to this reference: Get MySQL Replication up and running in 5 minutes, Slave must access master to initialize.

slave> CHANGE MASTER TO MASTER_HOST='192.168.0.31',
 -> MASTER_USER='repl_user',
 -> MASTER_PASSWORD='billy',
 -> MASTER_LOG_FILE='',
 -> MASTER_LOG_POS=4;

So, you can setup slave in localhost and master in remote host with accessible IP and port.

This is a client server communication:

enter image description here

Logically, the Primary ‘pushes’ data to the Replica.

Actually, the Replica connects to the Primary and ‘pulls’ the data.

So, it is more important to have a static IP, or a DNS lookup, so that the Replica can find the Primary.

Leave a Reply

Your email address will not be published. Required fields are marked *