MySQL Replication – Setup Master-Master-Slave Replication

MySQLreplication

I am trying to set up a MySQL replication architecture between 3 MySQL servers by following a tutorial.

  • Server A as a master to Server B
  • Server B as a slave of server A and a master for server C
  • Server C as a slave of server B.

Using this architecture, the goal is if any data will be changed on Server A, both the server B and C must be updated.

After doing some tests, I got the following results:

  • Replication between server B and A is working well.
  • Any change on server A is mirrored on B but not in server C.
  • Testing if replication is working between server B and C (by manually editing some information in server B data), I was surprised that everything is working well, data edited in server B was edited in server C.

I can't understand why if Server A is edited and B is following it server C in that case is not following?

Best Answer

First of all, I dislike your setup. When Server B fails, the Server C will not be in replication anymore. If you want to be safe, that the data is on every server in sync, you should try to use a cluster. A cluster is minimum 3 servers and would fit your environment.

Next question for me is, why don't you use just one master (Server A) and two slaves (B+C)?

To answer your question, you need to activate the relay log, so that all changes to the slave are stored for the other slaves:

# REPLICATION slave to other slaves #
log-slave-updates              = 1
relay-log                      = /var/lib/mysql/relay-bin
slave-net-timeout              = 60