MySQL配置:内存使用“危险地高”?

时间:2013-02-09 17:03:28

标签: mysql

我在专用服务器(带有~8Gb RAM的四核i7)上运行带有DirectAdmin的CentOS,我遇到了MySQL的主要问题,可以找到更多详细信息here

我刚从this website运行perl MySQL Tuner脚本,试图确定问题所在。

可悲的是,输出对我来说没有多大意义:

 >>  MySQLTuner 1.2.0 - Major Hayden <major@mhtx.net>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password:

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.20-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 236M (Tables: 686)
[--] Data in InnoDB tables: 226M (Tables: 199)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[!!] Total fragmented tables: 312

-------- Security Recommendations  -------------------------------------------
[OK] All database users have passwords assigned

-------- Performance Metrics -------------------------------------------------
[--] Up for: 18h 42m 34s (1M q [18.265 qps], 49K conn, TX: 3B, RX: 835M)
[--] Reads / Writes: 60% / 40%
[--] Total buffers: 528.0M global + 7.0M per thread (1500 max threads)
[!!] Maximum possible memory usage: 10.8G (138% of installed RAM)
[OK] Slow queries: 0% (3/1M)
[OK] Highest usage of available connections: 2% (37/1500)
[OK] Key buffer size / total MyISAM indexes: 64.0M/74.1M
[OK] Key buffer hit rate: 99.9% (8M cached / 5K reads)
[OK] Query cache efficiency: 66.9% (529K cached / 792K selects)
[!!] Query cache prunes per day: 83513
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 42K sorts)
[!!] Joins performed without indexes: 5962
[OK] Temporary tables created on disk: 5% (5K on disk / 97K total)
[OK] Thread cache hit rate: 99% (37 created / 49K connections)
[OK] Table cache hit rate: 42% (512 open / 1K opened)
[OK] Open file limit used: 10% (756/7K)
[OK] Table locks acquired immediately: 99% (513K immediate / 513K locks)
[!!] InnoDB data size / buffer pool: 226.7M/128.0M

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
    Reduce your overall MySQL memory footprint for system stability
    Adjust your join queries to always utilize indexes
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    query_cache_size (> 64M)
    join_buffer_size (> 2.0M, or always use indexes with joins)
    innodb_buffer_pool_size (>= 226M)

调谐器是否暗示我的MySQL安装需要超过8Gb RAM?

我的服务器上的主要网站每周获得约30,000个独立访问者,但即便如此,当然,MySQL还没有受到 的严厉打击?

my.cnf中的设置为:

[mysqld]
local-infile=0
bind-address=127.0.0.1
max_connections=1500
long_query_time=2
log-slow-queries=/var/log/mysql_slow.log
expire_logs_days=14
external-locking

open_files_limit=1536
key_buffer_size=64M
innodb_buffer_pool_size=128M
innodb_additional_mem_pool_size=8M
innodb_log_buffer_size=8M
group_concat_max_len=16k
max_sort_length=16k
max_length_for_sort_data=16k
query_cache_type=1
query_cache_limit=4M
query_cache_size=64M
innodb_thread_concurrency=16
thread_concurrency=16
thread_cache=128
thread_stack=1M
read_buffer_size=1M
join_buffer_size=2M
read_rnd_buffer_size=1M
table_cache=512
tmp_table_size=256M
max_heap_table_size=256M
log-warnings

[mysqld_safe]
log-error=/var/log/mysqld.log

有没有人对如何优化我的MySQL安装有任何建议?

1 个答案:

答案 0 :(得分:0)

假设您使用InnoDB,它第一眼看到您没有使用RAM来获取数据库嗡嗡声。怎么样:

innodb_buffer_pool_size = 4G 
innodb_log_file_size = 1G