Toolserver:Admin:Change the replication master

This page was moved from the Toolserver wiki.
Toolserver has been replaced by Toolforge. As such, the instructions here may no longer work, but may still be of historical interest.
Please help by updating examples, links, template links, etc. If a page is still relevant, move it to a normal title and leave a redirect.

Before you change the master, you need the new master position. It's usually in the server admin log, but if not, ask for it in #wikimedia-tech. If the master was changed by the WMF-guys because of a schema-change it is important to wait until the (then) old master was modified by the WMF-guys too.

If the master host changed

edit

If the master is changing, you need to reconfigure SQL-Proxy to use the new master. Then choose one of the following options, based on the replication type.

For a MySQL-replicated cluster

edit
  • Stop the MySQL slave: STOP SLAVE;
  • Change the MySQL master position: CHANGE MASTER TO master_log_pos=..., master_log_file='...';
  • Restart replication: START SLAVE;

For a trainwreck-replicated cluster

edit
  • Stop the appropriate trainwreck instance: svcs trainwreck; svcadm disable trainwreck:instance
  • Wait for the reader and writer threads to exit (tail -f /var/svc/log/network-trainwreck:instance.log)
  • Delete the file 0.logpos, which will be in the statedir defined in /etc/trainwreck/instance.conf.
  • Run trainwreck manually: /opt/local/bin/trainwreck -af /etc/trainwreck/instance.conf -F <logfile> -p <position>
  • Stop it: /opt/local/bin/twctl -c /etc/trainwreck/instance.conf shutdown
  • Start it properly: svcadm enable trainwreck:instance

Category:Admin:Database