MySQL缓冲池使用+高负载

HTF*_*HTF 7 mysql innodb

我们有一个非常强大的服务器:HP ProLiant DL360p Gen8, 2xIntel Xeon E5-2630 2.30GHz, 128GB of RAM.

整个数据集应该适合内存:

mysql> SELECT FLOOR(SUM(DATA_LENGTH+INDEX_LENGTH)/POWER(1024,2)) 'Total Size (MB)', FLOOR(SUM(DATA_LENGTH)/POWER(1024,2)) 'Data Size (Data_length in MB)', FLOOR(SUM(INDEX_LENGTH)/POWER(1024,2)) 'Index Size (Index_length in MB)' FROM information_schema.TABLES;
+-----------------+-------------------------------+---------------------------------+
| Total Size (MB) | Data Size (Data_length in MB) | Index Size (Index_length in MB) |
+-----------------+-------------------------------+---------------------------------+
|          110559 |                         62464 |                           48095 |
+-----------------+-------------------------------+---------------------------------+
1 row in set (1.64 sec)
Run Code Online (Sandbox Code Playgroud)

-innodb_buffer_pool_size是 100GB

mysql> SELECT (@@innodb_buffer_pool_size / POWER(1024,3)) AS "innodb_buffer_pool_size in GB";
+-------------------------------+
| innodb_buffer_pool_size in GB |
+-------------------------------+
|                           100 |
+-------------------------------+
1 row in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)

—— SHOW ENGINE INNODB STATUS

mysql> SHOW ENGINE INNODB STATUS\G
*************************** 1. row ***************************
  Type: InnoDB
  Name: 
Status: 
=====================================
140806 21:38:13 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 8 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 19534 1_second, 19526 sleeps, 1952 10_second, 49 background, 49 flush
srv_master_thread log flush and writes: 19578
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 5952877, signal count 43935931
Mutex spin waits 179717547, rounds 1194842254, OS waits 3382912
RW-shared spins 13682200, rounds 38631505, OS waits 343596
RW-excl spins 1136695, rounds 48060134, OS waits 128072
Spin rounds per wait: 6.65 mutex, 2.82 RW-shared, 42.28 RW-excl
------------
TRANSACTIONS
------------
Trx id counter 743DC46C7
Purge done for trx's n:o < 743DC1705 undo n:o < 0
History list length 3212
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 21989, OS thread handle 0x7fb88c96b700, query id 27211624 localhost root
SHOW ENGINE INNODB STATUS
---TRANSACTION 743C76A59, not started
MySQL thread id 20318, OS thread handle 0x7fb88c9ac700, query id 27198440 10.0.0.1 db
---TRANSACTION 743C14BB5, not started
MySQL thread id 20317, OS thread handle 0x7fb88c9ed700, query id 27198476 10.0.0.1 db
---TRANSACTION 743C14414, not started
MySQL thread id 20316, OS thread handle 0x7fb88ca2e700, query id 27198479 10.0.0.1 db
---TRANSACTION 743DB1BDC, not started
MySQL thread id 20312, OS thread handle 0x7fb88caf1700, query id 27198410 10.0.0.1 db
---TRANSACTION 743C143FC, not started
MySQL thread id 20313, OS thread handle 0x7fb88cab0700, query id 27198483 10.0.0.1 db
---TRANSACTION 743C76A2F, not started
MySQL thread id 20315, OS thread handle 0x7fb88cbf5700, query id 27198444 10.0.0.1 db
---TRANSACTION 743C14428, not started
MySQL thread id 20309, OS thread handle 0x7fb88cbb4700, query id 27198478 10.0.0.1 db
---TRANSACTION 743C777FA, not started
MySQL thread id 20308, OS thread handle 0x7fb88cc36700, query id 27198421 10.0.0.1 db
---TRANSACTION 743C14DCA, not started
MySQL thread id 20304, OS thread handle 0x7fb88cc77700, query id 27198472 10.0.0.1 db
---TRANSACTION 743C18D70, not started
MySQL thread id 20303, OS thread handle 0x7fb88ccb8700, query id 27198457 10.0.0.1 db
---TRANSACTION 743C14440, not started
MySQL thread id 20301, OS thread handle 0x7fb88ccf9700, query id 27198477 10.0.0.1 db
---TRANSACTION 743C76A4D, not started
MySQL thread id 20293, OS thread handle 0x7fd2c87d0700, query id 27198442 10.0.0.1 db
---TRANSACTION 743C776A8, not started
MySQL thread id 20292, OS thread handle 0x7fd2c8b9f700, query id 27198428 10.0.0.1 db
---TRANSACTION 743C183D5, not started
MySQL thread id 20288, OS thread handle 0x7fb88d393700, query id 27198462 10.0.0.1 db
---TRANSACTION 743DB1FB6, not started
MySQL thread id 20290, OS thread handle 0x7fd2c91b7700, query id 27198405 10.0.0.1 db
---TRANSACTION 743C143FE, not started
MySQL thread id 20289, OS thread handle 0x7fd2c8a19700, query id 27198481 10.0.0.1 db
---TRANSACTION 743DC46C4, not started
MySQL thread id 20286, OS thread handle 0x7fd2c9d65700, query id 27211621 10.0.0.1 db
---TRANSACTION 743C769A5, not started
MySQL thread id 577, OS thread handle 0x7fb88ce7f700, query id 27198447 10.0.0.1 db
---TRANSACTION 743DC40FD, not started
MySQL thread id 581, OS thread handle 0x7fb88cd7b700, query id 27209984 10.0.0.1 db
---TRANSACTION 743C18DF0, not started
MySQL thread id 580, OS thread handle 0x7fb88cdbc700, query id 27198456 10.0.0.1 db
---TRANSACTION 743D5CFAA, not started
MySQL thread id 579, OS thread handle 0x7fb88cdfd700, query id 27198417 10.0.0.1 db
---TRANSACTION 743C76ABE, not started
MySQL thread id 578, OS thread handle 0x7fb88ce3e700, query id 27198438 10.0.0.1 db
---TRANSACTION 743D9FC89, not started
MySQL thread id 576, OS thread handle 0x7fb88cec0700, query id 27198414 10.0.0.1 db
---TRANSACTION 743DBE66D, not started
MySQL thread id 572, OS thread handle 0x7fb88cfc4700, query id 27198404 10.0.0.1 db
---TRANSACTION 743C7778A, not started
MySQL thread id 559, OS thread handle 0x7fb88d311700, query id 27198424 10.0.0.1 db
---TRANSACTION 743DC46C5, not started
MySQL thread id 568, OS thread handle 0x7fb88d0c8700, query id 27211622 10.0.0.1 db
---TRANSACTION 743C77702, not started
MySQL thread id 566, OS thread handle 0x7fb88d14a700, query id 27198426 10.0.0.1 db
---TRANSACTION 743C17F2A, not started
MySQL thread id 570, OS thread handle 0x7fb88d046700, query id 27198470 10.0.0.1 db
---TRANSACTION 743D9FB7D, not started
MySQL thread id 554, OS thread handle 0x7fd2c80f5700, query id 27198415 10.0.0.1 db
---TRANSACTION 743DBF213, not started
MySQL thread id 555, OS thread handle 0x7fd2c80b4700, query id 27198401 10.0.0.1 db
---TRANSACTION 743C1888B, not started
MySQL thread id 563, OS thread handle 0x7fb88d20d700, query id 27198461 10.0.0.1 db
---TRANSACTION 743C1819B, not started
MySQL thread id 562, OS thread handle 0x7fb88d24e700, query id 27198465 10.0.0.1 db
---TRANSACTION 743C76A34, not started
MySQL thread id 564, OS thread handle 0x7fb88d1cc700, query id 27198441 10.0.0.1 db
---TRANSACTION 743DB1BD1, not started
MySQL thread id 560, OS thread handle 0x7fb88d2d0700, query id 27198411 10.0.0.1 db
---TRANSACTION 743C17FBE, not started
MySQL thread id 552, OS thread handle 0x7fd2c8177700, query id 27198468 10.0.0.1 db
---TRANSACTION 743C768DF, not started
MySQL thread id 558, OS thread handle 0x7fb88d352700, query id 27198452 10.0.0.1 db
---TRANSACTION 743C777A7, not started
MySQL thread id 553, OS thread handle 0x7fd2c8136700, query id 27198420 10.0.0.1 db
---TRANSACTION 743C1D66A, not started
MySQL thread id 556, OS thread handle 0x7fd2c8073700, query id 27198455 10.0.0.1 db
---TRANSACTION 743C769CE, not started
MySQL thread id 551, OS thread handle 0x7fd2c81b8700, query id 27198445 10.0.0.1 db
---TRANSACTION 743C77669, not started
MySQL thread id 549, OS thread handle 0x7fd2c823a700, query id 27198431 10.0.0.1 db
---TRANSACTION 743C775D5, not started
MySQL thread id 547, OS thread handle 0x7fd2c82bc700, query id 27198434 10.0.0.1 db
---TRANSACTION 743C187CC, not started
MySQL thread id 548, OS thread handle 0x7fd2c827b700, query id 27198460 10.0.0.1 db
---TRANSACTION 743DC3CA0, not started
MySQL thread id 544, OS thread handle 0x7fd2c837f700, query id 27208595 10.0.0.1 db
---TRANSACTION 743C768E5, not started
MySQL thread id 543, OS thread handle 0x7fd2c83c0700, query id 27198453 10.0.0.1 db
---TRANSACTION 743C777F0, not started
MySQL thread id 542, OS thread handle 0x7fd2c8401700, query id 27198422 10.0.0.1 db
---TRANSACTION 743C77F14, not started
MySQL thread id 541, OS thread handle 0x7fd2c8442700, query id 27198418 10.0.0.1 db
---TRANSACTION 743D9FB6D, not started
MySQL thread id 540, OS thread handle 0x7fd2c8483700, query id 27198416 10.0.0.1 db
---TRANSACTION 743DBE430, not started
MySQL thread id 538, OS thread handle 0x7fd2c8505700, query id 27180780 10.0.0.1 db
---TRANSACTION 743C7690A, not started
MySQL thread id 537, OS thread handle 0x7fd2c8546700, query id 27198451 10.0.0.1 db
---TRANSACTION 743C17FE3, not started
MySQL thread id 539, OS thread handle 0x7fd2c84c4700, query id 27198466 10.0.0.1 db
---TRANSACTION 743DC46A7, not started
MySQL thread id 536, OS thread handle 0x7fd2c8587700, query id 27211571 10.0.0.1 db
---TRANSACTION 743C1889F, not started
MySQL thread id 534, OS thread handle 0x7fd2c8609700, query id 27198459 10.0.0.1 db
---TRANSACTION 743C7777D, not started
MySQL thread id 535, OS thread handle 0x7fd2c85c8700, query id 27198425 10.0.0.1 db
---TRANSACTION 743D9FD29, not started
MySQL thread id 533, OS thread handle 0x7fd2c864a700, query id 27198413 10.0.0.1 db
---TRANSACTION 743C76AB5, not started
MySQL thread id 532, OS thread handle 0x7fd2c868b700, query id 27198437 10.0.0.1 db
---TRANSACTION 743C77F05, not started
MySQL thread id 531, OS thread handle 0x7fd2c86cc700, query id 27198419 10.0.0.1 db
---TRANSACTION 743DC42E3, not started
MySQL thread id 529, OS thread handle 0x7fd2c870d700, query id 27210503 10.0.0.1 db
---TRANSACTION 743C1D66B, not started
MySQL thread id 528, OS thread handle 0x7fd2c874e700, query id 27198454 10.0.0.1 db
---TRANSACTION 743C77589, not started
MySQL thread id 527, OS thread handle 0x7fd2c878f700, query id 27198435 10.0.0.1 db
---TRANSACTION 743C17FDB, not started
MySQL thread id 524, OS thread handle 0x7fd2c8852700, query id 27198467 10.0.0.1 db
---TRANSACTION 743DBF21E, not started
MySQL thread id 522, OS thread handle 0x7fd2c88d4700, query id 27198402 10.0.0.1 db
---TRANSACTION 743C14D9F, not started
MySQL thread id 519, OS thread handle 0x7fd2c8997700, query id 27198474 10.0.0.1 db
---TRANSACTION 743C76AA5, not started
MySQL thread id 520, OS thread handle 0x7fd2c8956700, query id 27198439 10.0.0.1 db
---TRANSACTION 743DC264E, not started
MySQL thread id 518, OS thread handle 0x7fd2c89d8700, query id 27201143 10.0.0.1 db
---TRANSACTION 743DC3C70, not started
MySQL thread id 515, OS thread handle 0x7fd2c8a9b700, query id 27208546 10.0.0.1 db
---TRANSACTION 743C14417, not started
MySQL thread id 516, OS thread handle 0x7fd2c8a5a700, query id 27198480 10.0.0.1 db
---TRANSACTION 743C76910, not started
MySQL thread id 514, OS thread handle 0x7fd2c8adc700, query id 27198450 10.0.0.1 db
---TRANSACTION 743C7699F, not started
MySQL thread id 513, OS thread handle 0x7fd2c8b1d700, query id 27198448 10.0.0.1 db
---TRANSACTION 743C18202, not started
MySQL thread id 508, OS thread handle 0x7fd2c8be0700, query id 27198464 10.0.0.1 db
---TRANSACTION 743DC4646, not started
MySQL thread id 505, OS thread handle 0x7fd2c8ca3700, query id 27211470 10.0.0.1 db
---TRANSACTION 743C776A4, not started
MySQL thread id 504, OS thread handle 0x7fd2c8ce4700, query id 27198429 10.0.0.1 db
---TRANSACTION 743C77572, not started
MySQL thread id 503, OS thread handle 0x7fd2c8d25700, query id 27198436 10.0.0.1 db
---TRANSACTION 743DB1CC4, not started
MySQL thread id 499, OS thread handle 0x7fd2c8e29700, query id 27198408 10.0.0.1 db
---TRANSACTION 743C1830C, not started
MySQL thread id 502, OS thread handle 0x7fd2c8d66700, query id 27198463 10.0.0.1 db
---TRANSACTION 743DC3DEB, not started
MySQL thread id 496, OS thread handle 0x7fd2c8eec700, query id 27208974 10.0.0.1 db
---TRANSACTION 743DB1FB0, not started
MySQL thread id 497, OS thread handle 0x7fd2c8eab700, query id 27198406 10.0.0.1 db
---TRANSACTION 743DC42E8, not started
MySQL thread id 494, OS thread handle 0x7fd2c8f6e700, query id 27211463 10.0.0.1 db
---TRANSACTION 743C76A28, not started
MySQL thread id 495, OS thread handle 0x7fd2c8f2d700, query id 27198443 10.0.0.1 db
---TRANSACTION 743C776BF, not started
MySQL thread id 490, OS thread handle 0x7fd2c9072700, query id 27198427 10.0.0.1 db
---TRANSACTION 743C77686, not started
MySQL thread id 491, OS thread handle 0x7fd2c9031700, query id 27198430 10.0.0.1 db
---TRANSACTION 743C14BE8, not started
MySQL thread id 486, OS thread handle 0x7fd2c9176700, query id 27198475 10.0.0.1 db
---TRANSACTION 743C17E7C, not started
MySQL thread id 493, OS thread handle 0x7fd2c8faf700, query id 27198471 10.0.0.1 db
---TRANSACTION 743DB1CAA, not started
MySQL thread id 487, OS thread handle 0x7fd2c9135700, query id 27198409 10.0.0.1 db
---TRANSACTION 743D9FE04, not started
MySQL thread id 488, OS thread handle 0x7fd2c90f4700, query id 27198412 10.0.0.1 db
---TRANSACTION 743C7778F, not started
MySQL thread id 483, OS thread handle 0x7fd2c9239700, query id 27198423 10.0.0.1 db
---TRANSACTION 743DBE72A, not started
MySQL thread id 484, OS thread handle 0x7fd2c91f8700, query id 27198403 10.0.0.1 db
---TRANSACTION 743C7692E, not started
MySQL thread id 481, OS thread handle 0x7fd2c92bb700, query id 27198449 10.0.0.1 db
---TRANSACTION 743C77309, not started
MySQL thread id 480, OS thread handle 0x7fd2c92fc700, query id 27198432 10.0.0.1 db
---TRANSACTION 743DB1DFE, not started
MySQL thread id 456, OS thread handle 0x7fd2c9810700, query id 27198407 10.0.0.1 db
---TRANSACTION 743DBE403, not started
MySQL thread id 465, OS thread handle 0x7fd2c95c7700, query id 27180731 10.0.0.1 db
---TRANSACTION 743C188FA, not started
MySQL thread id 463, OS thread handle 0x7fd2c9649700, query id 27198458 10.0.0.1 db
---TRANSACTION 743DBE40D, not started
MySQL thread id 460, OS thread handle 0x7fd2c970c700, query id 27180741 10.0.0.1 db
---TRANSACTION 743C7763C, not started
MySQL thread id 457, OS thread handle 0x7fd2c97cf700, query id 27198433 10.0.0.1 db
---TRANSACTION 743C769C4, not started
MySQL thread id 462, OS thread handle 0x7fd2c968a700, query id 27198446 10.0.0.1 db
---TRANSACTION 743C17FB6, not started
MySQL thread id 461, OS thread handle 0x7fd2c96cb700, query id 27198469 10.0.0.1 db
---TRANSACTION 743C14DB8, not started
MySQL thread id 464, OS thread handle 0x7fd2c9608700, query id 27198473 10.0.0.1 db
---TRANSACTION 743DC467E, not started
MySQL thread id 459, OS thread handle 0x7fd2c974d700, query id 27211529 10.0.0.1 db
---TRANSACTION 743DC46C6, ACTIVE 0 sec 
mysql tables in use 1, locked 0
MySQL thread id 511, OS thread handle 0x7fd2c8b5e700, query id 27211623 10.0.0.1 db Sending data
Select * from `product` where '%224406167' like product_code limit 1
Trx read view will not see trx with id >= 743DC46C7, sees < 743DC1729
---TRANSACTION 743DC4697, ACTIVE 0 sec
mysql tables in use 1, locked 0
MySQL thread id 20314, OS thread handle 0x7fb88ca6f700, query id 27211555 10.0.0.1 db Sending data
Select COUNT(DISTINCT `product`.order_ref) from `product` where `product`.id = 374878 and `product`.feedback != '' and `product`.feedback_date > '1901-02-01' and `product`.link = 0
Trx read view will not see trx with id >= 743DC4698, sees < 743DC1729
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
 ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
1671739 OS file reads, 719434 OS file writes, 49848 OS fsyncs
16.12 reads/s, 16384 avg bytes/read, 29.50 writes/s, 3.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 5169, seg size 5171, 18899 merges
merged operations:
 insert 41086, delete mark 12708, delete 1980
discarded operations:
 insert 0, delete mark 0, delete 0
Hash table size 212497717, node heap has 89398 buffer(s)
774716.54 hash searches/s, 25607.67 non-hash searches/s
---
LOG
---
Log sequence number 994047525425
Log flushed up to   994047525415
Last checkpoint at  994039754907
0 pending log writes, 0 pending chkp writes
505579 log i/o's done, 1.12 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 109890764800; in additional pool allocated 0
Dictionary memory allocated 284681021
Buffer pool size   6553599
Free buffers       4797931
Database pages     1665370
Old database pages 614775
Modified db pages  4015
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 1032, not young 0
0.00 youngs/s, 0.00 non-youngs/s
Pages read 1659227, created 6143, written 206544
16.12 reads/s, 0.00 creates/s, 27.75 writes/s
Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 1665370, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
4 read views open inside InnoDB
Main thread process no. 14318, id 140430662539008, state: sleeping
Number of rows inserted 666847, updated 159401, deleted 125715, read 32445750369
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 2684759.28 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================

1 row in set (0.06 sec)
Run Code Online (Sandbox Code Playgroud)

- New Relic 的缓冲池利用率

新的遗物统计

- 读/写比率

mysql> SELECT SUM(IF(variable_name = 'Com_select', variable_value, 0)) AS `Total reads`, SUM(IF(variable_name IN ('Com_delete', 'Com_insert', 'Com_update', 'Com_replace'), variable_value, 0)) AS `Total writes`  FROM information_schema.GLOBAL_STATUS;
+-------------+--------------+
| Total reads | Total writes |
+-------------+--------------+
|    10869877 |       406010 |
+-------------+--------------+
1 row in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)

- MySQL 版本

mysql> SELECT @@version, @@version_comment;
+------------+------------------------------+
| @@version  | @@version_comment            |
+------------+------------------------------+
| 5.5.31-log | MySQL Community Server (GPL) |
+------------+------------------------------+
1 row in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)

- 内存使用情况

# free -m
             total       used       free     shared    buffers     cached
Mem:        129022      43658      85363          0        352       2696
-/+ buffers/cache:      40609      88413
Swap:         2047         24       2023
Run Code Online (Sandbox Code Playgroud)

- NUMA 政策

# numactl --hardware
available: 2 nodes (0-1)
node 0 cpus: 0 1 2 3 4 5 12 13 14 15 16 17
node 0 size: 65501 MB
node 0 free: 30522 MB
node 1 cpus: 6 7 8 9 10 11 18 19 20 21 22 23
node 1 size: 65535 MB
node 1 free: 55032 MB
node distances:
node   0   1 
  0:  10  20 
  1:  20  10
Run Code Online (Sandbox Code Playgroud)

题:

为什么只使用了缓冲池中的一小部分可用内存?是不是因为缓冲池没有预热并且不是所有数据都填充到缓存中?

问题:

两天前,我们在该服务器上遇到了高负载(~100),缓冲池的使用量立即下降 - 您可以在上图中看到这一点(没有服务器或 MySQL 重启)。SELECT队列中有很多语句,据我所知,它没有绑定到磁盘 I/O(datadir安装在两个镜像 SSD 驱动器上)。CPU 使用率很高。该应用程序正在 Tomcat 上运行。

有什么建议我可以进一步解决这个问题吗?

更新:2014 年 8 月 8 日星期五 09:39:08 BST

- 请求的变量

innodb_old_blocks_pct = 37
innodb_old_blocks_time = 0
innodb_flush_method = O_DIRECT
innodb_buffer_pool_ins

Rol*_*DBA 4

您的读/写比率为 26:1(基于 10869877 除以 406010),即 96% 的读取。

\n

我想你可能正在遭受我所说的“提前阅读徒劳”的痛苦。听起来好像是我编的。嗯,你是对的。我做到了。我是什么意思?根据MySQL文档关于状态变量Innodb_buffer_pool_read_ahead_evicted

\n
\n

由预读后台线程读入 InnoDB 缓冲池的页数,这些页数随后在未被查询访问的情况下被逐出。

\n
\n

为了进行预读,大量的 SELECT 可能会读取太多的数据页。这些页面可能永远不会被访问,并且只是从缓冲池中逐出。这就像不打结就吹大一个巨大的气球。空气最终会出来。即使对于完整的缓冲池也是如此。不允许页面处于休眠状态。必须将它们删除,以便为 InnoDB 架构的其他移动部分腾出空间

\n

InnoDB架构

\n

例如,看一下图表。您是否知道多达 25% 的缓冲池被用作非唯一索引更改的暂存器?它形成了一个将这些更改迁移到系统表空间的管道。如果对具有许多非唯一索引的表进行大量插入和更新,这可能会使 InnoDB 崩溃。您可以删除这些索引,执行 INSERT,然后再次创建索引来避免这种情况。我之前写过这个

\n\n

回头看看你的图表,你的杂项并不存在。这说明什么?

\n

根据MySQL关于Innodb_buffer_pool_pages_misc的文档

\n
\n

由于已分配管理开销(例如行锁或自适应哈希索引)而处于繁忙状态的页数。该值也可以计算为 Innodb_buffer_pool_pages_total \xe2\x80\x93 Innodb_buffer_pool_pages_free \xe2\x80\x93 Innodb_buffer_pool_pages_data。

\n
\n

显然,您没有频繁搜索相同的数据。你的 SELECT 必须在做

\n\n

建议

\n
    \n
  • 您可能需要调整查询,这样它们就不会请求太多数据。
  • \n
  • 您还应该避免在工作日中间执行 mysqldump,这往往会将每个数据页及其祖母加载到缓冲池中,结果只是将这些页面悄悄地逐出。如果您必须运行 mysqldumps,请设置一个 MySQL Slave 并从该 Slave 进行转储。
  • \n
  • 您可以尝试禁用更改缓冲(将innodb_change_buffering设置为 0)。
  • \n
\n

更新 2014-08-11 16:45 美国东部时间

\n

请回头看看评论区。德里克·唐尼 (Derek Downey) 为您提供了我 3 年前发布的帖子的链接。根据我帖子中的 2012 年更新,您需要设置innodb_buffer_pool_instances = 2。这将有助于抑制 mysqld 的交换行为。

\n

从你的SHOW ENGINE INNODB STATUS\\G,您的读写线程太少

\n
--------\nFILE I/O\n--------\nI/O thread 0 state: waiting for completed aio requests (insert buffer thread)\nI/O thread 1 state: waiting for completed aio requests (log thread)\nI/O thread 2 state: waiting for completed aio requests (read thread)\nI/O thread 3 state: waiting for completed aio requests (read thread)\nI/O thread 4 state: waiting for completed aio requests (read thread)\nI/O thread 5 state: waiting for completed aio requests (read thread)\nI/O thread 6 state: waiting for completed aio requests (write thread)\nI/O thread 7 state: waiting for completed aio requests (write thread)\nI/O thread 8 state: waiting for completed aio requests (write thread)\nI/O thread 9 state: waiting for completed aio requests (write thread)\n
Run Code Online (Sandbox Code Playgroud)\n

您只有4 个读取4 个写入I/O 线程。增加你的话题

\n
innodb_read_io_threads = 16\ninnodb_write_io_threads = 16\n
Run Code Online (Sandbox Code Playgroud)\n

如果你有超过 2 个核心,我会使用 32 或 64。你现在可以尝试 16。

\n

InnoDB 总是与查询缓存相矛盾。请禁用它。

\n
query_cache_size = 0\n
Run Code Online (Sandbox Code Playgroud)\n

您需要更大的日志缓冲区以获得更好的 InnoDB 写入性能

\n
innodb_log_buffer_size = 256M\n
Run Code Online (Sandbox Code Playgroud)\n

这些都是所有的改变

\n
[mysqld]\ninnodb_buffer_pool_instances = 2\ninnodb_log_buffer_size = 256M\ninnodb_read_io_threads = 16\ninnodb_write_io_threads = 16\nquery_cache_size = 0\n
Run Code Online (Sandbox Code Playgroud)\n


归档时间:

查看次数:

9461 次

最近记录:

11 年,1 月 前