Note: Thereisafileembeddedwithinthispost, pleasevisitthisposttodownloadthefile. mySQL database CPU soar Emergency Handling Method for a database that runs smoothly. If the CPU usage rate reaches about 80%, it must be caused by bad SQL statements written by developers. What DBAs must ensure first is, do not run the database, so
Note: There is a file embedded within this post, please visit this post to download the file. mySQL database CPU soar Emergency Handling Method for a database that runs smoothly. If the CPU usage rate reaches about 80%, it must be caused by bad SQL statements written by developers. What DBAs must ensure first is, do not run the database, so
Note: There is a file embedded within this post, please visit this post to download the file.
MySQL database CPU soaring Emergency Handling Method
If the CPU usage of a stable database is so high as 80%, it must be caused by bad SQL statements developed and written. The DBA must first ensure that the database should not run down, therefore, we need to kill slow SQL statements and record them in the file for subsequent troubleshooting. Here we use a tool pt-kill to help you.
1 |
pt-kill? --match-info "^(select|SELECT)" --busy-time 3 --victim all --interval 1 --kill --print --daemonize > /root/kill.txt
|
Explanation: only the SQL statements that take more than three seconds for the select statement are killed and printed out.
Simulated Test
In this way, the server is killed and then the LOG is viewed.
The SQL statements that will be killed will be recorded, and further troubleshooting will be conducted with the development team. The problematic SQL statements cannot be released at will!
Original article address: MySQL database CPU soaring emergency handling method, thanks to the original author for sharing.