重启mysql从库

http://www.jonathanlevin.co.uk/2010/05/how-to-safetly-restart-your-mysql-slave.html

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
 
 
http://dba.stackexchange.com/questions/5528/rebooting-a-mysql-replication-slave

For the first time since it was set up I need to reboot a read-only MySQL replication slave.

I found this article about downing a slave for maintenance (albeit he's just describing stopping the mysql daemon):

How to Safetly[sic] Restart Your MySQL Slave Server

In summary the procedure is:

In mysql client:

STOP SLAVE;
FLUSH TABLES;

From OS:

/etc/init.d/mysql stop

I would reboot at this point and then after the system has booted:

In mysql client (the mysql daemon is configured to start on boot):

START SLAVE;

Does this look about right? Is there anything else I should be doing?

shareimprove this question
 
1  
Would you have a recommendation for automating this? In other words, if the server is ever rebooted, you'd like to have this happen: STOP SLAVE; FLUSH TABLES; –  user3707 Oct 3 '11 at 19:06

This looks right. The slave will pick up where it left off when it starts back up.

I will note that unless you supply the --skip-slave-start option, the slave should start automatically.

shareimprove this answer
 
    
Just gave it a go and it works fine (also see my edit note on the question about the misspelling of "safely"). Thanks. –  Kev Sep 8 '11 at 16:46
    
Looks right to me, too !!! +1 !!! –  RolandoMySQLDBA Sep 8 '11 at 17:05
posted @ 2015-04-24 11:52  陳聽溪  阅读(680)  评论(0)    收藏  举报