[Mysql] mysql-innodb buffer pool size调整


本文总阅读量

1、查看当前数据库innodb_buffer_pool参数

1
show global variables like 'innodb_buffer_pool_size';

##2、查看page_size大小

1
show variables like 'innodb_page_size';

官方文档参数详解

1
2
3
Innodb_page_size
InnoDB page size (default 16KB). Many values are counted in pages; the page size enables them to be
easily converted to bytes

3、查看当前内存innodb页的总数量和包含数据的页的数量

1
2
show global status like 'Innodb_buffer_pool_pages_data';
show global status like 'Innodb_buffer_pool_pages_total';

官方文档参数详解:

1
2
3
4
5
6
Innodb_buffer_pool_pages_data
The number of pages in the InnoDB buffer pool containing data. The number includes both dirty and
clean pages.

Innodb_buffer_pool_pages_total
The total size of the InnoDB buffer pool, in pages.

4、调优参考计算方法:

1
2
3
val = Innodb_buffer_pool_pages_data / Innodb_buffer_pool_pages_total * 100%
val > 95% 则考虑增大 innodb_buffer_pool_size, 建议使用物理内存的75%
val < 95% 则考虑减小 innodb_buffer_pool_size, 建议设置为:Innodb_buffer_pool_pages_data * Innodb_page_size * 1.05 / (1024*1024*1024)

5、设置innodb_buffer_pool_siz大小

设置命令:

1
set global innodb_buffer_pool_size = 17179869184;

缓冲池字节大小,单位kb,如果不设置,默认为128M
5.7版本以后可以动态修改参数,但是也要修改配置文件参数,防止重启之后,参数又变成配置文件内的参数,5.7以下的版本为静态参数,需要修改配置文件,并重新启动mysql

1
2
3
4
cat /etc/my.cnf
---------
innodb_buffer_pool_size = 17179869184 #设置16G
---------

6、配置参数也可使用M、G等参数,内容如下:

1
2
3
4
5
/etc/my.cnf:
-------------------
innodb_buffer_pool_size = 16G #设置16G
innodb_buffer_pool_size = 500M #设置500M
--------------------------
目录
  1. 1. 1、查看当前数据库innodb_buffer_pool参数
  2. 2. 3、查看当前内存innodb页的总数量和包含数据的页的数量
  3. 3. 4、调优参考计算方法:
  4. 4. 5、设置innodb_buffer_pool_siz大小
  5. 5. 6、配置参数也可使用M、G等参数,内容如下:

Proudly powered by Hexo and Theme by Lap
本站访客数人次
© 2020 zeven0707's blog