user427165
user427165

Reputation:

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.

  1. Setup slave
  2. Stop replication.
  3. Make ALTER on slave
  4. Let slave catch up the master
  5. swap master and slave, so slave becomes production server with changed structure and minimum downtime

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.

Upvotes: 4

Views: 1182

Answers (2)

ajreal
ajreal

Reputation: 47321

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.

Upvotes: 1

kedar
kedar

Reputation: 116

seconds_behind_master should be 0.

Upvotes: 0

Related Questions