Innodb_buffer_pool_chunk_size可以自行设定,且增加和减少都要以M为单位,并只能在启动前修改,修改后的值*innodb_buffer_pool_instances不能大于buffer pool的大小,否则修改无效。
[mysqld]
innodb_buffer_pool_chunk_size=134217728
buffer pool的大小可以动态修改,用set语句直接修改,当语句发起时,会一直等到当前所有的事务结束后才执行,而一旦执行则执行过程中的其他事务如果要访问buffer pool就会等待语句执行完毕。
#动态修改
mysql> SET GLOBAL innodb_buffer_pool_size=402653184;
当执行online的调整大小时,可以通过error log或者innodb_buffer_pool_resize_status查看进度
mysql> SHOW STATUS WHERE Variable_name='InnoDB_buffer_pool_resize_status';
+----------------------------------+----------------------------------+
| Variable_name | Value |
+----------------------------------+----------------------------------+
| Innodb_buffer_pool_resize_status | Resizing also other hash tables. |
+----------------------------------+----------------------------------+
当buffer pool的大小是GB级别时,将一个buffer poo分割成几个独立的实例能降低多个线程同时读写缓存页的竞争性而提高并发性。
通过innodb_buffer_pool_instances参数可以调整实例个数。 如果有多个实例,则缓存的数据页会随机放置到任意的实例中,且每个实例都有独立的buffer pool所有的特性。
Innodb_buffer_pool_instances的默认值是1,最大可以调整成64。
mysql> SYSTEM cat /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
character-set-server=utf8
collation-server=utf8_unicode_ci
secure-file-priv=/tmp/
innodb_buffer_pool_instances=5
innodb_buffer_pool_size=1024M
#这里我设置了实例为了 buffer_pool 为1024M
mysql> show variables like '%innodb_buffer_pool%'
-> ;
+-------------------------------------+----------------+
| Variable_name | Value |
+-------------------------------------+----------------+
| innodb_buffer_pool_chunk_size | 134217728 |
| innodb_buffer_pool_dump_at_shutdown | ON |
| innodb_buffer_pool_dump_now | OFF |
| innodb_buffer_pool_dump_pct | 25 |
| innodb_buffer_pool_filename | ib_buffer_pool |
| innodb_buffer_pool_instances | 5 |
| innodb_buffer_pool_load_abort | OFF |
| innodb_buffer_pool_load_at_startup | ON |
| innodb_buffer_pool_load_now | OFF |
| innodb_buffer_pool_size | 1342177280 |
+-------------------------------------+----------------+
实际大小是buffer_pool的1280M 实例为5
可以 show engine innodb status\G; 看看几个buffer 实例 会从1280平均分给buffer pool 实例