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 Database Optimize recommendations.

Discussion in 'Workarounds and Optimization' started by comixfreak, Aug 17, 2015.

  1. comixfreak

    comixfreak Registered

    Joined:
    Aug 17, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Iceland
    cPanel Access Level:
    Website Owner
    Firstly, I am very new to managing my own server. I currently have a dedicated server with 500gb SATA II and 4gb memory. Based on my MySQLTuner output below what would you recommend? Thanks in advance!

    Code:
     >>  MySQLTuner 1.5.0 - Major Hayden <major@mhtx.net>
    >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
    >>  Run with '--help' for additional options and output filtering
    [OK] Currently running supported MySQL version 5.5.42-cll
    [OK] Operating on 64-bit architecture
    
    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM
    [--] Data in MyISAM tables: 30M (Tables: 73)
    [--] Data in InnoDB tables: 121M (Tables: 82)
    [!!] Total fragmented tables: 13
    
    -------- Security Recommendations  -------------------------------------------
    [OK] There is no anonymous account in all database users
    [OK] All database users have passwords assigned
    [--] There is 605 basic passwords in the list.
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 11m 40s (125K q [179.001 qps], 1K conn, TX: 3B, RX: 16M)
    [--] Reads / Writes: 93% / 7%
    [--] Binary logging is disabled
    [--] Total buffers: 168.0M global + 2.8M per thread (151 max threads)
    [OK] Maximum reached memory usage: 220.2M (6.07% of installed RAM)
    [OK] Maximum possible memory usage: 583.2M (16.06% of installed RAM)
    [OK] Slow queries: 0% (0/125K)
    [OK] Highest usage of available connections: 12% (19/151)
    [OK] Aborted connections: 0.15%  (2/1317)
    [!!] Key buffer used: 25.3% (2M used / 8M cache)
    [OK] Key buffer size / total MyISAM indexes: 8.0M/8.1M
    [OK] Read Key buffer hit rate: 100.0% (4M cached / 576 reads)
    [!!] Query cache is disabled
    [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 16K sorts)
    [!!] Temporary tables created on disk: 71% (6K on disk / 9K total)
    [!!] Thread cache is disabled
    [OK] Table cache hit rate: 91% (71 open / 78 opened)
    [OK] Open file limit used: 0% (24/10K)
    [OK] Table locks acquired immediately: 100% (131K immediate / 131K locks)
    
    -------- InnoDB Metrics -----------------------------------------------------
    [--] InnoDB is enabled.
    [OK] InnoDB buffer pool / data size: 128.0M/121.4M
    [OK] InnoDB buffer pool instances: 1
    [!!] InnoDB Used buffer: 62.52% (5122 used/ 8192 total)
    [OK] InnoDB Read buffer efficiency: 99.99% (36679442 hits/ 36683601 total)
    [!!] InnoDB Write buffer efficiency: 0.00% (0 hits/ 1 total)
    [OK] InnoDB log waits: 0.00% (0 waits / 4945 writes)
    
    -------- Replication Metrics -------------------------------------------------
    [--] No replication slave(s) for this server.
    [--] This is a standalone server..
    
    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Run OPTIMIZE TABLE to defragment tables for better performance
        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
        Set thread_cache_size to 4 as a starting value
    Variables to adjust:
        query_cache_size (>= 8M)
        tmp_table_size (> 16M)
        max_heap_table_size (> 16M)
        thread_cache_size (start at 4)
     
  2. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,146
    Likes Received:
    34
    Trophy Points:
    48
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Hello,

    I recommend this MySQL tuner scripts after MySQL has been running for at least 24 hours. The output you pasted shows it was only up for 11 minutes when the tuner was ran. So please run this scripts again after 24 hours uptime of your MySQL services
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,762
    Likes Received:
    662
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Yes, please let MySQL run for at least 24 hours to ensure the results are accurate. Also, feel free to update the "Variables to adjust" as advised in the results and run the tuner again.

    Thank you.
     
  4. comixfreak

    comixfreak Registered

    Joined:
    Aug 17, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Iceland
    cPanel Access Level:
    Website Owner
    Reason I can't get up for 24 is my server is crashing. The hosting company is unsure why other then saying we are running out of memory. So I am upgrading to 8gb RAM. Also switched to MariaDB and if anyone has other recommendations I would appreciate it.

    Code:
     >>  MySQLTuner 1.5.0 - Major Hayden <major@mhtx.net>
    >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
    >>  Run with '--help' for additional options and output filtering
    [!!] Currently running unsupported MySQL version 10.0.21-MariaDB
    [OK] Operating on 64-bit architecture
    
    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: +ARCHIVE +Aria +BLACKHOLE +CSV +FEDERATED +InnoDB +MRG_MyISAM
    [--] Data in MyISAM tables: 32M (Tables: 73)
    [--] Data in InnoDB tables: 129M (Tables: 82)
    [!!] Total fragmented tables: 13
    
    -------- Security Recommendations  -------------------------------------------
    [OK] There is no anonymous account in all database users
    [OK] All database users have passwords assigned
    [--] There is 605 basic passwords in the list.
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 55m 20s (443K q [133.721 qps], 5K conn, TX: 12B, RX: 57M)
    [--] Reads / Writes: 92% / 8%
    [--] Binary logging is disabled
    [--] Total buffers: 856.0M global + 2.8M per thread (151 max threads)
    [OK] Maximum reached memory usage: 897.7M (11.70% of installed RAM)
    [OK] Maximum possible memory usage: 1.2G (16.63% of installed RAM)
    [OK] Slow queries: 0% (0/443K)
    [OK] Highest usage of available connections: 9% (15/151)
    [OK] Aborted connections: 0.02%  (1/5149)
    [!!] Key buffer used: 19.3% (25M used / 134M cache)
    [OK] Key buffer size / total MyISAM indexes: 128.0M/8.5M
    [OK] Read Key buffer hit rate: 99.9% (3M cached / 1K reads)
    [!!] Write Key buffer hit rate: 22.2% (3K cached / 2K writes)
    [OK] Query cache efficiency: 33.4% (192K cached / 578K selects)
    [OK] Query cache prunes per day: 0
    [OK] Sorts requiring temporary tables: 0% (0 temp sorts / 19K sorts)
    [!!] Temporary tables created on disk: 77% (10K on disk / 13K total)
    [!!] Thread cache is disabled
    [OK] Table cache hit rate: 222% (111 open / 50 opened)
    [OK] Open file limit used: 0% (40/10K)
    [OK] Table locks acquired immediately: 99% (224K immediate / 224K locks)
    
    -------- InnoDB Metrics -----------------------------------------------------
    [--] InnoDB is enabled.
    [!!] InnoDB  buffer pool / data size: 128.0M/129.3M
    [OK] InnoDB buffer pool instances: 1
    [!!] InnoDB Used buffer: 76.16% (6238 used/ 8191 total)
    [OK] InnoDB Read buffer efficiency: 99.99% (66953309 hits/ 66958268 total)
    [!!] InnoDB Write buffer efficiency: 0.00% (0 hits/ 1 total)
    [OK] InnoDB log waits: 0.00% (0 waits / 20766 writes)
    
    -------- Replication Metrics -------------------------------------------------
    [--] No replication slave(s) for this server.
    [--] This is a standalone server..
    
    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Run OPTIMIZE TABLE to defragment tables for better performance
        MySQL started within last 24 hours - recommendations may be inaccurate
        Temporary table size is already large - reduce result set size
        Reduce your SELECT DISTINCT queries without LIMIT clauses
        Set thread_cache_size to 4 as a starting value
    Variables to adjust:
        thread_cache_size (start at 4)
        innodb_buffer_pool_size (>= 129M) if possible.
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,762
    Likes Received:
    662
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    You may also want to review the MySQL error log located at /var/lib/mysql/$hostname.err to see if you notice any specific error messages when MySQL crashes.

    Thank you.
     
  6. comixfreak

    comixfreak Registered

    Joined:
    Aug 17, 2015
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Iceland
    cPanel Access Level:
    Website Owner
    Hi,

    I am back and have been running great. I check tuner every day just to see how things are going. Here is my current output and my.cnf settings. I have reduced the Temp Table Size as recommended but Select Distinct queries, I am not sure what that is.

    Code:
     >>  MySQLTuner 1.5.0 - Major Hayden <major@mhtx.net>
    >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
    >>  Run with '--help' for additional options and output filtering
    [!!] Currently running unsupported MySQL version 10.0.21-MariaDB-log
    [OK] Operating on 64-bit architecture
    
    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: +ARCHIVE +Aria +BLACKHOLE +CSV +FEDERATED +InnoDB +MRG_MyISAM
    [--] Data in MyISAM tables: 81M (Tables: 79)
    [--] Data in InnoDB tables: 128M (Tables: 79)
    [!!] Total fragmented tables: 12
    
    -------- Security Recommendations  -------------------------------------------
    [OK] There is no anonymous account in all database users
    [OK] All database users have passwords assigned
    [--] There is 605 basic passwords in the list.
    
    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 2d 9h 43m 35s (40M q [192.888 qps], 483K conn, TX: 1291B, RX: 4B)
    [--] Reads / Writes: 97% / 3%
    [--] Binary logging is disabled
    [--] Total buffers: 1.1G global + 2.8M per thread (151 max threads)
    [OK] Maximum reached memory usage: 1.4G (19.27% of installed RAM)
    [OK] Maximum possible memory usage: 1.5G (20.65% of installed RAM)
    [OK] Slow queries: 1% (520K/40M)
    [OK] Highest usage of available connections: 74% (113/151)
    [OK] Aborted connections: 0.00%  (1/483118)
    [!!] Key buffer used: 28.7% (38M used / 134M cache)
    [OK] Key buffer size / total MyISAM indexes: 128.0M/17.6M
    [OK] Read Key buffer hit rate: 100.0% (1B cached / 25K reads)
    [!!] Write Key buffer hit rate: 26.5% (282K cached / 207K writes)
    [OK] Query cache efficiency: 39.0% (22M cached / 58M selects)
    [OK] Query cache prunes per day: 0
    [OK] Sorts requiring temporary tables: 0% (25 temp sorts / 1M sorts)
    [!!] Temporary tables created on disk: 31% (560K on disk / 1M total)
    [OK] Thread cache hit rate: 93% (32K created / 483K connections)
    [OK] Table cache hit rate: 45% (400 open / 881 opened)
    [OK] Open file limit used: 2% (255/10K)
    [OK] Table locks acquired immediately: 99% (13M immediate / 13M locks)
    
    -------- InnoDB Metrics -----------------------------------------------------
    [--] InnoDB is enabled.
    [OK] InnoDB buffer pool / data size: 180.0M/128.8M
    [OK] InnoDB buffer pool instances: 1
    [!!] InnoDB Used buffer: 74.07% (8532 used/ 11519 total)
    [OK] InnoDB Read buffer efficiency: 100.00% (5953132344 hits/ 5953136814 total)
    [!!] InnoDB Write buffer efficiency: 0.00% (0 hits/ 1 total)
    [OK] InnoDB log waits: 0.00% (0 waits / 932542 writes)
    
    -------- Replication Metrics -------------------------------------------------
    [--] No replication slave(s) for this server.
    [--] This is a standalone server..
    
    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Run OPTIMIZE TABLE to defragment tables for better performance
        Temporary table size is already large - reduce result set size
        Reduce your SELECT DISTINCT queries without LIMIT clauses
    Code:
    [mysqld]
    default-storage-engine=MyISAM
    innodb_file_per_table=1
    max_allowed_packet=268435456
    open_files_limit=10000
    innodb_buffer_pool_instances = 1
    innodb_buffer_pool_size = 180M
    thread_cache_size=4
    skip-name-resolve
    query_cache_type = 1
    query_cache_limit = 256K
    query_cache_min_res_unit = 2k
    query_cache_size = 200M
    tmp_table_size= 448M
    max_heap_table_size= 448M
    wait_timeout=60
    slow_query_log=1
    slow_query_log_file=mysql-slow.log
    long_query_time=0.1
    log-queries-not-using-indexes
     
Loading...

Share This Page