GTID的格式和存储

GTID的概念:

A global transaction identifier (GTID) is a unique identifier created and associated with each transaction committed on the server of origin (the source). This identifier is unique not only to the server on which it originated, but is unique across all servers in a given replication topology.

全局事务标识号,分配给每一个在server上提交的事务并且是唯一的。在整个复制拓扑中都是唯一存在的。

GTID的组成

GTID = source_id:transaction_id1

source_id标识原有的server,一般就是source_uuid,

transaction_id是事务提交时决定执行顺序的一个序列号。

 

gtid_executed表

GTIDs are stored in a table named gtid_executed, in the mysql database。

GTID存储在mysql.gtid_executed表中,这个表是在mysql安装或者升级后产生的。

CREATE TABLE gtid_executed (
    source_uuid CHAR(36) NOT NULL,
    interval_start BIGINT(20) NOT NULL,
    interval_end BIGINT(20) NOT NULL,
    PRIMARY KEY (source_uuid, interval_start)
)

Warning

As with other MySQL system tables, do not attempt to create or modify this table yourself.

不要去修改它!

其实除了这个表,还有binlog日志中的GTID_LOG_EVENT记录了GTID的值。

GTIDs are stored in the mysql.gtid_executed table only when gtid_mode is ON or ON_PERMISSIVE. The point at which GTIDs are stored depends on whether binary logging is enabled or disabled:

只有当gtid_mode =on 或者 ON_PERMISSIVE时,GTID才会被写入到gtid_executed 表中。

  • 如果binlog没开启。事务的GTID会被写入到gtid_executed 表中

If binary logging is disabled (log_bin is OFF), or if log_slave_updates is disabled, the server stores the GTID belonging to each transaction together with the transaction in the table.

  • 如果binlog启用。当binlog发生切换或者server 关闭时,原本写入binlog日志中的事务的GTID将被写入到gtid_executed 表中

If binary logging is enabled (log_bin is ON), whenever the binary log is rotated or the server is shut down, the server writes GTIDs for all transactions that were written into the previous binary log into the mysql.gtid_executed table. This situation applies on a replication source server, or a replica where binary logging is enabled.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值