MySQL基于GTID的复制(实战阿里云RDS复制)

    Read

之前写过基于位置点的数据库主从复制(https://note.t4x.org/database/configuration-mysql-master-slave/),下面这个是关于GTID的复制方式:
MySQL安装:

MASTER配置:


SLAVE配置:
SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

验证:

SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

配置文件:

SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

说明:SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

一、GTID的概述:SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

1、全局事物标识:global transaction identifieds。
2、GTID事物是全局唯一性的,且一个事务对应一个GTID。
3、一个GTID在一个服务器上只执行一次,避免重复执行导致数据混乱或者主从不一致。
4、GTID用来代替classic的复制方法,不在使用binlog+pos开启复制。而是使用master_auto_postion=1的方式自动匹配GTID断点进行复制。
5、MySQL-5.6.5开始支持的,MySQL-5.6.10后开始完善。
6、在传统的slave端,binlog是不用开启的,但是在GTID中,slave端的binlog是必须开启的,目的是记录执行过的GTID(强制)。SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

二、GTID的组成部分:SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

前面是server_uuid:后面是一个序列号
例如:server_uuid:sequence number
7800a22c-95ae-11e4-983d-080027de205a:10
UUID:每个mysql实例的唯一ID,由于会传递到slave,所以也可以理解为源ID。
Sequence number:在每台MySQL服务器上都是从1开始自增长的序列,一个数值对应一个事务。SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

三、GTID比传统复制的优势:SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

1、更简单的实现failover,不用以前那样在需要找log_file和log_Pos。
2、更简单的搭建主从复制。
3、比传统复制更加安全。
4、GTID是连续没有空洞的,因此主从库出现数据冲突时,可以用添加空事物的方式进行跳过。SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

四、GTID的工作原理:
1、master更新数据时,会在事务前产生GTID,一同记录到binlog日志中。
2、slave端的i/o 线程将变更的binlog,写入到本地的relay log中。
3、sql线程从relay log中获取GTID,然后对比slave端的binlog是否有记录。
4、如果有记录,说明该GTID的事务已经执行,slave会忽略。
5、如果没有记录,slave就会从relay log中执行该GTID的事务,并记录到binlog。
6、在解析过程中会判断是否有主键,如果没有就用二级索引,如果没有就用全部扫描。 SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

阿里云RDS实战复制:


数据库配置GTID复制
SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/

错误整理:
1:错误1


2:错误2

3:错误3

帮助文档:http://rpmfind.net/linux/rpm2html/search.php?query=libev.so.4&submit=Search+...
参考文档:
1:http://www.cnblogs.com/abobo/p/4242417.html
2:https://help.aliyun.com/knowledge_detail/41817.html
3:http://blog.csdn.net/dongsong1117/article/details/51800072
4:http://blog.csdn.net/thundermeng/article/details/50401150
5:http://www.cnblogs.com/cenalulu/p/4309009.htmlSourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/ SourceByrd's Weblog-https://note.t4x.org/database/mysql-global-transaction-identifieds/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
Byrd
  • by Published on November 22, 2016
  • 原文链接:https://note.t4x.org/database/mysql-global-transaction-identifieds/
匿名

Comment

Anonymous

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: