MySQL database CPU Spike emergency handling method
Run a smooth database, if you encounter CPU hurricane, to 80% or so, it must be developed to write bad SQL caused, the DBA first to ensure that the database does not run off, so we have to put those running slow SQL killed and recorded in the file, so that the subsequent troubleshooting.
Here is a tool pt-kill that can help you.
1 |
pt-kill --match-info 
" ^ (select| Select) "
--busy-time 
3
--victim all--interval 
1
--kill--print--daemonize >/root/kill.txt
|
 
explanation: Only SQL that takes more than 3 seconds to select is killed and printed out.
simulation test
This will kill, and then look at log.
Will kill the SQL recorded, and then with the development of slowly troubleshooting, the problem of SQL must not let the development of random on-line!
This article is from the "Spring Yang Technical column" blog, please be sure to keep this source http://hcymysql.blog.51cto.com/5223301/1353820
MySQL database CPU Spike emergency handling method