MySQL 占用大量 CPU 使用率(紧急)

MySQL 占用大量 CPU 使用率(紧急)

最近,我清理了网站的缓存文件,现在 MySQL 占用的 CPU 高达 100%。它在 5 分钟内慢慢从 10% 增长到 100%,因此服务器崩溃了。幸运的是,我通过停止了服务,#service mysql stop但每次我打开它时,它都会开始占用 CPU。

这是错误日志:

#/usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/dev.system.de.pid
101112 18:22:03 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
101112 18:22:03 [Warning] option 'innodb-additional-mem-pool-size': signed value 204800 adjusted to 524288
101112 18:22:03 [Warning] option 'innodb-log-buffer-size': signed value 204800 adjusted to 262144
101112 18:22:03 [Note] Plugin 'ndbcluster' is disabled.
101112 18:22:03  InnoDB: Started; log sequence number 0 63198013
101112 18:22:03 [Note] Event Scheduler: Loaded 0 events
101112 18:22:03 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.1.50'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution

Status information:

Current dir: /var/lib/mysql/
Running threads: 0  Stack size: 196608
Current locks:
lock: 0x89df8a0:

lock: 0x89d6798:

lock: 0x89cca68:

lock: 0x89c1500:

lock: 0x89b9818:

lock: 0x89adff8:

lock: 0x89a9918:

lock: 0x899b3e0:


Key caches:
default
Buffer_size:      33554432
Block_size:           1024
Division_limit:        100
Age_limit:             300
blocks used:             3
not flushed:             0
w_requests:              0
writes:                  0
r_requests:              6
reads:                   3


handler status:
read_key:            0
read_next:           3
read_rnd             0
read_first:          3
write:               0
delete               0
update:              0

Table status:
Opened tables:         15
Open tables:            8
Open files:            16
Open streams:           0

Alarm status:
Active alarms:   0
Max used alarms: 0
Next alarm time: 0

Begin safemalloc memory dump:

End safemalloc memory dump.

Memory status:
Non-mmapped space allocated from system: 1286144
Number of free chunks:                   19
Number of fastbin blocks:                0
Number of mmapped regions:               7
Space in mmapped regions:                108834816
Maximum total allocated space:           0
Space available in freed fastbin blocks: 0
Total allocated space:                   1242928
Total free space:                        43216
Top-most, releasable space:              25280
Estimated memory (with thread stack):    110120960

Events status:
LLA = Last Locked At  LUA = Last Unlocked At
WOC = Waiting On Condition  DL = Data Locked

Event scheduler status:
State      : INITIALIZED
Thread id  : 0
LLA        : n/a:0
LUA        : n/a:0
WOC        : NO
Workers    : 0
Executed   : 0
Data locked: NO

Event queue status:
Element count   : 0
Data locked     : NO
Attempting lock : NO
LLA             : init_queue:132
LUA             : init_queue:142
WOC             : NO
Next activation : never
101112 18:26:07 [Note] /usr/libexec/mysqld: Normal shutdown

101112 18:26:08 [Note] Event Scheduler: Purging the queue. 0 events
101112 18:26:08 [ERROR] /usr/libexec/mysqld: Sort aborted
101112 18:26:10  InnoDB: Starting shutdown...
101112 18:26:13  InnoDB: Shutdown completed; log sequence number 0 63198023
101112 18:26:13 [Note] /usr/libexec/mysqld: Shutdown complete

抱歉,我不知道该怎么读。有人能帮忙吗?

答案1

在 my.cnf 中的 [mysqld] 下添加以下行:
long_query_time = 5
log-slow-queries

然后重新启动 MySQL 并查看其中是否出现任何查询(任何运行时间超过 5 秒的查询)。也可能问题实际上不是出在 MySQL 上,而是出在 Apache 上。

相关内容