MySQLTuner is a Perl script that helps to analyzes your current MySQL configuration and give some recommendations to adjust your settings to increase the performance and stability.
The MySQLTuner output is separated into 5 parts as below:
- General Statistics
- Storage Engine Statistics
- Security Recommendations
- Performance Metrics
- Recommendations
You should go through all parts especially on the Recommendations. It’s the main part which summarizes everything you need to step by step review your MySQL installation or make changes on some settings in the configuration file (usually located in /etc/my.cnf or /etc/mysql/my.cnf).
1. Get and run MySQLTuner on your server
-
Login to your server with root account vis SSH then go to the tmp directory:
[text]
cd /tmp
[/text] - Download the MySQLTuner script:
[text]
wget http://mysqltuner.pl/mysqltuner.pl
[/text] -
Make it executable
[text]
chmod +x mysqltuner.pl
[/text] -
Run it:
[text]
./mysqltuner.pl
[/text]Note: you may be asked to enter the MySQL root password, if yes, please provide.
2. Example of the MySQLTuner output
[text] >> MySQLTuner 1.2.0 – Major Hayden <[email protected]>>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with ‘–help’ for additional options and output filtering
——– General Statistics ————————————————–
[–] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.0.77
[OK] Operating on 64-bit architecture
——– Storage Engine Statistics ——————————————-
[–] Status: -Archive +BDB -Federated +InnoDB -ISAM -NDBCluster
[–] Data in MyISAM tables: 6G (Tables: 137)
[–] Data in InnoDB tables: 2M (Tables: 139)
[!!] BDB is enabled but isn’t being used
[!!] Total fragmented tables: 19
——– Security Recommendations ——————————————-
[OK] All database users have passwords assigned
——– Performance Metrics ————————————————-
[–] Up for: 43d 6h 14m 17s (25M q [6.849 qps], 1M conn, TX: 78B, RX: 3B)
[–] Reads / Writes: 96% / 4%
[–] Total buffers: 34.0M global + 2.7M per thread (100 max threads)
[OK] Maximum possible memory usage: 309.0M (3% of installed RAM)
[OK] Slow queries: 0% (0/25M)
[OK] Highest usage of available connections: 42% (42/100)
[OK] Key buffer size / total MyISAM indexes: 8.0M/1.4G
[OK] Key buffer hit rate: 99.5% (2B cached / 12M reads)
[!!] Query cache is disabled
[OK] Sorts requiring temporary tables: 0% (16 temp sorts / 6M sorts)
[!!] Temporary tables created on disk: 49% (5M on disk / 10M total)
[!!] Thread cache is disabled
[!!] Table cache hit rate: 0% (64 open / 43K opened)
[OK] Open file limit used: 10% (104/1K)
[OK] Table locks acquired immediately: 99% (32M immediate / 32M locks)
[OK] InnoDB data size / buffer pool: 2.3M/8.0M
——– Recommendations —————————————————–
General recommendations:
Add skip-bdb to MySQL configuration to disable BDB
Run OPTIMIZE TABLE to defragment tables for better performance
Enable the slow query log to troubleshoot bad queries
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries without LIMIT clauses
Set thread_cache_size to 4 as a starting value
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
query_cache_size (>= 8M)
tmp_table_size (> 32M)
max_heap_table_size (> 16M)
thread_cache_size (start at 4)
table_cache (> 64)
Please leave your opinion in the comment or share your solution.