Mariadb迁移后Cache_hits非常低

时间:2014-03-17 15:09:48

标签: performance mariadb

从percona迁移mariadb 5.5后,我们的新数据库引擎出现问题:

我们已经从percona mysql服务器5.5更改为mariadb但性能不如我们想象的那么好。 此图表来自mariadb中的一天。您可以在cache_hits方面看到低性能 http://i.stack.imgur.com/gAApV.png

我们有其他服务器使用percona mysql server 5.5。下图来自其中一个: http://i.stack.imgur.com/5BnjT.png

我们不知道如何只有46%的查询缓存效率。 percona mysql服务器接近90%。

这是来自mariadb服务器的my.conf

#
# * Fine Tuning
#

bulk_insert_buffer_size = 16M

concurrent_insert       = 2
connect_timeout         = 5

interactive_timeout     = 14400
join_buffer_size        = 1G
key_buffer              = 256M
key_buffer_size         = 256M
max_allowed_packet      = 16M
max_connections         = 200

myisam_recover          = BACKUP
myisam_sort_buffer_size = 500M

open_files_limit        = 20000
table_open_cache        = 5000
table_definition_cache  = 3000

query_cache_limit       = 16M
query_cache_size        = 1G
query_cache_min_res_unit = 4K

read_buffer_size        = 8M
read_rnd_buffer_size    = 4M

sort_buffer_size        = 512K

aria-pagecache-buffer-size = 256M
key-cache-segments      = 8

thread_cache_size       = 128
thread_concurrency      = 8
thread_stack            = 192K

tmp_table_size          = 2G
max_heap_table_size     = 2G
wait_timeout            = 14400

mysqltuner:

[--] Status: +ARCHIVE +Aria +BLACKHOLE +CSV +FEDERATED +InnoDB +MRG_MYISAM +SPHINX 
[--] Data in InnoDB tables: 8M (Tables: 10)
[--] Data in MyISAM tables: 872M (Tables: 146)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[!!] Total fragmented tables: 11

-------- Performance Metrics -------------------------------------------------
[--] Up for: 1d 20h 47m 59s (40M q [248.063 qps], 2M conn, TX: 87B, RX: 3B)
[--] Reads / Writes: 97% / 3%
[--] Total buffers: 2.9G global + 1.0G per thread (200 max threads)
[!!] Maximum possible memory usage: 204.3G (651% of installed RAM)
[OK] Slow queries: 1% (529K/40M)
[OK] Highest usage of available connections: 11% (23/200)
[OK] Key buffer size / total MyISAM indexes: 128.0M/92.7M
[OK] Key buffer hit rate: 100.0% (61B cached / 44K reads)
[OK] Query cache efficiency: 45.3% (28M cached / 62M selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (111 temp sorts / 1M sorts)
[!!] Temporary tables created on disk: 48% (1M on disk / 2M total)
[OK] Thread cache hit rate: 99% (23 created / 2M connections)
[OK] Table cache hit rate: 68% (370 open / 541 opened)
[OK] Open file limit used: 2% (517/20K)
[!!] Table locks acquired immediately: 93%
[OK] InnoDB buffer pool / data size: 256.0M/8.4M
[OK] InnoDB log waits: 0

欢迎任何帮助。

非常感谢提前

1 个答案:

答案 0 :(得分:3)

我在从MySQL迁移到MariaDB时遇到了确切的问题,我们的查询缓存命中率降低到45%。

我花了几个小时来调试这个问题,但事实证明查询缓存没有任何问题。问题是MySQL,Percona和MariaDB如何报告查询总量。 com_select状态变量包括MariaDB的Qcache_hits,而Percona和MySQL排除这些命中。

这是https://mariadb.atlassian.net/browse/MDEV-7216

上的错误报告

当执行缓存命中率计算时,MySQLTuner会计算两次查询总数,从而产生一半的值(45%而不是90%)。

你可能已经用另一种方式解决了这个问题,但是当这个问题出现在谷歌我在这里回答它以便其他人也可以找到。