1

In a unidirectional Master-Slave setup, should the slave be manually stopped in cases where the Master is offline due to Maintenance, Crash etc. ? Or should one just leave it so that it keeps trying to reconnect until the Master is up and running again ?

3 Answers 3

3

If the master crashes, then it doesn't really matter what you do as far as stopping the slave, as long as you observe the slave once the master is back online, to verify that it has successfully started reading and executing events from the master again.

If you don't stop it, the slave should still be fine, and will sit and continually try to reconnect to the master based on master-retry-count and slave_net_timeout. These retries are not going to have any significant performance impact on other queries running on the slave. After enough retries, the slave will eventually give up, after which STOP SLAVE; followed by START SLAVE; should bring it back online again (or make it try again for the allocated number of retries).

If you take the master down for maintenance, the safest thing to do would arguably be to STOP SLAVE IO_THREAD; on the slave before shutting down the master, but if you don't do this, the master should shut down the slave's connection gracefully. The slave will still continue to retry, but the retries as the slave attempts to reconnect aren't going to do any harm.

http://dev.mysql.com/doc/refman/5.6/en/replication-options-slave.html

1

When possible, you should run slave stop on the slave after you have stopped traffic to the master.

That said, in most cases the salve will reconnect on its own as long as [a] there isn't an re-attempt limit, [b] the last slave read concluded properly and [c] the binlog on the master side hasn't been corrupted.

1
  • Actually, as long as the binlog where the slave last read is complete and not corrupt on the master, the slave will have no problem picking up where it left off, even if the master's binlog position has advanced or the log has rotated to a different binlog file, if all of the intermediate events on the master's binlogs are intact. Commented Apr 15, 2014 at 22:44
1

We have few replications in my shop and anytime we stop a master, prior to doing so we stop replication on the slave with:

STOP SLAVE;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.