(Debian 7 32-bits KVM with 512mb RAM - SSD storage - 1 cpu)
The server is not mysql dedicated.
It runs a small forum on it. (Mysql -> read-mostly)
Does anyone have any advice as to how I can optimise my MySQL installation?
The server have no lags on peak times.
My current config in my my.cnf file is:
[mysqld] #skip-locking #skip-innodb #skip-name-resolve #skip-networking #skip-bdb local-infile=0 # Logs log_error=/var/log/mysql/mysql_error.log #log_slow_queries=/var/log/mysql/mysql_slow.log #long_query_time=10 #log-queries-not-using-indexes # Buffers key_buffer_size=16M sort_buffer_size=1M join_buffer_size=1M max_join_size=2M #Threads thread_concurrency=2 thread_cache_size=1 #Table_cache table_cache=1024 #Temp tables max_heap_table_size=128M tmp_table_size=128M #Query_cache query_cache_limit=1M query_cache_size=16M #Timeouts interactive_timeout=90 wait_timeout=90 #Connections max_connections=50 #[innodb] innodb_buffer_pool_size=128M innodb_file_per_table=1 innodb_log_file_size=5M innodb_thread_concurrency=1
When I run MySQLTuner, this is what I get:
>> MySQLTuner 1.3.0 - Major Hayden <email@example.com> >> Bug reports, feature requests, and downloads at http://mysqltuner.com/ >> Run with '--help' for additional options and output filtering [OK] Logged in using credentials from debian maintenance account. [OK] Currently running supported MySQL version 5.5.36-34.2-648.wheezy [OK] Operating on 32-bit architecture with less than 2GB RAM -------- Storage Engine Statistics ------------------------------------------- [--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MRG_MYISAM [--] Data in MyISAM tables: 5M (Tables: 64) [--] Data in InnoDB tables: 82M (Tables: 195) [--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17) [--] Data in MEMORY tables: 252K (Tables: 3) [!!] Total fragmented tables: 26 -------- Security Recommendations ------------------------------------------- [OK] All database users have passwords assigned -------- Performance Metrics ------------------------------------------------- [--] Up for: 8d 4h 46m 25s (2M q [3.459 qps], 181K conn, TX: 7B, RX: 521M) [--] Reads / Writes: 54% / 46% [--] Total buffers: 304.0M global + 2.6M per thread (50 max threads) [!!] Maximum possible memory usage: 432.1M (86% of installed RAM) [OK] Slow queries: 0% (0/2M) [OK] Highest usage of available connections: 62% (31/50) [OK] Key buffer size / total MyISAM indexes: 16.0M/5.1M [OK] Key buffer hit rate: 99.8% (1M cached / 2K reads) [OK] Query cache efficiency: 74.4% (1M cached / 1M selects) [!!] Query cache prunes per day: 3959 [OK] Sorts requiring temporary tables: 0% (21 temp sorts / 81K sorts) [!!] Joins performed without indexes: 30762 [!!] Temporary tables created on disk: 46% (74K on disk / 160K total) [OK] Thread cache hit rate: 86% (25K created / 181K connections) [!!] Table cache hit rate: 10% (347 open / 3K opened) [OK] Open file limit used: 8% (178/2K) [OK] Table locks acquired immediately: 99% (1M immediate / 1M locks) [OK] InnoDB buffer pool / data size: 128.0M/82.8M [OK] InnoDB log waits: 0 -------- Recommendations ----------------------------------------------------- General recommendations: Run OPTIMIZE TABLE to defragment tables for better performance Reduce your overall MySQL memory footprint for system stability 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 Increase table_cache gradually to avoid file descriptor limits Read this before increasing table_cache over 64: http://bit.ly/1mi7c4C Variables to adjust: query_cache_size (> 16M) join_buffer_size (> 1.0M, or always use indexes with joins) tmp_table_size (> 128M) max_heap_table_size (> 128M) table_cache (> 1024)
When I run TUNING PRIMER, this is what I get:
-- MYSQL PERFORMANCE TUNING PRIMER -- - By: Matthew Montgomery - MySQL Version 5.5.36-34.2-648.wheezy i686 Uptime = 8 days 4 hrs 47 min 29 sec Avg. qps = 3 Total Questions = 2450393 Threads Connected = 1 Server has been running for over 48hrs. It should be safe to follow these recommendations To find out more information on how each of these runtime variables effects performance visit: http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html Visit http://www.mysql.com/products/enterprise/advisors.html for info about MySQL's Enterprise Monitoring and Advisory Service SLOW QUERIES The slow query log is NOT enabled. Current long_query_time = 10.000000 sec. You have 0 out of 2450414 that take longer than 10.000000 sec. to complete Your long_query_time seems to be fine BINARY UPDATE LOG The binary update log is NOT enabled. You will not be able to do point in time recovery See http://dev.mysql.com/doc/refman/5.5/en/point-in-time-recovery.html WORKER THREADS Current thread_cache_size = 1 Current threads_cached = 0 Current threads_per_sec = 0 Historic threads_per_sec = 0 Your thread_cache_size is fine MAX CONNECTIONS Current max_connections = 50 Current threads_connected = 1 Historic max_used_connections = 31 The number of used connections is 62% of the configured maximum. Your max_connections variable seems to be fine. INNODB STATUS Current InnoDB index space = 25 M Current InnoDB data space = 82 M Current InnoDB buffer pool free = 13 % Current innodb_buffer_pool_size = 128 M Depending on how much space your innodb indexes take up it may be safe to increase this value to up to 2 / 3 of total system memory MEMORY USAGE Max Memory Ever Allocated : 255 M Configured Max Per-thread Buffers : 128 M Configured Max Global Buffers : 176 M Configured Max Memory Limit : 304 M Physical Memory : 502 M Max memory limit seem to be within acceptable norms KEY BUFFER Current MyISAM index space = 5 M Current key_buffer_size = 16 M Key cache miss rate is 1 : 513 Key buffer free ratio = 67 % Your key_buffer_size seems to be fine QUERY CACHE Query cache is enabled Current query_cache_size = 16 M Current query_cache_used = 9 M Current query_cache_limit = 1 M Current Query cache Memory fill ratio = 60.50 % Current query_cache_min_res_unit = 4 K MySQL won't cache query results that are larger than query_cache_limit in size SORT OPERATIONS Current sort_buffer_size = 1 M Current read_rnd_buffer_size = 256 K Sort buffer seems to be fine JOINS Current join_buffer_size = 1.00 M You have had 30765 queries where a join could not use an index properly You should enable "log-queries-not-using-indexes" Then look for non indexed joins in the slow query log. If you are unable to optimize your queries you may want to increase your join_buffer_size to accommodate larger joins in one pass. Note! This script will still suggest raising the join_buffer_size when ANY joins not using indexes are found. OPEN FILES LIMIT Current open_files_limit = 2109 files The open_files_limit should typically be set to at least 2x-3x that of table_cache if you have heavy MyISAM usage. Your open_files_limit value seems to be fine TABLE CACHE Current table_open_cache = 1024 tables Current table_definition_cache = 400 tables You have a total of 303 tables You have 348 open tables. The table_cache value seems to be fine TEMP TABLES Current max_heap_table_size = 128 M Current tmp_table_size = 128 M Of 86516 temp tables, 46% were created on disk Perhaps you should increase your tmp_table_size and/or max_heap_table_size to reduce the number of disk-based temporary tables Note! BLOB and TEXT columns are not allow in memory tables. If you are using these columns raising these values might not impact your ratio of on disk temp tables. TABLE SCANS Current read_buffer_size = 128 K Current table scan ratio = 489 : 1 read_buffer_size seems to be fine TABLE LOCKING Current Lock Wait ratio = 1 : 178950 Your table locking seems to be fine