I have a questions here about MySQL replication. I have a very limited knowledge about database. Please someone help me to clarify this. My goal is to be able to do a deployment that can avoid downtime.
Suppose I have a DB replicated (master and slave). Suppose I want to do a new release, and I need to run a migration script. My plan is to stop the replication. And run the script in the slave. The migration script can be as:
- Based on some business logic, running multiple queries to set new values for a column in a table.
- Adding new column
What would actually happen when I start the replication again? The slave will catch up of any changes on the master. But how would the master get the changes that was applied to the slave? If i run the same database script, the migration script won’t be run again against the same data set on the master.
Would it make sense, if once the slave catch up with the master, to use the snapshot of the slave and use it as the new slave. And old slave become master?
I hope this actually is clear. Thanks. Any help is really appreciated.
You either have to do cross master replication in order for the slave to catch up with the master and the master to copy the modifications carried out on the salve or have some down time and run the script of the master.
1- You can change the slave master replcaition to cross master without any down time.
2- stop the ex-slave from replicating the master.
3- run your script.
4- start the ex-slave again.
I recommand that you setup a testing environment using a tool like vmware and try it out. That’s what I have done.
HERE IS A LINK THAT EXPLAINS HOW TO SET IT UP
http://onlamp.com/onlamp/2006/04/20/advanced-mysql-replication.html
I can’t stress enough on testing before applying the changes on a real environment, so test again and again untill you think that you’re ready. When that happens test one more time. DON’T FORGET TO MAKE A BACKUP TOO