Monday, September 5, 2016

Clearing out the results of show slave status hosts after removing a slave

I've been working on setting up automatic failover in replication topologies and saw that the results of "show slave hosts" was not being cleared out even after re-assigning the slave replica to a different master. I'm not sure the best way to do "safely" and have only found "flush status" to do the trick. However, the manual only recommends doing this for debugging.

http://dev.mysql.com/doc/refman/5.6/en/flush.html

FLUSH STATUS
This option adds the current thread's session status variable values to the global values and resets the session values to zero. Some global variables may be reset to zero as well. It also resets the counters for key caches (default and named) to zero and sets Max_used_connections to the current number of open connections. This is something you should use only when debugging a query.


mysql> show slave hosts;
+-----------+--------------+------+-----------+--------------------------------------+
| Server_id | Host         | Port | Master_id | Slave_UUID                           |
+-----------+--------------+------+-----------+--------------------------------------+
|         2 | vmware.db1_1 | 3306 |         3 | c03e14b1-6e06-11e6-a052-000c29f50e10 |
+-----------+--------------+------+-----------+--------------------------------------+
1 row in set (0.00 sec)

mysql> flush status;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave hosts;
Empty set (0.00 sec)

No comments:

Post a Comment