MySQL gtids (Global transaction identifiers)

Source: Internet
Author: User
Tags uuid

1. How to define and generate Gtids

Uniqueness: In all master and slave libraries are unique, consisting of two tuples

?
GTID = source_id:transaction_id

SOURCE_ID mark the main library

1.1 Server_uuid

How to get Server_uuid

A, determine if the data_dir/auto.cnf file exists, if there is a return

b, does not exist, automatically generate a new UUID, and save to the DATA_DIR/AUTO.CNF

The auto.cnf file format is as follows:

?
[auto]server_uuid=8a94f357-aab4-11df-86ab-c80aa9429562

The auto.cnf file is automatically generated and does not attempt to modify the file.

This auto.cnf file is read-only if the server_uuid of the main library changes to a change of master to.

Http://dev.mysql.com/doc/refman/5.6/en/replication-options.html#sysvar_server_uuid

1.2 GTID Sets

?
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)

1.3 Gtid Generation Process

(1) Transaction execution completed and submitted in the main library

Use the UUID of the main library and the minimum number of transaction sequences, and record Gtid to the binlog of the main library

(2) When the Binlog data is received from the library and stored in the relay log, the Gtid is read from the library SQL thread and assigned to the variable Gitd_next

(3) Check the Gtid from the library and verify that it has not been executed. If this gtid has not been used, write Gtid from the library and replay the transaction.

Slave need to make sure two points:

A, Gtid not been used in previous transactions

B. The associated transaction has not been committed

(4) Because Gtid_next is not empty, slave does not attempt to generate a new gtid, but instead saves the Gtid in the variable Gtid_next

?
mysql> show global variables like ‘%gti%‘; +--------------------------+------------------------------------------------------------------------------------+ | Variable_name            | Value                                                                              | +--------------------------+------------------------------------------------------------------------------------+ | enforce_gtid_consistency | ON| | gtid_executed            | 5f02986b-c5de-11e3-8d21-001e4f1ef3b7:1-8, b9d59578-df02-11e3-b112-001e4f1f39cf:1-2 | | gtid_mode                | ON| | gtid_owned               |                                                                                    | | gtid_purged              | 5f02986b-c5de-11e3-8d21-001e4f1ef3b7:1-8, b9d59578-df02-11e3-b112-001e4f1f39cf:1-2 | +--------------------------+------------------------------------------------------------------------------------+

2, how to set up Gtids-based synchronization

3. Some suggestions for using Gtids

4, the use of gtids restrictions

5. Reference documents

Http://dev.mysql.com/doc/refman/5.6/en/replication-gtids.html

Http://qing.blog.sina.com.cn/1757661907/68c3cad333002qhe.html

Http://qing.blog.sina.com.cn/1757661907/68c3cad333002qsk.html

Http://qing.blog.sina.com.cn/1757661907/68c3cad333002s5l.html

http://dev.mysql.com/worklog/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.