在线调整innodb_buffer_pool_size不用重启mysql进程
MySQL5.7以前,调整innodb_buffer_pool_size需要重启mysql进程才可以生效。
建议业务低峰时间执行
1 当前大小128M
root@localhost:mysql3306.sock [(none)]>show variables like '%innodb_buffer_pool_size%';
+-------------------------+-----------+
| Variable_name | Value |
+-------------------------+-----------+
| innodb_buffer_pool_size | 134217728 |
+-------------------------+-----------+
row in set (0.03 sec)
root@localhost:mysql3306.sock [(none)]>select 134217728/1024/1024;
+---------------------+
| 134217728/1024/1024 |
+---------------------+
| 128.00000000 |
+---------------------+
row in set (0.00 sec)
2 动态调整为256M
root@localhost:mysql3306.sock [(none)]>set global innodb_buffer_pool_size = 256*1024*1024;
Query OK, 0 rows affected (0.18 sec)
root@localhost:mysql3306.sock [(none)]>show variables like '%innodb_buffer_pool_size%';
+-------------------------+-----------+
| Variable_name | Value |
+-------------------------+-----------+
| innodb_buffer_pool_size | 268435456 |
+-------------------------+-----------+
row in set (0.02 sec)
root@localhost:mysql3306.sock [(none)]>select 268435456/1024/1024;
+---------------------+
| 268435456/1024/1024 |
+---------------------+
| 256.00000000 |
+---------------------+
row in set (0.00 sec)
root@localhost:mysql3306.sock [(none)]>select version();
+------------+
| version() |
+------------+
| 5.7.18-log |
+------------+
row in set (0.03 sec)
调整时,内部会把数据页移动到一个新的位置,单位是块。如果想提升移动速度,则需要调整
innodb_buffer_pool_chunk_size的参数大小,默认是128M
innodb_buffer_pool_size/innodb_buffer_pool_instances = innodb_buffer_pool_chunk_size的参数大小,默认是128M