Switch master
From Wikitech
(Difference between revisions)
m |
|||
| Line 1: | Line 1: | ||
To switch masters: | To switch masters: | ||
| + | |||
| + | * Check that the new master has binlog enabled. All slaves should be configured this way, for convenience. | ||
cd [http://svn.wikimedia.org/viewvc/mediawiki/trunk/tools/switch-master/ ~tstarling/src/tools/switch-master] | cd [http://svn.wikimedia.org/viewvc/mediawiki/trunk/tools/switch-master/ ~tstarling/src/tools/switch-master] | ||
| Line 14: | Line 16: | ||
* Press enter a few more times until it's done, these steps usually work. There may be an error from the old master saying that SLAVE STOP requires a running slave, you can ignore it. | * Press enter a few more times until it's done, these steps usually work. There may be an error from the old master saying that SLAVE STOP requires a running slave, you can ignore it. | ||
* Edit db.php again, turning off read-only mode and simultaneously switching the loads configuration. | * Edit db.php again, turning off read-only mode and simultaneously switching the loads configuration. | ||
| + | * Edit my.cnf on the old master and the new master, setting read_only mode appropriately | ||
Revision as of 06:41, 18 December 2006
To switch masters:
- Check that the new master has binlog enabled. All slaves should be configured this way, for convenience.
cd ~tstarling/src/tools/switch-master
- Edit config.others or config.enwiki depending on which master you are switching. Then copy it to config. Config is the file that is actually used.
- Log in to the mysql on the old master as root. Check for any long running queries. Kill them. If there is a single long-running query such as a backup, which will restart after you kill it, then get its thread ID ready in a kill command, ready to press enter later.
- Set read-only mode in db.php, sync it.
- Start the script
./switch
- Press enter, this will attempt to switch the master to read-only. If there are long-running queries, kill them now. The script will block at FLUSH TABLES until you do.
- Check for slave lag. Slave lag must be zero on the new master before you continue.
- Press enter a few more times until it's done, these steps usually work. There may be an error from the old master saying that SLAVE STOP requires a running slave, you can ignore it.
- Edit db.php again, turning off read-only mode and simultaneously switching the loads configuration.
- Edit my.cnf on the old master and the new master, setting read_only mode appropriately