- GTID transactions are identified by a global transaction identifier (GTID) in the form
UUID:NUMBER
. Every GTID transaction in a log is always preceded by aGtid_log_event
. GTID transactions can be addressed using either the GTID or using the file name and position.- Anonymous transactions do not have a GTID assigned, and MySQL ensures that every anonymous transaction in a log is preceded by an
Anonymous_gtid_log_event
. In previous versions, anonymous transactions were not preceded by any particular event. Anonymous transactions can only be addressed using file name and position.
1,GTID_MODE 的概念
GTID是一个全局事务识别,由UUID:NUMBER组成,日志中的每一个GTID事务都是由Gtid_log_event产生的,GTID事务可以被每一个GTID或者binlog日志的文件名和位置点进行定位。
匿名的事务没有分配GTID号,MySQL确保了日志中每一个匿名的事务是由Anonymous_gtid_log_event产生的。
MySQL5.6之后gtid_mode
and enforce_gtid_consistency这两个变量可以被动态修改。之前只能是mysql启动才能生效。
gtid_mode
的四个参数值
-
OFF :
Both new and replicated transactions must be anonymous. 主库生成的是匿名事务,从库也只能是匿名事务。 -
OFF_PERMISSIVE:
Whengtid_mode=OFF_PERMISSIVE
then new transactions are anonymous while permitting replicated transactions to be either GTID or anonymous transactions
主库生成的是匿名事务,slave可以应用匿名和GTID事务。
-
ON_PERMISSIVE:
When