Linux

MySQLD 正在使用 175% 的 cpu

  • September 26, 2014

在其中一台伺服器上,我將 mysqld 作為從屬數據庫執行。

mysqld 目前使用的 CPU 使用率為 175%。

這是 SHOW PROCESSLIST 的結果;

+----------+-------------+-----------+---------+---------+---------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
| Id       | User        | Host      | db      | Command | Time    | State                                                                       | Info                                                                                                 |
+----------+-------------+-----------+---------+---------+---------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+
|   109029 | system user |           | NULL    | Connect | 2346123 | Waiting for master to send event                                            | NULL                                                                                                 |
|   109030 | system user |           | NULL    | Connect |       0 | Slave has read all relay log; waiting for the slave I/O thread to update it | NULL                                                                                                 |
| 12944426 | root        | localhost | NULL    | Query   |       0 | NULL                                                                        | SHOW PROCESSLIST                                                                                     |
| 12944443 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944445 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944463 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944466 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944467 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944469 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944470 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944471 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944476 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944479 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944482 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944484 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944485 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944488 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944490 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944491 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944492 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944493 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944495 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944496 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944498 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944499 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944501 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944502 | mdpipub     | localhost | mdpipub | Query   |       0 | Sending data                                                                | SELECT DISTINCT(article_id) FROM authors WHERE CONCAT(
               firstname,
         |
| 12944503 | mdpipub     | localhost | mdpipub | Sleep   |       0 |                                                                             | NULL                                                                                                 |
| 12944504 | mdpipub     | localhost | mdpipub | Query   |       0 | Sending data                                                                | SELECT DISTINCT(article_id) FROM authors WHERE CONCAT(
               firstname,
         |
+----------+-------------+-----------+---------+---------+---------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+

我資助這個問題。有人在網站上不斷執行搜尋功能,我對伺服器進行了攻擊。我剛剛禁止了這個IP,目前還可以。

這是因為 2 個潛在的繁重 SELECT 查詢正在執行。然後將所有執行緒的負載匯總到主程序中,並可能顯示超過 100%。

引用自:https://serverfault.com/questions/631169