Mysql5.7Gtid内部学习(七)总结binlog_gtid_simple_recovery参数带来的影响

简书地址:
http://www.jianshu.com/p/c9888d6447c8

想了想还是专门开了一节来总结这个问题
5.7.6以下中默认

雷州ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!

  • simplified_binlog_gtid_recovery=flase

5.7.6以上中默认

  • binlog_gtid_simple_recovery=true

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

一、Gtid关闭


  • simple_recovery=flase

5.7.6以下:这种方式一定得到正确的Gtid集合

  • 重启MySQL需要扫描全部的binlog来获得正确的Gtid集合
  • purge binlog或者超过参数expire_logs_days参数设置不触发全binlog扫描,由上层函数控制。因为不支持在线的Gtid更改。

5.7.6以上:这种方式一定得到正确的Gtid集合

  • 重启Mysql扫描全部的binlog。
  • purge binlog或者超过参数expire_logs_days参数设置触发全binlog扫描。

  • simple_recovery=true

5.7.6以下:这种情况可能得不到正确的Gtid集合

  • 重启Mysql不扫描全部的binlog,只扫描第一个和最后一个binlog。
  • purge binlog或者超过参数expire_logs_days参数设置不触发全binlog扫描,由上层函数控制。

5.7.6以上:由于有每个binlog都有Previous gtid Event的支持能够得到正确的Gtid集合。

  • 重启Mysql不扫描全部的binlog,只扫描第一个和最后一个binlog。
  • purge binlog或者超过参数expire_logs_days参数设置不触发全binlog扫描,只扫描第一个和最后一个binlog。

二、Gtid打开


  • simple_recovery=flase

5.7.6以下:这种方式一定得到正确的Gtid集合。

  • 重启Mysql不扫描全部的binlog,如果是中途打开GTID,重启任然需要扫描多个binlog因为需要找到Previous gtid Event。
  • purge binlog或者超过参数expire_logs_days参数设置不触发全binlog扫描,如果是中途打开GTID重启,任然需要扫描多个binlog因为需要找到Previous gtid Event。

5.7.6以上:这种方式一定得到正确的Gtid集合

  • 重启Mysql不扫秒全部的binlog,如果是中途打开GTID重启任然需要扫描多个binlog因为需要找到Gtid event。
  • purge binlog或者超过参数expire_logs_days参数设置不触发全binlog扫描,如果是中途打开GTID重启任然需要扫描多个binlog因为需要找到Gtid event。

  • simple_recovery=true

5.7.6以下:这种情况可能得不到正确的Gtid集合

  • 重启Mysql不扫描全部的binlog,只扫描第一个和最后一个binlog。
  • purge binlog或者超过参数expire_logs_days参数设置不扫描全部binlog,只扫描第一个和最后一个binlog。

5.7.6以上:由于有每个binlog都有Previous gtid Event的支持能够得到正确的Gtid集合。

  • 重启Mysql不扫描全部的binlog,只扫描第一个和最后一个binlog。
  • purge binlog或者超过参数expire_logs_days参数设置不触发全binlog扫描,只扫描第一个和最后一个binlog。

三、本节总结

  • 5.7.6以下保持默认设置simplified_binlog_gtid_recovery=flase,但是这会导致过多的binlog扫描,况且5.6没有mysql.gtid_executed的支持,从库必须开启log_slave_updates,这会带来性能影响。所以还是少用Gtid。
  • 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/simplified_binlog_gtid_recovery是如何影响binlog文件的扫描的的
  • 5.7.6以下应该如何设置
  • 5.7.6以上应该如何设置

作者微信:


Mysql 5.7 Gtid内部学习(七) 总结binlog_gtid_simple_recovery参数带来的影响

本文标题:Mysql5.7Gtid内部学习(七)总结binlog_gtid_simple_recovery参数带来的影响
URL标题:https://www.cdcxhl.com/article4/ppjhoe.html

成都网站建设公司_创新互联,为您提供外贸建站网站导航响应式网站搜索引擎优化做网站网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

搜索引擎优化