【问题标题】:Fix MySQL high CPU usage with InnoDB使用 InnoDB 修复 MySQL 高 CPU 使用率
【发布时间】:2014-04-26 06:39:44
【问题描述】:

最近我的服务器 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 c0 - 8.12% CPU 负载 MYSQLD:190%

我的服务器信息: Intel® Pentium® E5400 2.70GHz 2M 高速缓存 硬盘:250GB 内存:4GB

请帮帮我!

【问题讨论】:

    标签: mysql configuration innodb cpu highlight


    【解决方案1】:

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

    innodb_buffer_pool_size=128M
    

    当然,如果 CPU 峰值是由查询引起的,那么您需要使用索引来优化那些。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-14
      • 1970-01-01
      • 2010-11-19
      • 2020-08-25
      • 1970-01-01
      • 2022-06-19
      • 2017-03-23
      相关资源
      最近更新 更多