Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    Jul 2010
    Posts
    9

    Default MySQL optimize help

    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. #2
    Member
    Join Date
    May 2010
    Posts
    321

    Default Re: MySQL optimize help

    Seems your mysql is default so what we do is start building it bit by bit:

    Edit your my.cnf and make it show:

    [mysqld]
    set-variable = max_connections=200
    query_cache_type=1
    query_cache_size=8M
    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=80
    join_buffer_size=1M
    log-slow-queries=/var/lib/mysql/slow.log
    save this and restart mysql:

    /etc/init.d/mysql restart
    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. #3
    Member
    Join Date
    Jul 2010
    Posts
    9

    Default Re: MySQL optimize help

    thank you

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

    thank you again

  4. #4
    Member
    Join Date
    Jul 2010
    Posts
    9

    Default Re: MySQL optimize help

    here is it after 24 hours

    -------- 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: 9

    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 1d 3h 6m 12s (8M q [86.629 qps], 237K conn, TX: 2B, RX: 1B)
    [--] Reads / Writes: 53% / 47%
    [--] Total buffers: 66.0M global + 3.8M per thread (200 max threads)
    [OK] Maximum possible memory usage: 828.5M (80% of installed RAM)
    [OK] Slow queries: 0% (0/8M)
    [OK] Highest usage of available connections: 12% (24/200)
    [OK] Key buffer size / total MyISAM indexes: 16.0M/51.5M
    [OK] Key buffer hit rate: 100.0% (4B cached / 52K reads)
    [OK] Query cache efficiency: 85.1% (5M cached / 6M selects)
    [!!] Query cache prunes per day: 5477
    [OK] Sorts requiring temporary tables: 0% (172 temp sorts / 61K sorts)
    [OK] Temporary tables created on disk: 5% (1K on disk / 32K total)
    [OK] Thread cache hit rate: 99% (24 created / 237K connections)
    [!!] Table cache hit rate: 3% (79 open / 2K opened)
    [OK] Open file limit used: 12% (131/1K)
    [OK] Table locks acquired immediately: 99% (2M immediate / 2M locks)

    -------- Recommendations -----------------------------------------------------
    General recommendations:
    Add skip-innodb to MySQL configuration to disable InnoDB
    Run OPTIMIZE TABLE to defragment tables for better performance
    Increase table_cache gradually to avoid file descriptor limits
    Variables to adjust:
    query_cache_size (> 8M)
    table_cache (> 80)
    thank you

  5. #5
    Member
    Join Date
    May 2010
    Posts
    321

    Default Re: MySQL optimize help

    Edit your my.cnf and use these settings as suggested:

    [mysqld]
    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
    Then restart mysql.

    /etc/init.d/mysql restart

  6. #6
    Member
    Join Date
    Jul 2010
    Posts
    9

    Default Re: MySQL optimize help

    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?
    Last edited by SamiBH; 11-22-2010 at 01:07 PM.

  7. #7
    Member
    Join Date
    May 2010
    Posts
    321

    Default Re: MySQL optimize help

    "Add skip-innodb to MySQL configuration to disable InnoDB
    in your my.cnf just add the line:

    skip-innodb
    Also

    Run OPTIMIZE TABLE to defragment tables for better performance"
    Just run this command:

    mysqlcheck -u root -p --auto-repair --check --optimize --all-databases
    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. #8
    Member
    Join Date
    Jul 2010
    Posts
    9

    Default Re: MySQL optimize help

    thank you so much

    I'm still having problem with Table cache hit rate

    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 11h 46m 36s (3M q [81.006 qps], 109K conn, TX: 2B, RX: 425M)
    [--] Reads / Writes: 52% / 48%
    [--] Total buffers: 90.0M global + 3.8M per thread (200 max threads)
    [OK] Maximum possible memory usage: 852.5M (83% of installed RAM)
    [OK] Slow queries: 0% (1/3M)
    [OK] Highest usage of available connections: 17% (34/200)
    [OK] Key buffer size / total MyISAM indexes: 16.0M/51.7M
    [OK] Key buffer hit rate: 100.0% (2B cached / 55K reads)
    [OK] Query cache efficiency: 83.6% (2M cached / 2M selects)
    [OK] Query cache prunes per day: 0
    [OK] Sorts requiring temporary tables: 0% (7 temp sorts / 32K sorts)
    [OK] Temporary tables created on disk: 5% (912 on disk / 17K total)
    [OK] Thread cache hit rate: 99% (45 created / 109K connections)
    [!!] Table cache hit rate: 1% (128 open / 8K opened)
    [OK] Open file limit used: 24% (249/1K)
    [OK] Table locks acquired immediately: 99% (1M immediate / 1M locks)
    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. #9
    Member
    Join Date
    May 2010
    Posts
    321

    Default Re: MySQL optimize help

    I'm still having problem with Table cache hit rate
    You can increase this to your own liking, Its always best to post the full mysqltuner output.

    Use these settings.


    [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=256
    join_buffer_size=1M
    log-slow-queries=/var/lib/mysql/slow.log

Similar Threads & Tags
Similar threads

  1. MySQL optimize help on Xeon
    By saamxvr in forum Optimization
    Replies: 45
    Last Post: 06-01-2011, 09:50 PM
  2. MySQL optimize help for newbe
    By saamxvr in forum Optimization
    Replies: 15
    Last Post: 11-13-2010, 04:13 PM
  3. Optimize MySQL config for 768MB of RAM ?
    By dolphinuk in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 04-04-2009, 11:04 AM
  4. how can i optimize my mysql ?
    By meeti in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 02-23-2008, 11:35 AM
  5. Optimize MySQL
    By Domenico in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 07-26-2002, 12:24 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube