18 May 2010

How to Safetly Restart Your MySQL Slave Server

  • Make sure that nothing can access it
    (take it off the load balancer).
  • in mysql client do: STOP SLAVE;
  • in mysql client do: FLUSH TABLES;
    (if it gets stuck here, then you might need to fix it. You can try UNLOCK TABLES.)
  • in command line do: /etc/init.d/mysql stop

...do your what you need to do here...

  • in command line do: /etc/init.d/mysql start
    (check for errors, sometimes in my.cnf)
  • in mysql client do: START SLAVE;
    (normally this would be done automatically when you restart mysql)
  • in mysql client do: SHOW SLAVE STATUS\G
    (check that replication is working properly)
  • After you are satisfied, set up the slave server back on the load balancer