我有一个拥有大型产品数据库的联盟网店。 3.000.000+记录,它使用4,3 GiB(InnoDB类型)。
我想扩展数据库,但我正在寻找最佳的MySQL配置。
服务器信息:
Operating system Debian Linux 7.4
Real memory 5.57 GB used, 31.39 GB total
Local disk space 198.34 GB used, 707.74 GB total
Virtual memory 29.35 MB used, 1021.99 MB total
Apache2 webserver
MySQL version 5.5.35
这是我的MySQLTuner结果:
MySQLTuner 1.3.0
[OK] Logged in using credentials from debian maintenance account.
[OK] Currently running supported MySQL version 5.5.35-0+wheezy1
[OK] Operating on 64-bit architecture
-------- Storage Engine Statistics --------
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
[--] Data in MyISAM tables: 40M (Tables: 288)
[--] Data in InnoDB tables: 2G (Tables: 22)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[!!] Total fragmented tables: 58
-------- Security Recommendations --------
[OK] All database users have passwords assigned
-------- Performance Metrics --------
[--] Up for: 3d 20h 4m 45s (17M q [52.042 qps], 418K conn, TX: 19B, RX: 3B)
[--] Reads / Writes: 52% / 48%
[--] Total buffers: 3.2G global + 24.4M per thread (151 max threads)
[OK] Maximum possible memory usage: 6.8G (21% of installed RAM)
[OK] Slow queries: 0% (49/17M)
[OK] Highest usage of available connections: 30% (46/151)
[OK] Key buffer size / total MyISAM indexes: 3.0G/20.9M
[OK] Key buffer hit rate: 100.0% (726M cached / 10K reads)
[OK] Query cache efficiency: 72.3% (8M cached / 12M selects)
[!!] Query cache prunes per day: 3831
[OK] Sorts requiring temporary tables: 0% (399 temp sorts / 690K sorts)
[!!] Joins performed without indexes: 4229
[OK] Temporary tables created on disk: 14% (2K on disk / 18K total)
[OK] Thread cache hit rate: 99% (119 created / 418K connections)
[!!] Table cache hit rate: 0% (413 open / 153K opened)
[OK] Open file limit used: 29% (646/2K)
[OK] Table locks acquired immediately: 99% (9M immediate / 9M locks)
[!!] InnoDB buffer pool / data size: 128.0M/2.9G
[OK] InnoDB log waits: 0
-------- Recommendations --------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Enable the slow query log to troubleshoot bad queries
Adjust your join queries to always utilize indexes
Increase table_open_cache gradually to avoid file descriptor limits
Read this before increasing table_open_cache over 64: http://bit.ly/1mi7c4C
Variables to adjust:
query_cache_size (> 64M)
join_buffer_size (> 128.0K, or always use indexes with joins)
table_open_cache (> 1024)
innodb_buffer_pool_size (>= 2G)
我可以更改大部分变量进行调整,但我不知道最佳设置是什么。我们这里的数据库专家能为我提供建议吗?
我已经为查询和连接设置了正确的索引。