Tuning MySQL Performance with MySQLTuner

Discussion in 'Server Operation' started by VMartins, Oct 27, 2008.

  1. VMartins

    VMartins New Member

    Hi All,

    I downloaded and ran this script in my server. I'm having many issues regardins the MySQL Performance. My experience with MySQL parameters is very low. I have a ISPConfig server.

    My result of the analysis is:

    Code:
     >>  MySQLTuner 0.9.9 - Major Hayden <[email protected]>
     >>  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.0.51a-3ubuntu5.1-log
    [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: 2M (Tables: 354)
    [--] Data in InnoDB tables: 9M (Tables: 344)
    [!!] Total fragmented tables: 41
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 3m 14s (9 q [0.046 qps], 6 conn, TX: 7K, RX: 515)
    [--] Reads / Writes: 100% / 0%
    [--] Total buffers: 42.0M global + 2.6M per thread (100 max threads)
    [!!] Maximum possible memory usage: 304.5M (163% of installed RAM)
    [OK] Slow queries: 0% (0/9)
    [OK] Highest usage of available connections: 1% (1/100)
    Use of uninitialized value in numeric lt (<) at ./mysqltuner.pl line 673, <>
            line 2 (#1)
        (W uninitialized) An undefined value was used as if it were already
        defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
        To suppress this warning assign a defined value to your variables.
        
        To help you figure out what was undefined, perl tells you what operation
        you used the undefined value in.  Note, however, that perl optimizes your
        program and the operation displayed in the warning may not necessarily
        appear literally in your program.  For example, "that $foo" is
        usually optimized into "that " . $foo, and the warning will refer to
        the concatenation (.) operator, even though there is no . in your
        program.
        
    [!!] Key buffer size / total MyISAM indexes: 16.0M/20.2M
    [!!] Query cache is disabled
    [OK] Temporary tables created on disk: 0% (0 on disk / 2 total)
    [OK] Thread cache hit rate: 83% (1 created / 6 connections)
    [OK] Table cache hit rate: 50% (6 open / 12 opened)
    [OK] Open file limit used: 1% (14/1K)
    [OK] Table locks acquired immediately: 100% (12 immediate / 12 locks)
    [!!] Connections aborted: 16%
    [!!] InnoDB data size / buffer pool: 9.2M/8.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
        Enable the slow query log to troubleshoot bad queries
        Your applications are not closing MySQL connections properly
    Variables to adjust:
      *** MySQL's maximum memory usage exceeds your installed memory ***
      *** Add more RAM before increasing any MySQL buffer variables  ***
        key_buffer_size (> 20.2M)
        query_cache_size (>= 8M)
        innodb_buffer_pool_size (>= 9M)
    I will increase my server memory.

    Someone has tips or instructions to improve my MySQL performance?

    Thanks in advance,

    Vinicius
     
  2. falko

    falko Super Moderator ISPConfig Developer

    What's in your my.cnf?

    If you have phpMyAdmin installed, you can use that to optimize your tables.
     
  3. VMartins

    VMartins New Member

    falko,

    I changed some memory configurations I now i have this result:

    Code:
    root@ns1:~# ./mysqltuner.pl 
    
     >>  MySQLTuner 0.9.9 - Major Hayden <[email protected]>
     >>  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.0.51a-3ubuntu5.1-log
    [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: 2M (Tables: 354)
    [--] Data in InnoDB tables: 9M (Tables: 344)
    [!!] Total fragmented tables: 40
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 13h 2m 45s (16K q [0.347 qps], 1K conn, TX: 36M, RX: 2M)
    [--] Reads / Writes: 71% / 29%
    [--] Total buffers: 58.0M global + 2.6M per thread (100 max threads)
    [!!] Maximum possible memory usage: 320.5M (137% of installed RAM)
    [OK] Slow queries: 0% (0/16K)
    [OK] Highest usage of available connections: 5% (5/100)
    [OK] Key buffer size / total MyISAM indexes: 16.0M/20.2M
    [OK] Key buffer hit rate: 99.8% (36K cached / 81 reads)
    [OK] Query cache efficiency: 45.7% (4K cached / 9K selects)
    [OK] Query cache prunes per day: 0
    [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 642 sorts)
    [!!] Temporary tables created on disk: 26% (510 on disk / 1K total)
    [OK] Thread cache hit rate: 99% (5 created / 1K connections)
    [!!] Table cache hit rate: 8% (64 open / 752 opened)
    [OK] Open file limit used: 12% (127/1K)
    [OK] Table locks acquired immediately: 100% (7K immediate / 7K locks)
    [!!] InnoDB data size / buffer pool: 9.2M/8.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
        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
        Increase table_cache gradually to avoid file descriptor limits
    Variables to adjust:
      *** MySQL's maximum memory usage exceeds your installed memory ***
      *** Add more RAM before increasing any MySQL buffer variables  ***
        tmp_table_size (> 32M)
        max_heap_table_size (> 16M)
        table_cache (> 64)
        innodb_buffer_pool_size (>= 9M)
    
    Yes, I have phpmyAdmin. And my my.cnf is:

    Code:
    #
    # The MySQL database server configuration file.
    #
    # You can copy this to one of:
    # - "/etc/mysql/my.cnf" to set global options,
    # - "~/.my.cnf" to set user-specific options.
    # 
    # One can use all long options that the program supports.
    # Run program with --help to get a list of available options and with
    # --print-defaults to see which it would actually understand and use.
    #
    # For explanations see
    # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
    
    # This will be passed to all mysql clients
    # It has been reported that passwords should be enclosed with ticks/quotes
    # escpecially if they contain "#" chars...
    # Remember to edit /etc/mysql/debian.cnf when changing the socket location.
    [client]
    port		= 3306
    socket		= /var/run/mysqld/mysqld.sock
    
    # Here is entries for some specific programs
    # The following values assume you have at least 32M ram
    
    # This was formally known as [safe_mysqld]. Both versions are currently parsed.
    [mysqld_safe]
    socket		= /var/run/mysqld/mysqld.sock
    nice		= 0
    
    [mysqld]
    #
    # * Basic Settings
    #
    user		= mysql
    pid-file	= /var/run/mysqld/mysqld.pid
    socket		= /var/run/mysqld/mysqld.sock
    port		= 3306
    basedir		= /usr
    datadir		= /var/lib/mysql
    tmpdir		= /tmp
    language	= /usr/share/mysql/english
    skip-external-locking
    #
    # localhost which is more compatible and is not less secure.
    # bind-address		= 127.0.0.1
    #
    # * Fine Tuning
    #
    key_buffer		= 16M
    max_allowed_packet	= 16M
    thread_stack		= 128K
    thread_cache_size	= 8
    #max_connections        = 100
    #table_cache            = 64
    #thread_concurrency     = 10
    #
    # * Query Cache Configuration
    #
    query_cache_limit       = 1M
    query_cache_size        = 16M
    #
    # * Logging and Replication
    #
    # Both location gets rotated by the cronjob.
    # Be aware that this log type is a performance killer.
    #log		= /var/log/mysql/mysql.log
    #
    # Error logging goes to syslog. This is a Debian improvement :)
    #
    # Here you can see queries with especially long duration
    #log_slow_queries	= /var/log/mysql/mysql-slow.log
    #long_query_time = 2
    #log-queries-not-using-indexes
    #
    # The following can be used as easy to replay backup logs or for replication.
    #server-id		= 1
    log_bin			= /var/log/mysql/mysql-bin.log
    # WARNING: Using expire_logs_days without bin_log crashes the server! See README.Debian!
    expire_logs_days	= 10
    max_binlog_size         = 100M
    #binlog_do_db		= include_database_name
    #binlog_ignore_db	= include_database_name
    #
    # * BerkeleyDB
    #
    # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
    skip-bdb
    #
    # * InnoDB
    #
    # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
    # Read the manual for more InnoDB related options. There are many!
    # You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
    #skip-innodb
    #
    # * Security Features
    #
    # Read the manual, too, if you want chroot!
    # chroot = /var/lib/mysql/
    #
    # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
    #
    # ssl-ca=/etc/mysql/cacert.pem
    # ssl-cert=/etc/mysql/server-cert.pem
    # ssl-key=/etc/mysql/server-key.pem
    
    
    
    [mysqldump]
    quick
    quote-names
    max_allowed_packet	= 16M
    
    [mysql]
    #no-auto-rehash	# faster start of mysql but no tab completition
    
    [isamchk]
    key_buffer		= 16M
    
    #
    # * NDB Cluster
    #
    # See /usr/share/doc/mysql-server-*/README.Debian for more information.
    #
    # The following configuration is read by the NDB Data Nodes (ndbd processes)
    # not from the NDB Management Nodes (ndb_mgmd processes).
    #
    # [MYSQL_CLUSTER]
    # ndb-connectstring=127.0.0.1
    
    
    #
    # * IMPORTANT: Additional settings that can override those from this file!
    #
    !includedir /etc/mysql/conf.d/
    
    
     
  4. falko

    falko Super Moderator ISPConfig Developer

    You can add something like
    Code:
    tmp_table_size = 64M
    max_heap_table_size = 32M
    table_cache = 128
    innodb_buffer_pool_size=10M
    to the [mysqld] section.

    How much RAM do you have?
     

Share This Page