Using MYSQL replication to speed up Schema changes and table optermise
I hear that many people use master - slave arrangements help to improve time taken when changing schemas by using replication to setup a new temporary master, then stopping relocation and then swapping roles before starting again. I have found an example (below) found on stack overflow.
- Setup slave
- Stop replication.
- Make ALTER on slave
- Let slave catch up the master
- swap master and slave, so slave becomes production server with changed structure and minimum d开发者_运维百科owntime
This is all very well, however, i dont understand step 4 it isn't clear to me.
I wonder if anyone could please explain the procedure clearer.
Let slave catch up the master
Let slave catch up with the master meaning slave is 0 seconds behind master.
This mean if the replication stopped at some point (for you to alter table),
it will register a last replication time.
When the replication resume,
it will compare the current write on master with the last replication time on slave.
However, the procedures seems to be a flaw.
You cannot alter slave and
expecting schema in the updated slave is same as master.
In the events column type changed, column dropped,
potentially lead to replication failure.
seconds_behind_master should be 0.
精彩评论