Home > database >  Mysql Master-Master Replication When Master is Down
Mysql Master-Master Replication When Master is Down

Time:06-17

I have two servers with same version "mysql Ver 15.1 Distrib 10.6.8-MariaDB," on centos 7

I have implemented Mysql Master-Master Replication, master1 is on server-1 and master2 is on server-2 what happens when the either one of the servers goes down or the master goes Down

I am assuming if the one server goes down, it will switch to writes to the same master and when the server comes back up, it will start replicating the missing data to master2. I am not sure about it.

any information would be helpful

CodePudding user response:

Since replication is asynchronous already, if a server goes down, the other server will just accumulate its binary log of changes. When the server comes back up, it typically resumes replication and gradually catches up. Depending on how long it was down and how rapidly the changes accumulated in the binary logs on the server that remained running, it could take some time for the server to catch up.

Often binary logs are configured to expire automatically with the expire_logs_days option. If a server is down so long that some binary logs are expired before the server can get them and catch up, then the server is basically trash, and has to be reinitialized from a fresh backup of the other one. There's no way to reliably catch up without a complete sequence of binary logs.

I'm not aware that MariaDB has any automatic way of switching traffic to the other instance. This is up to the client to know which one to use for writes. There are several different ways to handle this, but none of them are perfectly automatic in 100% of cases.

It's better to leave it manual, but make the switch quick and reliable to make. That allows a human to make a judgment call when to perform the switch. But if the steps are well-scripted, once the human invokes it, it will happen correctly. It's best to make it a single command so you can do it even if you're half-asleep. Servers have a habit of going down when you're not awake! :-(

  • Related