binlog_gtid_simple_recovery参数的影响总结

  • binlog_gtid_simple_recovery参数的影响总结已关闭评论
  • 187 views
  • A+
所属分类:MySQL

摘要: 想了想还是专门开了一节来总结这个问题: 5.7.6以下中默认 simplified_binlog_gtid_recovery=flase 5.7.6以上中默认 binlog_gtid_simple_recovery=true 默认值就是最合理的设置。

binlog_gtid_simple_recovery参数的影响总结

想了想还是专门开了一节来总结这个问题:

5.7.6以下中默认

binlog_gtid_simple_recovery参数的影响总结simplified_binlog_gtid_recovery=flase
5.7.6以上中默认

binlog_gtid_simple_recovery参数的影响总结binlog_gtid_simple_recovery=true
默认值就是最合理的设置。
因为参数名更改了所以下面统称simple_recovery来代替。

一、Gtid关闭

binlog_gtid_simple_recovery参数的影响总结simple_recovery=flase
5.7.6以下:这种方式一定得到正确的Gtid集合

binlog_gtid_simple_recovery参数的影响总结重启MySQL需要扫描全部的BINLOG来获得正确的GTID集合
binlog_gtid_simple_recovery参数的影响总结purge binlog或者超过参数expire_logs_days参数设置不触发全BINLOG扫描,由上层函数控制。因为不支持在线的GTID更改。
5.7.6以上:这种方式一定得到正确的Gtid集合

binlog_gtid_simple_recovery参数的影响总结重启MySQL扫描全部的BINLOG
binlog_gtid_simple_recovery参数的影响总结purge binlog或者超过参数expire_logs_days参数设置触发全BINLOG扫描。
binlog_gtid_simple_recovery参数的影响总结simple_recovery=true
5.7.6以下:这种情况可能得不到正确的GTID集合

binlog_gtid_simple_recovery参数的影响总结重启Mysql不扫描全部的BINLOG,只扫描第一个和最后一个BINLOG
binlog_gtid_simple_recovery参数的影响总结purge binlog或者超过参数expire_logs_days参数设置不触发全BINLOG扫描,由上层函数控制。
5.7.6以上:由于有每个BINLOG都有Previous gtid Event的支持能够得到正确的GTID集合。

binlog_gtid_simple_recovery参数的影响总结重启Mysql不扫描全部的BINLOG,只扫描第一个和最后一个BINLOG
binlog_gtid_simple_recovery参数的影响总结purge binlog或者超过参数expire_logs_days参数设置不触发全BINLOG扫描,只扫描第一个和最后一个BINLOG

二、Gtid打开

binlog_gtid_simple_recovery参数的影响总结simple_recovery=flase
5.7.6以下:这种方式一定得到正确的GTID集合。

binlog_gtid_simple_recovery参数的影响总结重启MySQL不扫描全部的BINLOG,如果是中途打开GTID,重启任然需要扫描多个BINLOG因为需要找到Previous gtid Event
binlog_gtid_simple_recovery参数的影响总结purge binlog或者超过参数expire_logs_days参数设置不触发全BINLOG扫描,如果是中途打开GTID重启,任然需要扫描多个BINLOG因为需要找到Previous gtid Event
5.7.6以上:这种方式一定得到正确的GTID集合

binlog_gtid_simple_recovery参数的影响总结重启Mysql不扫秒全部的BINLOG,如果是中途打开GTID重启任然需要扫描多个BINLOG因为需要找到GTID EVENT
binlog_gtid_simple_recovery参数的影响总结purge binlog或者超过参数expire_logs_days参数设置不触发全BINLOG扫描,如果是中途打开GTID重启任然需要扫描多个BINLOG因为需要找到GTID EVENT
binlog_gtid_simple_recovery参数的影响总结simple_recovery=true
5.7.6以下:这种情况可能得不到正确的GTID集合

binlog_gtid_simple_recovery参数的影响总结重启Mysql不扫描全部的BINLOG,只扫描第一个和最后一个BINLOG
binlog_gtid_simple_recovery参数的影响总结purge binlog或者超过参数expire_logs_days参数设置不扫描全部GTID,只扫描第一个和最后一个BINLOG
5.7.6以上:由于有每个BINLOG都有Previous gtid Event的支持能够得到正确的GTID集合。

binlog_gtid_simple_recovery参数的影响总结重启Mysql不扫描全部的BINLOG,只扫描第一个和最后一个BINLOG
binlog_gtid_simple_recovery参数的影响总结purge binlog或者超过参数expire_logs_days参数设置不触发全BINLOG扫描,只扫描第一个和最后一个BINLOG

三、本节总结

binlog_gtid_simple_recovery参数的影响总结5.7.6以下保持默认设置simplified_binlog_gtid_recovery=flase,但是这会导致过多的BINLOG扫描,况且5.6没有mysql.gtid_executed的支持,从库必须开启log_slave_updates,这会带来性能影响。所以还是少用GTID
binlog_gtid_simple_recovery参数的影响总结5.7.6以上由于对每个BINLOG都有Previous gtid Event的支持binlog_gtid_simple_recovery=true是合理的设置,BINLOG扫描非常的快因为只是第一个和最后一个BINLOG文件而已。
可以看到Gtid也越来越成熟了。这部分的逻辑在函MYSQL_BIN_LOG::init_gtid_sets中前文已经提到过,这里就不看代码了。

此外在5.7的官方文档中对binlog_gtid_simple_recovery=true 有如下警告的描述:

If this option is enabled, gtid_executed and gtid_purged may be
initialized incorrectly in the following situations:
• The newest binary log was generated by MySQL 5.7.5 or older, and
gtid_mode was ON for some binary logs but OFF for the newest binary log.
• A SET GTID_PURGED statement was issued on a MySQL version
prior to 5.7.7, and the binary log that was active at the time of the SET
GTID_PURGED has not yet been purged.
If an incorrect GTID set is computed in either situation, it will remain incorrect
even if the server is later restarted, regardless of the value of this option.

如果将参数设置为true可能在老版本中得不到正确的GTID集合,也是前面讨论的。

学习完本节至少能够学习到:

binlog_gtid_simple_recovery参数的影响总结binlog_gtid_simple_recovery/simplified_binlog_gtid_recovery是如何影响BINLOG文件的扫描的的
binlog_gtid_simple_recovery参数的影响总结5.7.6以下应该如何设置
binlog_gtid_simple_recovery参数的影响总结5.7.6以上应该如何设置

  • 安卓客户端下载
  • 微信扫一扫
  • weinxin
  • 微信公众号
  • 微信公众号扫一扫
  • weinxin
avatar