MySQL/Percona 服务器 CPU 使用率突然飙升

MySQL/Percona 服务器 CPU 使用率突然飙升

我在使用 Percona Server 5.5 时遇到了一些问题:MySQL CPU 使用率突然异常,导致系统无响应,因为大量线程占用了所有 CPU。

它是一个 24 核系统,配备 64GB RAM,通常处于空闲状态(平均负载约为 0.xx)。我检查了进程列表,但只发现几个查询和平均数量的连接。此外,网站上的访问者也很少。

事实上,那里的主数据库大约有 15GB,有点碎片化,但总是索引良好(商店计划很快修复这个问题)。但即使转储所有表或运行 magento cron,负载也相当低。

当我执行 service mysql restart 时问题就消失了。

调试此问题的最佳方法是什么?

也可能与我对 my.cnf 进行的一些优化有关?我不认为我添加了一些奇怪的东西,只是缓存、缓冲区、打开表、time_wait 和 max_packet。我没有过度使用 RAM 或不假思索地在那里放置选项。

[mysqld]
# * Basic Settings
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/sql/
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

## security
local-infile=0
## disable for security
old_passwords = no
## combat lock wait timeouts
wait_timeout=300
##innodb_lock_wait_timeout set to debug transaction wait timeout (default 50)
innodb_lock_wait_timeout=200

# * Fine Tuning
key_buffer              = 16M
thread_stack            = 192K
thread_cache_size       = 8
## increased to combat server has gone away issue with magento (usually sign of MP)
max_allowed_packet      = 32M

## increased
max_connections        = 400
## skipped, synonym for table_open_cache
#table_cache            = 128
## don't use this it's a waste of time
#thread_concurrency     = 10
## keep this fair
table_open_cache       = 1500
## generally high enough to match pref table sum
table_definition_cache = 5000

# * Query Cache Configuration
## if frequent prunes happen: decrease to prevent performance hog (defaults to 1M)
query_cache_limit       = 256K
## doubled to 32MB - monitor hitrate and adapt accordingly in 12MB steps
query_cache_size        = 64M
## don't increase too much as inefficient queries will perform even worse
#tmp_table_size = 32M
#max_heap_table_size = 32M

## Feed the beast!
innodb_buffer_pool_size = 24G
## enable stats (debug + BF prevention)
userstat = 1

我将非常感激您的建议,因为知道系统稳定后我肯定会睡得更好;)

相关内容