We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on Vesta 2.0 and expect to release it by the end of 2024. Read more about it: https://vestacp.com/docs/vesta-2-development
Скрипты для тюнинга MySQL
Скрипты для тюнинга MySQL
MySQLTuner
Скачиваем
Запускаем:
или
Performance Metrics и Recommendations - ваши друзья
MySQL performance tuning prime
Скачиваем:
Запускаем:
---
PS: Помните, что это не панацея, а старт. Не нужно слепо следовать рекомендациям, пробуйте и проверяйте.
Скачиваем
Code: Select all
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl --no-check-certificate
Code: Select all
perl mysqltuner.pl
Code: Select all
perl mysqltuner.pl --user root --pass rootpassword
Пример выводаShow
Code: Select all
-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 44d 17h 59m 10s (2B q [573.704 qps], 9M conn, TX: 6971G, RX: 468G)
[--] Reads / Writes: 91% / 9%
[--] Binary logging is disabled
[--] Physical Memory : 15.6G
[--] Max MySQL memory : 9.0G
[--] Other process memory: 244.5M
[--] Total buffers: 608.0M global + 34.2M per thread (250 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 9.0G (57.74% of installed RAM)
[OK] Maximum possible memory usage: 9.0G (57.52% of installed RAM)
[OK] Overall possible memory usage with other process is compatible with memory available
[OK] Slow queries: 0% (17K/2B)
[!!] Highest connection usage: 100% (251/250)
[!!] Aborted connections: 4.26% (408724/9598439)
[!!] Query cache may be disabled by default due to mutex contention.
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 49M sorts)
[!!] Joins performed without indexes: 450259
[!!] Temporary tables created on disk: 28% (16M on disk / 58M total)
[OK] Thread cache hit rate: 99% (3K created / 9M connections)
[!!] Table cache hit rate: 10% (8K open / 74K opened)
[OK] Open file limit used: 2% (11K/500K)
[OK] Table locks acquired immediately: 99% (468M immediate / 468M locks)
-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.
-------- MyISAM Metrics ----------------------------------------------------------------------------
[OK] Key buffer used: 99.9% (33M used / 33M cache)
[OK] Key buffer size / total MyISAM indexes: 32.0M/717.9M
[OK] Read Key buffer hit rate: 100.0% (589B cached / 94M reads)
[OK] Write Key buffer hit rate: 99.6% (6B cached / 30M writes)
-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is disabled.
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB buffer pool / data size: 512.0M/357.7M
[OK] InnoDB buffer pool instances: 1
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 100.00% (19723956887 hits/ 19724049028 total)
[!!] InnoDB Write Log efficiency: 59.76% (7444679 hits/ 12458378 total)
[OK] InnoDB log waits: 0.00% (0 waits / 5013699 writes)
-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.
-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.
-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] This is a standalone server.
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
Set up a Secure Password for user@host ( SET PASSWORD FOR 'user'@'SpecificDNSorIp' = PASSWORD('secure_password'); )
Restrict Host for user@% to user@SpecificDNSorIp
Enable the slow query log to troubleshoot bad queries
Reduce or eliminate persistent connections to reduce connection usage
Reduce or eliminate unclosed connections and network issues
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 which have no LIMIT clause
Increase table_open_cache gradually to avoid file descriptor limits
Read this before increasing table_open_cache over 64: http://bit.ly/1mi7c4C
Beware that open_files_limit (500000) variable
should be greater than table_open_cache ( 8192)
Variables to adjust:
max_connections (> 250)
wait_timeout (< 25)
interactive_timeout (< 50)
query_cache_type (=0)
join_buffer_size (> 16.0M, or always use indexes with joins)
tmp_table_size (> 8M)
max_heap_table_size (> 16M)
table_open_cache (> 8192)
Скачиваем:
Code: Select all
wget https://launchpadlibrarian.net/78745738/tuning-primer.sh
Code: Select all
chmod +x tuning-primer.sh
./tuning-primer.sh
Пример выводаShow
Code: Select all
-- MYSQL PERFORMANCE TUNING PRIMER --
Current MyISAM index space = 717 M acceptable normsem memoryay be safeo complete
Current key_buffer_size = 32 M
Key cache miss rate is 1 : 6207
Key buffer free ratio = 0 %
You could increase key_buffer_size
It is safe to raise this up to 1/4 of total system memory;
assuming this is a dedicated database server.
QUERY CACHE
Query cache is enabled
Current query_cache_size = 16 M
Current query_cache_used = 12 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 79.86 %
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 = 16 M
Current read_rnd_buffer_size = 1 M
Sort buffer seems to be fine
JOINS
Current join_buffer_size = 16.00 M
You have had 450256 queries where a join could not use an index properly
join_buffer_size >= 4 M
This is not advised
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
OPEN FILES LIMIT
Current open_files_limit = 500000 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 = 8192 tables
Current table_definition_cache = 8192 tables
You have a total of 6164 tables
You have 8192 open tables.
Current table_cache hit rate is 10%
, while 100% of your table cache is in use
You should probably increase your table_cache
TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 8 M
Of 58531429 temp tables, 22% were created on disk
Created disk tmp tables ratio seems fine
TABLE SCANS
Current read_buffer_size = 1 M
Current table scan ratio = 455 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 1 : 8445
Your table locking seems to be fine
PS: Помните, что это не панацея, а старт. Не нужно слепо следовать рекомендациям, пробуйте и проверяйте.