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.

MySQL optimize help

Discussion in 'Workarounds and Optimization' started by SamiBH, Nov 21, 2010.

  1. SamiBH

    SamiBH Member

    Joined:
    Jul 20, 2010
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Hello everybody I need help to optimize MySQL

    VPS

    Shared Dual Quad Core CPU / 50 GB HDD / 500 GB Bandwidth / 256 MB Memory (1024 MB Burstable)

    my.cnf only have 3 lines :)

    Code:
    [mysqld]
    set-variable = max_connections=500
    log-slow-queries
    safe-show-database
    
    Code:
    -------- General Statistics --------------------------------------------------
    [--] Skipped version check for MySQLTuner script
    [OK] Currently running supported MySQL version 5.0.91-community-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: 665M (Tables: 185)
    [!!] InnoDB is enabled but isn't being used
    [!!] Total fragmented tables: 7
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 25m 35s (130K q [84.793 qps], 3K conn, TX: 96M, RX: 15M)
    [--] Reads / Writes: 87% / 13%
    [--] Total buffers: 34.0M global + 2.7M per thread (500 max threads)
    [!!] Maximum possible memory usage: 1.3G (134% of installed RAM)
    [OK] Slow queries: 0% (0/130K)
    [OK] Highest usage of available connections: 4% (20/500)
    [OK] Key buffer size / total MyISAM indexes: 8.0M/51.0M
    [OK] Key buffer hit rate: 100.0% (137M cached / 4K reads)
    [!!] Query cache is disabled
    [OK] Sorts requiring temporary tables: 0% (1 temp sorts / 11K sorts)
    [!!] Joins performed without indexes: 157
    [!!] Temporary tables created on disk: 29% (479 on disk / 1K total)
    [!!] Thread cache is disabled
    [OK] Table cache hit rate: 20% (64 open / 311 opened)
    [OK] Open file limit used: 4% (104/2K)
    [OK] Table locks acquired immediately: 99% (160K immediate / 161K locks)
    
    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Add skip-innodb to MySQL configuration to disable InnoDB
        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
        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
    Variables to adjust:
      *** MySQL's maximum memory usage is dangerously high ***
      *** Add RAM before increasing MySQL buffer variables ***
        query_cache_size (>= 8M)
        join_buffer_size (> 128.0K, or always use indexes with joins)
        tmp_table_size (> 32M)
        max_heap_table_size (> 16M)
        thread_cache_size (start at 4)
    
    
    thank you to everyone who can help
     
  2. GaryT

    GaryT Well-Known Member

    Joined:
    May 19, 2010
    Messages:
    321
    Likes Received:
    3
    Trophy Points:
    16
    Seems your mysql is default so what we do is start building it bit by bit:

    Edit your my.cnf and make it show:

    save this and restart mysql:

    You should leave it for 24 hours before running mysql tuner again, When you do post the output of your tuner so we can build further.
     
  3. SamiBH

    SamiBH Member

    Joined:
    Jul 20, 2010
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    thank you

    I Edited my.cnf , and will post mysql tuner after 24 hours

    thank you again
     
  4. SamiBH

    SamiBH Member

    Joined:
    Jul 20, 2010
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    here is it after 24 hours

    thank you
     
  5. GaryT

    GaryT Well-Known Member

    Joined:
    May 19, 2010
    Messages:
    321
    Likes Received:
    3
    Trophy Points:
    16
    Edit your my.cnf and use these settings as suggested:

    Then restart mysql.

    :)
     
  6. SamiBH

    SamiBH Member

    Joined:
    Jul 20, 2010
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    done.

    thank you

    what about

    "Add skip-innodb to MySQL configuration to disable InnoDB
    Run OPTIMIZE TABLE to defragment tables for better performance"

    also

    "log-slow-queries=/var/lib/mysql/slow.log" what counts as slow query (5 seconds?) .can I change it to 2 seconds?
     
    #6 SamiBH, Nov 22, 2010
    Last edited: Nov 22, 2010
  7. GaryT

    GaryT Well-Known Member

    Joined:
    May 19, 2010
    Messages:
    321
    Likes Received:
    3
    Trophy Points:
    16
    in your my.cnf just add the line:

    Also

    Just run this command:

    Make sure you have your mysql root password to hand as soon as you press enter to run this is will require the password.

    You can change the log to that yes but default is 5, All up to you :)
     
  8. SamiBH

    SamiBH Member

    Joined:
    Jul 20, 2010
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    thank you so much

    I'm still having problem with Table cache hit rate

    is there more options I should add in my.cnf ?

    Code:
    [mysqld]
    skip-innodb
    set-variable = max_connections=200
    query_cache_type=1
    query_cache_size=32M
    query_cache_limit=1M
    sort_buffer_size=2M
    read_rnd_buffer_size=512K
    tmp_table_size=32M
    max_heap_table_size=32M
    thread_cache_size=24
    key_buffer_size=16M
    table_cache=128
    join_buffer_size=1M
    log-slow-queries=/var/lib/mysql/slow.log
    
     
  9. GaryT

    GaryT Well-Known Member

    Joined:
    May 19, 2010
    Messages:
    321
    Likes Received:
    3
    Trophy Points:
    16
    You can increase this to your own liking, Its always best to post the full mysqltuner output.

    Use these settings.


     
Loading...

Share This Page