当前位置:网站首页>Introduction to the gtid mode of MySQL master-slave replication
Introduction to the gtid mode of MySQL master-slave replication
2022-07-05 00:51:00 【Greatsql community】
GTID summary
MySQL5.6 A new replication method is added to the original master-slave replication , That is, based on GTID The way of reproduction , It consists of UUID And transaction ID Two parts , It has the following characteristics .
- GTID Transactions are globally unique , And one transaction corresponds to one GTID value .
- One GTID The value is in the same MySQL The instance will be executed only once .
GTID Compared with traditional replication
- The master-slave construction is simpler , There is no need to manually specify position Location .
- There is a unified identity in the replication cluster , distinguish 、 Management is more convenient .
- Failover is easier , You don't need to find it like traditional replication log_file and log_Pos The location of .
- Usually GTID It's continuous, there's no void , Better ensure data consistency , Zero loss .
- be relative to ROW Copying model , More secure data , Easier switching .
- More secure than traditional replication , One GTID In a MySQL The instance will be executed only once , Avoid data confusion or master-slave inconsistency caused by repeated execution .
GTID What are their limitations
- In a replication group , Must be turned on GTID.
- MySQL5.6 Turn on GTID Need to restart .
- I won't support it sql_slave_skip_counte operation , Traditional replication can use this command to skip transactions .
- Not allowed in one SQL Update the tables of a transaction engine and a non transaction engine at the same time , Such as InnoDB and MyISAM.
- about create temporary table and drop temporary table Statement not supported .
- I won't support it create table … select Sentence copying .
GTID A brief introduction to the working principle
- master When nodes update data , It's going to happen before the transaction GTID Information , Record together binlog In the log .
- slave Node io Thread will binlog Write to local relay log in .
- then SQL The thread from relay log Read from GTID, Set up gtid_next The value of the gtid, Then contrast slave Terminal binlog Is there a record .
- If there are records , Explain the GTID The transaction for is already running ,slave Will ignore .
- If there is no record ,slave Will carry out the GTID The corresponding business , And record the binlog in .
How to open GTID Copy
- In addition to the traditional replication needs to be turned on binlog Other than relevant parameters ,GTID The following parameter settings need to be opened additionally for synchronization , Note that the master and slave nodes need to be started synchronously .
see GTID Related parameters
- Brief description of parameters
| Parameter name | Meaning Introduction |
|---|---|
| binlog_gtid_simple_recovery | This parameter controls when MySQL Automatically find when the service restarts or starts GTIDs Value . |
| enforce_gtid_consistency | This parameter is a mandatory requirement that only transaction safe transactions are allowed to be copied , Please see the specific limitations of the above steps . |
| gtid_executed | Already executed GTID Information . |
| gtid_executed_compression_period | Enable GTID when , The server will be on a regular basis mysql.gtid_executed Perform compression on the table . By setting gtid_executed_compression_period System variables , You can control the number of transactions allowed before compressing the table , So as to control the compression ratio . Set to 0 when , No compression . |
| gtid_mode | Open or not GTID Pattern |
| gtid_next | Indicates the next to be executed GTID Information |
| gtid_owned | This parameter contains global and session, Global means that all servers have GTIDs,session Level indicates current client All you have GTIDs. |
| gtid_purged | already purge Dropped GTIDs,purged Dropped GTIDs Will include to gtid_executed in . |
| session_track_gtids | This parameter controls what is used for capture GTIDs And in OK PACKE Return tracker . |
GTID Different from the traditional mode when creating replication statements
GTID Synchronization is used when establishing replication , The traditional copy is artificially specified binlog Of pos The site is changed to MASTER_AUTO_POSITION=1 Automatic access to binlog Of pos site .
GTID Simple analysis of synchronization status
In addition to the traditional view binlog and pos Beyond value ,GTID Mode can more intuitively view the execution of a transaction .
- GTID Description of relevant key parameters
| Parameter name | Meaning Introduction |
|---|---|
| Retrieved_Gtid_Set | Slave The node has received Master Node GTIDs |
| Executed_Gtid_Set | Slave The node has executed GTIDs |
| Auto_Position | Automatic access to position Location , Is shown as 1 |
summary
- Limited by space, I have written so much for the time being , Next week, we will continue to publish content related to master-slave replication , Welcome to catch up , In addition, it is limited by personal ability and experience , The content is inevitably wrong , If there is any error, please point out the correction in the comment area .
Enjoy GreatSQL
Article recommendation :
GreatSQL Quarterly Report (2021.12.26)
https://mp.weixin.qq.com/s/FZ_zSBHflwloHtZ38YJxbA
Technology sharing |sysbench Usage analysis of pressure measuring tools
https://mp.weixin.qq.com/s/m16LwXWy9bFt0i99HjbRsw
Fault analysis | linux disk io High utilization , Analyze the correct posture
https://mp.weixin.qq.com/s/7cu_36jfsjZp1EkVexkojw
Technology sharing | Flashback at MySQL Implementation and improvement in
https://mp.weixin.qq.com/s/6jepwEE0DnYUpjMYO17VtQ
Wan Da #20, How to filter data in index push down
https://mp.weixin.qq.com/s/pt6mr3Ge1ya2aa6WlrpIvQ
About GreatSQL
GreatSQL It is maintained by Wanli database MySQL Branch , Focus on Improvement MGR Reliability and performance , Support InnoDB Parallel query feature , It is suitable for financial grade applications MySQL Branch version .
Gitee:
https://gitee.com/GreatSQL/GreatSQL
GitHub:
https://github.com/GreatSQL/GreatSQL
Bilibili:
https://space.bilibili.com/1363850082/video
WeChat &QQ Group :
Searchable add GreatSQL Community assistant wechat friend , Send verification information “ Add group ” Join in GreatSQL/MGR Exchange wechat group
QQ Group :533341697
Wechat assistant :wanlidbc
边栏推荐
- Multilingual Wikipedia website source code development part II
- 2022.07.03 (lc_6111_counts the number of ways to place houses)
- Mongodb series learning notes tutorial summary
- Pycharm professional download and installation tutorial
- “薪资倒挂”、“毕业生平替” 这些现象说明测试行业已经...
- [paper reading] Tun det: a novel network for meridian ultra sound nodule detection
- MongoDB系列之学习笔记教程汇总
- Check if this is null - checking if this is null
- dotnet-exec 0.6.0 released
- Is it safe to open an account in the College of Finance and economics? How to open an account?
猜你喜欢

Pycharm professional download and installation tutorial

leetcode494,474

Inventory of more than 17 typical security incidents in January 2022

Applet live + e-commerce, if you want to be a new retail e-commerce, use it!

ORB(Oriented FAST and Rotated BRIEF)

The performance of major mainstream programming languages is PK, and the results are unexpected

SAP UI5 应用开发教程之一百零六 - 如何提高 SAP UI5 应用路由 url 的可读性试读版

Parameter passing mechanism of member methods

各大主流编程语言性能PK,结果出乎意料

Huawei employs millions of data governance experts! The 100 billion market behind it deserves attention
随机推荐
Safety learning week4
"Upside down salary", "equal replacement of graduates" these phenomena show that the testing industry has
P4408 [noi2003] truant children (tree diameter)
P3304 [SDOI2013]直径(树的直径)
Huawei employs millions of data governance experts! The 100 billion market behind it deserves attention
“薪資倒掛”、“畢業生平替” 這些現象說明測試行業已經...
Query for Boolean field as "not true" (e.g. either false or non-existent)
Specification for fs4061a boost 8.4v charging IC chip and fs4061b boost 12.6V charging IC chip datasheet
2022.07.03 (LC 6108 decryption message)
Learn C language from scratch day 024
Sorting selection sorting
【微处理器】基于FPGA的微处理器VHDL开发
Leetcode70 (Advanced), 322
Insert sort of sort
Summary of the function and usage of const, volatile and restrict
Which financial products with stable income are good
NPM install error forced installation
What you learned in the eleventh week
揭露测试外包公司,关于外包,你或许听到过这样的声音
Implementation steps of master detail detail layout mode of SAP ui5 application