当前位置:Gxlcms > 数据库问题 > 【缓存池】转-Mysql参数innodb_buffer_pool_size

【缓存池】转-Mysql参数innodb_buffer_pool_size

时间:2021-07-01 10:21:17 帮助过:21人阅读

mysqld --innodb_buffer_pool_size=8G --innodb_buffer_pool_instances=16 mysql> SELECT @@innodb_buffer_pool_size/1024/1024/1024; +------------------------------------------+ | @@innodb_buffer_pool_size/1024/1024/1024 | +------------------------------------------+ | 8.000000000000 | +------------------------------------------+ shell> mysqld --innodb_buffer_pool_size=9G --innodb_buffer_pool_instances=16 mysql> SELECT @@innodb_buffer_pool_size/1024/1024/1024; +------------------------------------------+ | @@innodb_buffer_pool_size/1024/1024/1024 | +------------------------------------------+ | 10.000000000000 | +------------------------------------------+ ————————————————

【 innodb_buffer_pool_chunk_size 】
innodb_buffer_pool_chunk_size 默认 128MB (更改不需重启),增加单位为 1MB 。 
innodb_buffer_pool_chunk_size 的最大值估算如下:
MAX(innodb_buffer_pool_chunk_size) = innodb_buffer_pool_size / innodb_buffer_pool_instances

 

综合以上三个参数:

buffer pool 估算公式:(N 为正整数; buffer pool 应为总内存的 3/4 至 4/5)
innodb_buffer_pool_size = N * (innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances)

当 N=1时, 使三个参数设置刚好满足以下公式:
innodb_buffer_pool_size = innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances

若此时再设置 innodb_buffer_pool_chunk_size 少 1MB , 那么 buffer pool 大小几乎翻倍, 因为 chunk_size * instances < buffer_pool_size, 此时有 N=2, buffer_pool_size 为(chunk_size*instances) 的倍数大小

innodb_buffer_pool_size = 2 * (innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances)

#所以较优设置:假设系统内存 = 128 GB, buffer pool 大小预计100GB(128GB*80%)
innodb_buffer_pool_instances = 8 #默认值,或者逻辑CPU数量
innodb_buffer_pool_chunk_size = 128MB #默认值
innodb_buffer_pool_size = 100 GB # N*8*128MG = N GB ,N 刚好为正整数。设 N=100使得 buffer pool 为总内存的 3/4 至 4/5。

 

【 innodb_page_size 】

innodb_page_size 默认 16kb, 数据存储页, 应与操作系统块大小一致(同 innodb_log_write_ahead_size)。 对于 SSD 更小的页可能更好。innodb_page_size 为32k and 64k 时, 行长度最大为 16000 bytes, 且不支持 ROW_FORMAT=COMPRESSED。

一个 innodb_buffer_pool_chunk_size 中包含的页数量取决于 innodb_page_size。

默认地: chunk可存储的页数量= innodb_buffer_pool_chunk_size / innodb_page_size = 128*1024/16 = 8192

mysql> SELECT @@innodb_buffer_pool_size;
mysql> SELECT @@innodb_buffer_pool_instances;
mysql> SELECT @@innodb_buffer_pool_chunk_size;

 

查看:

【缓存池】转-Mysql参数innodb_buffer_pool_size

标签:线程   最大   com   sele   weight   内存   bsp   一个   ssd   

人气教程排行