Follow

Using MySQLTuner

  • Applies to: Grid
    • Difficulty: Medium
    • Time Needed: 60
    • Tools Required: SSH, MySQL GridContainer
  • Applies to: Legacy DV & VPS Hosting
    • Difficulty: Medium
    • Time Needed: 60
    • Tools Required: SSH, root
  • Applies to: Legacy DV & VPS Hosting
    • Difficulty: Medium
    • Time Needed: 60
    • Tools Required: SSH, root

Overview

MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief format along with some basic performance suggestions.

Requirements

Before you start, you'll need the following:

READ ME FIRST
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

READ ME FIRST
(mt) Media Temple does not support the installation and configuration of third-party software on your DV server. Please consult the MySQLTuner blog for further assistance.

The MySQLTuner script will make suggestions for changes you can make to your server, to optimize your MySQL services. (mt) Media Temple does not support any suggested configuration changes. We encourage you to back up your service before making any of the changes recommended by the script.

Instructions

  1. Connect via SSH to your Grid.
  2. Set your site number variable for later use:
    export SITEID=`pwd | awk -F\/ '{ print $3 }'`
  3. Download mysqltuner.pl to your Grid with the following command:
    wget -O mysqltuner.pl https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl --no-check-certificate
    
  4. Fill in the forcemem option with the size of your GridContainer and run the script with the following command:
    perl mysqltuner.pl --host internal-db.s$SITEID.gridserver.com  --forcemem 128
  5. Enter your database username and password when you see the following:
    Please enter your MySQL administrative login:
    Please enter your MySQL administrative password:
    
  6. Log into your server with a root or sudo user via SSH.
  7. Download MySQLTuner by executing the following command:
    wget -O mysqltuner.pl https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl --no-check-certificate
  8. Give the script 775 permissions:
    chmod 775 mysqltuner.pl
  9. Run the script with the following command:
    perl mysqltuner.pl
  10. The script should run and then display statistics and recommendations. Sample output:
    >>  MySQLTuner 1.0.1 - 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.0.77
    [OK] Operating on 32-bit architecture with less than 2GB RAM
    
    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
    [--] Data in MyISAM tables: 122K (Tables: 99)
    [--] Data in InnoDB tables: 52M (Tables: 155)
    [!!] Total fragmented tables: 5
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 262d 23h 58m 26s (2M q [0.121 qps], 328K conn, TX: 572M, RX: 207M)
    [--] Reads / Writes: 66% / 34%
    [--] Total buffers: 35.0M global + 2.7M per thread (100 max threads)
    [OK] Maximum possible memory usage: 303.7M (45% of installed RAM)
    [OK] Slow queries: 0% (3/2M)
    [OK] Highest usage of available connections: 5% (5/100)
    [OK] Key buffer size / total MyISAM indexes: 8.0M/401.0K
    [!!] Key buffer hit rate: 93.9% (110K cached / 6K reads)
    [OK] Query cache efficiency: 82.8% (932K cached / 1M selects)
    [OK] Query cache prunes per day: 11
    [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 29K sorts)
    [OK] Temporary tables created on disk: 25% (88K on disk / 348K total)
    [!!] Thread cache is disabled
    [!!] Table cache hit rate: 0% (64 open / 184K opened)
    [OK] Open file limit used: 8% (86/1K)
    [OK] Table locks acquired immediately: 100% (339K immediate / 339K locks)
    [!!] InnoDB data size / buffer pool: 52.6M/2.0M
    
    -------- Recommendations -----------------------------------------------------
    General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    Enable the slow query log to troubleshoot bad queries
    Set thread_cache_size to 4 as a starting value
    Increase table_cache gradually to avoid file descriptor limits
    Variables to adjust:
    thread_cache_size (start at 4)
    table_cache (> 64)
    innodb_buffer_pool_size (>= 52M)
    
  11. Feel free to implement these suggestions at your own discretion.

 

Advanced Support can help!

If you're having trouble with the steps in this article, additional assistance is available via Advanced Support, our premium services division. Our expert engineers can assist in administering your MySQL environment for optimal performance. For more information on what Advanced Support can do for you, please click here.

Resources

Was this article helpful?
0 out of 1 found this helpful

Comments