Skip to content

MySQL replication failover for good…

This is more a note to myself then anything else. I’m throwing it up here on the offchance it is useful to someone else.

Let’s say you have a bunch of MySQL servers, some replication, everything is groovy, then your master dies. Eek! It turns out the actual failover is easy and very scriptable, see for example
Switching Masters During Failover on the MySQL docs in the MySQL docs.

Once you have failed over and had a nice cup of tea and a sitdown then you can ponder the situation.

If you are really really sure you won’t want to restore your old master to it’s rightful place, and in fact you want your new master to forget that once upon a time it was a lowly slave; then try the following incantations:


$ mysql --vertical -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1234 to server version: 5.0.34-beardybeardy

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> SHOW SLAVE STATUS;
#
# snip a whole pile of crap which really shouldn’t be there anymore
#
1 row in set (0.00 sec)

mysql> RESET SLAVE;
Query OK, 0 rows affected (0.50 sec)

mysql> CHANGE MASTER TO MASTER_HOST=”;
Query OK, 0 rows affected (0.90 sec)

mysql> SHOW SLAVE STATUS;
Empty set (0.00 sec)

mysql> SELECT “Ah, that’s better” as lovely;
*************************** 1. row ***************************
lovely: Ah, that’s better
1 row in set (0.00 sec)

Be careful though!

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*