Имеется виртуальная машина, на ней 4 ядра 10г оперативной памяти, ssd диски в рейд 1. Присутствует сайт: nginx + php + форк mysql(mariadb). Конфигурационный файл my.cnf
innodb_stats_on_metadata = OFF
#skip-network
myisam_use_mmap
query_cache_type = 0
innodb_log_buffer_size = 16M
innodb_buffer_pool_size = 5G
innodb_thread_concurrency = 5
innodb_additional_mem_pool_size = 8M
innodb_buffer_pool_instances = 2
tmp_table_size = 256M
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
#long_query_time = 2
#log_queries_not_using_indexes = 1
### DANGER ###
#innodb_flush_method = O_DIRECT
##############
thread_cache = 256
#thread_cache_size = 64M
query_cache_size = 128M
join_buffer_size = 8M
query_cache_limit = 2M
#lc-messages-dir = /usr/share/mysql
skip-external-locking
default-storage-engine = innodb
max_heap_table_size = 512M
read_buffer_size = 16M
read_rnd_buffer_size = 16M
key_buffer_size = 32M
max_allowed_packet = 32M
thread_stack = 16M
myisam-recover = BACKUP
max_connections = 768
log_error = /var/log/mysql/error.log
log_warnings = 1
expire_logs_days = 7
max_binlog_size = 100M
innodb_file_per_table
table_open_cache = 800
skip-name-resolve=1
server-id = 1
report_host = master1
log_bin = /var/lib/mysql/mariadb-bin
log_bin_index = /var/lib/mysql/mariadb-bin.index
relay_log = /var/lib/mysql/relay-bin
relay_log_index = /var/lib/mysql/relay-bin.index
replicate-do-db = name_db
replicate-do-db = phpmyadmin
binlog_format = row
[mysqldump]
quick
quote-names
max_allowed_packet = 32M
[mysql]
default-character-set=utf8
[isamchk]
#key_buffer = 16M
!includedir /etc/mysql/conf.d/
-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: (0B)
[!!] Log file doesn't exist
[!!] Log file isn't readable.
-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
[--] Data in MyISAM tables: 61K (Tables: 13)
[--] Data in InnoDB tables: 3G (Tables: 78)
[OK] Total fragmented tables: 0
-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] User 'farmskins@%' hasn't specific host restriction.
[!!] User 'm30491_dbuser2@%' hasn't specific host restriction.
[!!] User 'slave_user@%' hasn't specific host restriction.
[--] There are 612 basic passwords in the list.
-------- CVE Security Recommendations --------------------------------------------------------------
[OK] NO SECURITY CVE FOUND FOR YOUR VERSION
-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 1d 15h 52m 16s (41M q [287.442 qps], 1M conn, TX: 33G, RX: 3G)
[--] Reads / Writes: 96% / 4%
[--] Binary logging is enabled (GTID MODE: OFF)
[--] Physical Memory : 9.8G
[--] Max MySQL memory : 49.1G
[--] Other process memory: 1.0G
[--] Total buffers: 5.6G global + 58.0M per thread (768 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 13.8G (141.55% of installed RAM)
[!!] Maximum possible memory usage: 49.1G (502.30% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (9K/41M)
[OK] Highest usage of available connections: 19% (146/768)
[OK] Aborted connections: 0.01% (120/1722788)
[!!] Query cache may be disabled by default due to mutex contention.
[!!] Query cache efficiency: 11.7% (9M cached / 83M selects)
[!!] Query cache prunes per day: 102894
[OK] Sorts requiring temporary tables: 0% (722 temp sorts / 963K sorts)
[!!] Joins performed without indexes: 6706207
[OK] Temporary tables created on disk: 1% (525K on disk / 45M total)
[OK] Thread cache hit rate: 99% (146 created / 1M connections)
[OK] Table cache hit rate: 94% (511 open / 541 opened)
[OK] Open file limit used: 2% (93/3K)
[OK] Table locks acquired immediately: 100% (67M immediate / 67M locks)
[OK] Binlog cache memory access: 100.00% (1004158 Memory / 1004158 Total)
-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 8 thread(s).
[--] Using default value is good enough for your version (10.1.18-MariaDB-1~trusty)
-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.3% (6M used / 33M cache)
[OK] Key buffer size / total MyISAM indexes: 32.0M/171.0K
[OK] Read Key buffer hit rate: 100.0% (1M cached / 9 reads)
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 5
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 5.0G/3.3G
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (1.875 %): 48.0M * 2/5.0G should be equal 25%
[!!] InnoDB buffer pool instances: 2
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 100.00% (166052968436 hits/ 166053065313 total)
[!!] InnoDB Write Log efficiency: 27.87% (394076 hits/ 1414036 total)
[OK] InnoDB log waits: 0.00% (0 waits / 1019960 writes)
-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/1B
[OK] Aria pagecache hit rate: 99.6% (133M cached / 524K reads)
-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.
-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.
-------- RocksDB Metrics ---------------------------------------------------------------------------
[--] RocksDB is disabled.
-------- Spider Metrics ----------------------------------------------------------------------------
[--] Spider is disabled.
-------- Connect Metrics ---------------------------------------------------------------------------
[--] Connect is disabled.
-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.
-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] This server is acting as master for 1 server(s).
[--] No replication setup for this server.
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
Restrict Host for user@% to user@SpecificDNSorIp
Reduce your overall MySQL memory footprint for system stability
Dedicate this server to your database for highest performance.
Increasing the query_cache size over 128M may reduce performance
Adjust your join queries to always utilize indexes
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
query_cache_type (=0)
query_cache_limit (> 2M, or use smaller result sets)
query_cache_size (> 128M) [see warning above]
join_buffer_size (> 8.0M, or always use indexes with joins)
innodb_log_file_size should be equals to 1/4 of buffer pool size (=1G) if possible.
innodb_buffer_pool_instances(=5)
Проверка Qcache в самом mysql:
MariaDB [(none)]> SHOW STATUS LIKE 'Qcache%';
+-------------------------+----------+
| Variable_name | Value |
+-------------------------+----------+
| Qcache_free_blocks | 14380 |
| Qcache_free_memory | 35054664 |
| Qcache_hits | 9778972 |
| Qcache_inserts | 6256712 |
| Qcache_lowmem_prunes | 171581 |
| Qcache_not_cached | 18163532 |
| Qcache_queries_in_cache | 18775 |
| Qcache_total_blocks | 60116 |
+-------------------------+----------+
Как я понял, не разумно выставил параметры cache.
Каким образом можно улучшить производительность mysql?