我在专用服务器上使用 DirectAdmin 运行 CentOS(四核 i7 和 ~8Gb RAM),我遇到了 MySQL 的主要问题,可以在此处找到更多详细信息。
我刚刚从这个网站运行了一个 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?
我服务器上的主网站每周获得约 30K 的独立访问者,但即便如此,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 安装有任何建议吗?