mysqltuner输出,设置建议?

3yhwsihp  于 2021-06-24  发布在  Mysql
关注(0)|答案(2)|浏览(310)

我没有250GB的ram(按我们的预算),我现在有70gb,使用一个小时后就满了57gb(mysql缓冲区)。
我几乎不确定:
临时表缓冲区查询缓存修剪联接缓冲区和查询缓存大小
innodb缓冲区可能不会太小,其中很大一部分240gb很少被访问。我想大部分的访问都是缓冲的。
其中一些值已经处于边缘,我读到这是没有好处的(比如128mbtmp\u表或1mb join\u缓冲区)

[--] 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
biswetbf

biswetbf1#

让我们尝试在70gb内存内工作。”innodb缓冲池/数据大小:46.0g/240.6g“如果你没有太严重的颠簸的话就可以了。通常,改进索引和/或查询会有所帮助。
我看到的查询缓存规范还不错。但它有多大?它的价值是什么 query_cache_size ? 如果超过50米,那就太大了,因为梅子太贵了。
不要更改mysqltuner建议的其他设置。
你大概有50个 query_cache_prunes 每秒,太高了。
所以,虽然命中率很高,但我怀疑qc没有得到很好的调整。建议:
找出哪些查询可能会重复,哪些不会。把常用的换成 SELECT SQL_CACHE ... 把不常见的换成 SELECT SQL_NO_CACHE ... . 换成 query_cache_type = DEMAND .
为了更深入地挖掘,并解决一些缓慢的查询,请按照这里的建议。

dy2hfwbg

dy2hfwbg2#

在配置文件中要执行的操作:

thread_cache_size=100  # from 16  for V8 suggested CAP on busy system
innodb_buffer_pool_instances=8  # from default 1 to reduce mutex contention
query_cache_min_res_unit=512  # from 4K to increase capacity of QC
query_cache_limit=1M  # from 3M - 180M QC could only hold 60 of them
query_prealloc_size=32768  # from def 8192 to reduce malloc load
max_write_lock_count=2  # from a huge number to give RD opportunity every 2
max_connections=500  # from 1500 will leave 20% growth room
thread_concurrency=30  # to prevent saturation
key_age_threshold=64800  # why discard a key at 5 minutes? keep keep 18 hrs
key_cache_division_limit=50  # from 100% for warm cache to manage
key_cache_block_size=32768  # from 1024 to reduce CPU overhead

相关问题