林允中 Lîm, Ún-tiong

DevOps

MySQL Replication (Master-Slave): Setup and Resync Tutorial Collection

· --

Recently, the website I work for part-time needed to split its database (MySQL) across two servers to improve read performance. This opened the gates to Replication Hell... First, the Slave clearly showed it had successfully connected to the Master, but when I checked the data, nothing was actually syncing. I then went looking for resync methods and followed them several times, but the data still wouldn't sync. It wasn't until I found the replication setup guide below that I realized: when dumping the Master's data, the database must remain in a locked state, otherwise everything you do is for nothing (though looking more carefully, it seems everyone does mention this — truly a case of RTFM...). Additionally, you can use scp to transfer files between the two servers, saving yourself the hassle of constantly switching between FTP and SSH windows.

Setting up Replication: https://disp.cc/b/11-b2UR

Resynchronization: https://stackoverflow.com/questions/2366018/how-to-re-sync-the-mysql-db-if-master-and-slave-have-different-database-incase-o

If rewriting the DB name: On the slave side you need to set replicate-do-db=product_database2 because you have rewritten the DB name like product_database->product_database2. https://stackoverflow.com/questions/18241462/mysql-replication-struggling-with-replicate-rewrite-db-to-change-the-database-n


--

Comments