mysqltuner输出,设置建议?

时间:2018-01-15 05:20:38

标签: mysql mariadb

我没有250 GB的RAM(我们的预算方式),我目前有70GB,使用一小时后填充到57GB(mysql缓冲区)。
我大多不确定:
临时表缓冲区 查询缓存修剪 join_buffer和query_cache size

innodb缓冲区可能不是太小,240GB的很大一部分很少被访问。我认为大多数访问内容都是缓冲的。

其中一些值已经处于我读到它没有益处的边缘(如128MB tmp_table或1MB join_buffer)

[--] Up for: 9h 51m 30s (78M q [2K qps], 921K conn, TX: 110B, RX: 26B)
[--] Reads / Writes: 49% / 51%
[--] Total buffers: 46.6G global + 1.9M per thread (1500 max threads)
[OK] Maximum possible memory usage: 49.3G (82% of installed RAM)
[OK] Slow queries: 0% (1K/78M)
[OK] Highest usage of available connections: 28% (428/1500)
[OK] Key buffer size / total MyISAM indexes: 256.0M/1.6G
[OK] Key buffer hit rate: 99.9% (105M cached / 55K reads)
[OK] Query cache efficiency: 26.9% (11M cached / 44M selects)
[!!] Query cache prunes per day: 4482061
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 10M sorts)
[!!] Joins performed without indexes: 603
[!!] Temporary tables created on disk: 49% (1M on disk / 2M total)
[OK] Thread cache hit rate: 99% (6K created / 921K connections)
[OK] Table cache hit rate: 83% (1K open / 2K opened)
[OK] Open file limit used: 12% (633/5K)
[OK] Table locks acquired immediately: 99% (9M immediate / 9M locks)
[!!] InnoDB  buffer pool / data size: 46.0G/240.6G
[OK] InnoDB log waits: 0
-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
    Increasing the query_cache size over 128M may reduce performance
    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
Variables to adjust:
    query_cache_size (> 180M) [see warning above]
    join_buffer_size (> 1.0M, or always use indexes with joins)
    tmp_table_size (> 128M)
    max_heap_table_size (> 128M)
    innodb_buffer_pool_size (>= 240G)

配置:

max_allowed_packet      = 64M
thread_stack            = 256K
thread_cache_size       = 16

max_connections         = 1500
max_user_connections    = 850
query_cache_limit       = 3M
query_cache_size        = 180M
query_cache_type        = 1
table_open_cache        = 2500
key_buffer_size          = 256M   # index in memory for myisam
innodb_buffer_pool_size = 46G
innodb_log_file_size = 256M
tmp_table_size = 128M
max_heap_table_size = 128M
join_buffer_size = 1M

2 个答案:

答案 0 :(得分:0)

让我们尝试在70GB的RAM内工作。 " InnoDB缓冲池/数据大小:46.0​​G / 240.6G"很好如果你没有太厉害。通常,改进索引和/或查询可以提供帮助。

我看到的查询缓存规格并不算太糟糕。但它有多大? query_cache_size的价值是多少?如果它超过50M,它太大了,因为西梅是昂贵的。

请勿更改mysqltuner建议的其他设置。

你每秒大约有50 query_cache_prunes,这太高了。

所以,虽然命中率很高,但我怀疑QC没有很好地调整。建议:

了解哪些查询可能会重复完全,哪些不是。将常用的版本更改为SELECT SQL_CACHE ...,并将不常用的版本更改为SELECT SQL_NO_CACHE ...。并更改为query_cache_type = DEMAND

要深入挖掘并修复一些慢查询,请按照here的建议进行操作。

答案 1 :(得分:0)

在配置文件中要做的事情:

Promise.prototype.then