0

for work I was supposed to set up a master-master replication of 2 servers ( raspberry pi 3 debian ), which I did and it works, but now I have come to the issue of why we set up the replicas in the 1srt place : Server 1 is the main master and server 2 is supposed to be a backup in case server 1 shuts down for X reason, and the clients would still have access to the database and continue writing on it.

But what happens when server 1 is repaired and restarted ? Will it sync automatically with server 2 ( which now has more infos, tables and so on ) of do I have to write commands to make it sync and get all the data it's missing ?

Knowing the database is about 20 000 000 of code lines and heavy, I cannot just do this manually and I need this to be automatic or a least make some sort of script that manages to sync all the data at once and not line per line..

I'm not at all a linux pro, I just started working on it last october so some concepts are quite blurry to me

Thanks for the help !

2 Answers 2

1

Thanks for your answer !

I think I get what you're trying to say, but that implies to do on the faulty server a " CHANGE MASTER TO master_host.....Blahblah " with the new log file and log pos " using a "Show master status" on server 2 which has additionnal content ?

And this is supposed to call a sync of faulty Server 1 on server 2 ?

Because I tried to simulate a shutdown of server 1 using " sudo shutdown -h now "

then adding some data to an already existing table.

Then I restarted Server 1 and here trouble begins :

First my MySQLi php extension had vanished, I had to reinstall it because I couldn't have access to phpmyadmin anymore ( don't know why, maybe the shutdown erased it )

and when I did a " Show slave status\G; " on Faulty server 1, it said :

Last_Errno: 1 Last_Errno: BlahBlah " quoting what I added in server 2 while shutdown, pointing to it.

And the two were not sync anymore but on this ( http://msutic.blogspot.fr/2015/02/mariadbmysql-master-master-replication.html ) tutorial I followed it was said it would catch up by itself at restart.

So I deleted what I had added and did a stop slave/ Change master to/start slave on faulty server 1, but I still had to delete the added data, so it wasn't what I wanted at all ...

0

Standard replication is mostly automatic, so if a master/slave is stopped for a short time, there should be enough logs to synchronise the stopped server with the running server. This depends on how long the server is stopped for the rate of change of your data, how big your binary logs are and how long you retain them. At absolute worst the best solution is always to dump and resync but you can tell pretty quickly by looking at SHOW SLAVE STATUS.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .