The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with MySQL optimisation

Discussion in 'Workarounds and Optimization' started by drinky, Jul 3, 2012.

  1. drinky

    drinky Member

    Joined:
    Aug 14, 2003
    Messages:
    7
    Likes Received:
    1
    Trophy Points:
    3
    Hey guys,

    I lost my custom mysql.cnf due to a hard drive meltdown. Hoping someone can help me tweak the configuration.

    This is a dedicated box running Core2 Duo CPU E6750 @ 2.66GHz, 4Gb RAM.

    The default my.cnf


    Code:
    [mysqld]
    innodb_file_per_table=1
    default-storage-engine=MyISAM
    
    character-set-server=utf8
    collation-server=utf8_bin
    
    max_allowed_packet= 64M
    wait_timeout= 6000
    

    Here is my mysqltuner.pl output


    Code:
    >>  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.5.24-cll
    [!!] Switch to 64-bit OS - MySQL cannot currently use all of your RAM
    
    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
    [--] Data in MyISAM tables: 1000M (Tables: 10530)
    [--] Data in InnoDB tables: 169M (Tables: 2704)
    [--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
    [--] Data in MEMORY tables: 0B (Tables: 7)
    [!!] Total fragmented tables: 3180
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 1d 20h 23m 18s (8M q [53.694 qps], 59K conn, TX: 13B, RX: 1B)
    [--] Reads / Writes: 97% / 3%
    [--] Total buffers: 168.0M global + 2.7M per thread (151 max threads)
    [OK] Maximum possible memory usage: 573.8M (14% of installed RAM)
    [OK] Slow queries: 0% (13/8M)
    [OK] Highest usage of available connections: 11% (18/151)
    [OK] Key buffer size / total MyISAM indexes: 8.0M/215.7M
    [OK] Key buffer hit rate: 99.1% (48M cached / 433K reads)
    [!!] Query cache is disabled
    [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 334K sorts)
    [!!] Joins performed without indexes: 29534
    [!!] Temporary tables created on disk: 34% (133K on disk / 382K total)
    [!!] Thread cache is disabled
    [!!] Table cache hit rate: 0% (400 open / 275K opened)
    [OK] Open file limit used: 61% (625/1K)
    [OK] Table locks acquired immediately: 99% (8M immediate / 8M locks)
    [!!] InnoDB data size / buffer pool: 169.7M/128.0M
    
    -------- 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
        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)
        join_buffer_size (> 128.0K, or always use indexes with joins)
        tmp_table_size (> 16M)
        max_heap_table_size (> 16M)
        thread_cache_size (start at 4)
        table_cache (> 400)
        innodb_buffer_pool_size (>= 169M)
    
    I tried myself to add the "Variables to Adjust", listed in the above. however, Mysql would refuse to start.

    Grateful for any assistance which can be provided.

    Cheers
    Drinky
     
  2. srpurdy

    srpurdy Well-Known Member

    Joined:
    Jun 1, 2011
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Code:
    [mysqld]
    # Query Cache
    query_cache_size=128M
    query_cache_limit=8M
    query_cache_type=1
    
    # Thread Settings
    thread_cache_size=8
    
    # Slow Log
    slow-query-log=1
    slow-query-log-file="/var/log/mysql-slow-queries.log"
    #log_queries_not_using_indexes = 1
    long_query_time=2
    
    # File Descriptor
    table_open_cache=8192
    
    # Misc Settings
    max_allowed_packet=64M
    local-infile=0
    default-storage-engine=MyISAM
    innodb_file_per_table=1
    
    # Buffer Settings
    innodb_buffer_pool_size=200M
    key_buffer_size=240M
    read_buffer_size=256K
    sort_buffer_size=256K
    join_buffer_size=256K
    
    # Connection Settings
    max_connections=200
    
    # Timing Settings
    # Optional Custom Timeouts (change as desired)
    #wait_timeout=300
    #connect_timeout=300
    #interactive_timeout=1000
    
    # Temp Tables
    tmp_table_size=64M
    max_heap_table_size=64M
    
    [mysqld_safe]
    pid-file="/var/run/mysqld/mysqld.pid"
    open_files_limit=16384
    log-error="/var/log/mysqld.log"
    
    That should get you going, and if you like to post another tuner report after a few days. I can help you tweak more if needed. :)

    You can replace yours completely with this, as this has all the lines yours currently has.

    Also make sure this file exists.
    /var/log/mysql-slow-queries.log if not create it and give mysql permissions.
     
    #2 srpurdy, Jul 6, 2012
    Last edited: Jul 6, 2012
Loading...

Share This Page