1.首先讓我們來統計一下InnoDB表的實際占用大小。執行如下查詢:這會給出一個參考,讓你知道如果你想緩存整個數據集應該為InnoDB緩沖池設置多少內存合適。
不過大多數情況你不需要那樣做,你只需要緩存你經常使用的數據集。
設置好之后,我們來看看如何檢查InnoDB緩沖池大小是否設置足夠
mysql> SELECT engine,
-> count(*) as TABLES,
-> concat(round(sum(table_rows)/1000000,2),'M') rows,
-> concat(round(sum(data_length)/(1024*1024*1024),2),'G') DATA,
-> concat(round(sum(index_length)/(1024*1024*1024),2),'G') idx,
-> concat(round(sum(data_length+index_length)/(1024*1024*1024),2),'G') total_size,
-> round(sum(index_length)/sum(data_length),2) idxfrac
-> FROM information_schema.TABLES
-> WHERE table_schema not in ('mysql', 'performance_schema', 'information_schema')
-> GROUP BY engine
-> ORDER BY sum(data_length+index_length) DESC LIMIT 10;
+--------+--------+---------+--------+--------+------------+---------+
| engine | TABLES | rows | DATA | idx | total_size | idxfrac |
+--------+--------+---------+--------+--------+------------+---------+
| InnoDB | 203 | 984.03M | 45.30G | 33.10G | 78.40G | 0.73 |
| NULL | 112 | NULL | NULL | NULL | NULL | NULL |
+--------+--------+---------+--------+--------+------------+---------+
2.檢查InnoDB緩沖池大小是否設置足夠
[root@scada_master ~]# mysqladmin ext -ri1 | grep Innodb_buffer_pool_reads
| Innodb_buffer_pool_reads | 2384992 |
| Innodb_buffer_pool_reads | 0 |
| Innodb_buffer_pool_reads | 0 |
| Innodb_buffer_pool_reads | 0 |
| Innodb_buffer_pool_reads | 0 |
| Innodb_buffer_pool_reads | 0 |
| Innodb_buffer_pool_reads | 0 |
你所看到的是從硬盤讀取數據到緩沖池的次數(每秒)。
參考連接:
https://blog.csdn.net/cookily_liangzai/article/details/117249494