官方文档并没有直接告诉如何调整 innodb_log_buffer_size 大小,

根据对mysql 的状态信息了解知道  innodb_log_buffer_size 跟 Innodb_os_log_written 和 Com_commit 状态有关系。

 

  1. Innodb_os_log_written: innodb 引擎redo log  多少个字节被写入
  2. Com_commit : 在autocommit = 0 时候 有多少个innodb 事务提交 ,如果autocommit = 1,innodb 事务不包括在Com_commit 中
  3. 以上参考: https://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html#statvar_Com_xxx
  4. 在业务压力测试或者高峰时间段进行以下操作:
set global autocommit = 0;

SHOW GLOBAL STATUS LIKE 'Innodb_os_log_written';

 经过一段长时间.............

SHOW GLOBAL STATUS LIKE 'Com_commit';

通过以下公式计算平均每个事务要缓冲的平均数据量多少个bytes,前提你需要保留多长时间的redo log buffer

Innodb_os_log_written
/ Com_commit

在业务高峰运行期间如果 Innodb_log_waits 值为0或接近0, innodb_log_buffer_size 可能太大,可以减少。

set @old_value := 0;
set @new_value := 0;
select VARIABLE_VALUE into @old_value from information_schema.GLOBAL_STATUS where VARIABLE_NAME = 'Innodb_log_waits';
select SLEEP(时间);
select VARIABLE_VALUE into @new_value from information_schema.GLOBAL_STATUS where VARIABLE_NAME = 'Innodb_log_waits';
select @old_value;
select @new_value;

 

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

posted on 2019-03-05 22:08  黑洞中的奇点  阅读(1860)  评论(1编辑  收藏  举报