Thursday, August 16, 2012

cPanel - mysqltuner script

At times, situation comes where we need to tune mysql on cPanel server's. cPanel server has built in script now a days named - mysqltuner.pl

Location - /usr/local/cpanel/3rdparty/mysqltuner/mysqltuner.pl

We can make use of it in need onto the server.

e.g.

root@[/usr/local/cpanel/3rdparty/mysqltuner]# ./mysqltuner.pl
 >> MySQLTuner 1.1.2 - Major Hayden <major@mhtx.net>
 >> 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.1.63-cll
[OK] Operating on 64-bit architecture
-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 2G (Tables: 23107)
[--] Data in InnoDB tables: 598M (Tables: 5883)
[--] Data in MEMORY tables: 0B (Tables: 205)
[!!] Total fragmented tables: 6835
-------- Performance Metrics -------------------------------------------------
[--] Up for: 44m 31s (95K q [35.748 qps], 2K conn, TX: 263M, RX: 15M)
[--] Reads / Writes: 81% / 19%
[--] Total buffers: 442.0M global + 12.4M per thread (500 max threads)
[OK] Maximum possible memory usage: 6.5G (80% of installed RAM)
[OK] Slow queries: 0% (134/95K)
[OK] Highest usage of available connections: 2% (11/500)
[OK] Key buffer size / total MyISAM indexes: 384.0M/1.7G
[OK] Key buffer hit rate: 99.8% (9M cached / 19K reads)
[OK] Query cache efficiency: 73.0% (53K cached / 73K selects)
[!!] Query cache prunes per day: 21284
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 3K sorts)
[!!] Joins performed without indexes: 372
[!!] Temporary tables created on disk: 29% (2K on disk / 10K total)
[OK] Thread cache hit rate: 99% (11 created / 2K connections)
[!!] Table cache hit rate: 12% (512 open / 4K opened)
[OK] Open file limit used: 21% (876/4K)
[OK] Table locks acquired immediately: 99% (33K immediate / 33K locks)
[!!] InnoDB data size / buffer pool: 598.5M/8.0M
-------- Recommendations -----------------------------------------------------
General recommendations:
 Run OPTIMIZE TABLE to defragment tables for better performance
 MySQL started within last 24 hours - recommendations may be inaccurate
 Adjust your join queries to always utilize indexes
 When making adjustments, make tmp_table_size/max_heap_table_size equal
 Reduce your SELECT DISTINCT queries without LIMIT clauses
 Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
 query_cache_size (> 32M)
 join_buffer_size (> 128.0K, or always use indexes with joins)
 tmp_table_size (> 16M)
 max_heap_table_size (> 16M)
 table_cache (> 512)
 innodb_buffer_pool_size (>= 598M)
root@ [/usr/local/cpanel/3rdparty/mysqltuner]#