记事本做网站怎么不行啦,在网上帮做图片的网站,英文网站建站,视频推广联盟GTID的概念何为GITDGTID(global transaction identifier)是全局事务标识符#xff0c;在MySQL5.6版本中作为一个超级特性被推出。事务标识不仅对于Master(起源)的服务器来说是惟一的#xff0c;而且在整个复制拓扑架构来说#xff0c;也是全局唯一的。1.GTID的格式GTID sou…GTID的概念何为GITDGTID(global transaction identifier)是全局事务标识符在MySQL5.6版本中作为一个超级特性被推出。事务标识不仅对于Master(起源)的服务器来说是惟一的而且在整个复制拓扑架构来说也是全局唯一的。1.GTID的格式GTID source_id:transaction_idGTID分为两部分source_id和transaction_id。source_id是通过使用MySQL服务的server_uuid来表示 。transaction_id 是在事务提交的时候由系统顺序分配的一个序列号。使用show master status查看当前实例执行过的GTID事务信息。如下:(rootlocalhost) [Ztest] show master status\G;*************************** 1. row ***************************File: mysql-bin.000005Position: 1959Binlog_Do_DB:Binlog_Ignore_DB:Executed_Gtid_Set: 4160e9b3-58d9-11e8-b174-005056af6f24:1-101 row in set (0.00 sec)可以看出本实例的source_id为4160e9b3-58d9-11e8-b174-005056af6f24transaction_id为1-10说明是提交了10个事务。MySQL数据库服务的uuid的查询方式。(rootlocalhost) [(none)] show GLOBAL VARIABLES like server_uuid;-----------------------------------------------------| Variable_name | Value |-----------------------------------------------------| server_uuid | 4160e9b3-58d9-11e8-b174-005056af6f24 |-----------------------------------------------------1 row in set (0.02 sec)2.GTID的集合GTID集合是一组全局事务标识符格式如下:gtid_set:uuid_set [, uuid_set] ...| uuid_set:uuid:interval[:interval]...uuid:hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhhh:[0-9|A-F]interval:n[-n](n 1)3.GTID的管理MySQL库中新增了gtid_exectued表在MySQL 8.0中表结构如下:(rootlocalhost) [(none)] use mysqlDatabase changed(rootlocalhost) [mysql] show create table gtid_executed \G;*************************** 1. row ***************************Table: gtid_executedCreate Table: CREATE TABLE gtid_executed (source_uuid char(36) NOT NULL COMMENT uuid of the source where the transaction was originally executed.,interval_start bigint(20) NOT NULL COMMENT First number of interval.,interval_end bigint(20) NOT NULL COMMENT Last number of interval.,PRIMARY KEY (source_uuid,interval_start)) /*!50100 TABLESPACE mysql */ ENGINEInnoDB DEFAULT CHARSETutf81 row in set (0.00 sec)查看目前已经执行过的事务语句如下:(rootlocalhost) [mysql] select * from gtid_executed;--------------------------------------------------------------------| source_uuid | interval_start | interval_end |--------------------------------------------------------------------| 4160e9b3-58d9-11e8-b174-005056af6f24 | 1 | 26 |--------------------------------------------------------------------1 row in set (0.01 sec)可以分析•当未开启binlog时每个事务会记录到gitd_executed表中。•当开启binlog时事务不会立即写入gitd_executed表中只有当Binlog rotate轮询时亦或者数据库服务关闭时会把事务写入至gtid_executed表中。实验效果如下:1.插入数据前的gtid_executed表的情况:(rootlocalhost) [mysql] select * from gtid_executed;--------------------------------------------------------------------| source_uuid | interval_start | interval_end |--------------------------------------------------------------------| 4160e9b3-58d9-11e8-b174-005056af6f24 | 1 | 26 |--------------------------------------------------------------------1 row in set (0.01 sec)2.插入准备数据:insert into ztest.zstudent(stu_name,sex) values(hrd30,M);insert into ztest.zstudent(stu_name,sex) values(hrd31,M);commit;3.插入数据后的gtid_executed表的情况:(rootlocalhost) [mysql] select * from gtid_executed;--------------------------------------------------------------------| source_uuid | interval_start | interval_end |--------------------------------------------------------------------| 4160e9b3-58d9-11e8-b174-005056af6f24 | 1 | 26 |--------------------------------------------------------------------1 row in set (0.00 sec)如上情况没有任何改变Binlog rotate后查看gtid_executed表的情况(rootlocalhost) [mysql] flush logs;Query OK, 0 rows affected (0.01 sec)(rootlocalhost) [mysql] select * from gtid_executed;--------------------------------------------------------------------| source_uuid | interval_start | interval_end |--------------------------------------------------------------------| 4160e9b3-58d9-11e8-b174-005056af6f24 | 1 | 28 |--------------------------------------------------------------------1 row in set (0.00 sec)可以看到上述提交的两个事务在binlog刷新之后写入到了gitd_executed表中。知识点备注:RESET MASTER会清空gitd_executed表。