使用InnoDB修复MySQL高CPU使用率

时间:2014-04-26 06:39:45

标签: mysql configuration innodb cpu highlight

最近我的服务器CPU一直很高。

目前,我的my.cnf文件如下:

[mysqld]
default-storage-engine=innodb
local-infile=0
skip-locking
max_connections=300
key_buffer = 128M
myisam_sort_buffer_size = 64M
join_buffer_size = 1M
read_buffer_size = 2M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
table_cache = 1024
record_buffer = 1M
thread_cache_size = 128
wait_timeout = 30
connect_timeout = 10
interactive_timeout = 10
tmp_table_size = 64M
max_heap_table_size = 64M
max_allowed_packet = 16M
max_connect_errors = 10
query_cache_limit = 1M
query_cache_size = 64M
query_cache_type = 1
[isamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M
[myisamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M
[mysqlhotcopy]
interactive-timeout

CPU使用率:u623.84 s78.87 cu0 cs0 - 8.12%CPU负载 MYSQLD:190%

我的服务器信息: 英特尔®奔腾®E54002.70GHz 2M高速缓存 硬盘:250GB 内存:4GB

请帮帮我!

1 个答案:

答案 0 :(得分:1)

将此变量(不在my.cnf中)设置为可用内存的70%:

innodb_buffer_pool_size=128M

当然,如果CPU峰值是由于查询引起的,那么您希望优化具有索引的那些。