简体   繁体   中英

Sync large local DB with server DB (MySQL)

I need to weekly sync a large (3GB+ / 40+ tables) local MySQL database to a server database. The two databases are exactly the same. The local DB is constantly updated and every week or so the server DB need to be updated with the local data. You can call it 'mirrored DB' or 'master/master' but I'm not sure if this is correct.

Right now the DB only exist locally. So:

1) First I need to copy the DB from local to server. With PHPMyAdmin export/import is impossible because of the DB size and PHPMyAdmin limits. Exporting the DB to a gzipped file and uploading it through FTP probably will break in the middle of the transfer because of connection to the server problems or because of the server file size limit. Exporting each table separately will be a pain and the size of each table will also be very big. So, what is the better solution for this?

2) After the local DB us fully uploaded to the server I need to weekly update the server DB. What the better way to doing it?

I never worked with this kind of scenario, I don't know the different ways for achieving this and I'm not precisely strong with SQL so please explain yourself as good as possible.

Thank you very much.

This article should get you started.

Basically, get Maatkit and use the sync tools in there to perform a master-master-synchronization:

 mk-table-sync --synctomaster h=serverName,D=databaseName,t=tableName

You can use a DataComparer for mysql. Customize the template synchronization, which specify the data which tables to synchronize. Schedule a weekly update on the template. I have 2 servers daily synchronized with dbForge Data Comparer via command line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM