<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        Erranttransactions:MajorhurdleforGTID-basedfailoverin_MySQL

        來源:懂視網(wǎng) 責編:小采 時間:2020-11-09 19:18:24
        文檔

        Erranttransactions:MajorhurdleforGTID-basedfailoverin_MySQL

        Erranttransactions:MajorhurdleforGTID-basedfailoverin_MySQL:I have previously written about thenew replication protocolthat comes with GTIDs in MySQL 5.6. Because of this new replication protocol, you can inadvertently create errant transactions that may turn any failover to a nightmare. Lets see t
        推薦度:
        導讀Erranttransactions:MajorhurdleforGTID-basedfailoverin_MySQL:I have previously written about thenew replication protocolthat comes with GTIDs in MySQL 5.6. Because of this new replication protocol, you can inadvertently create errant transactions that may turn any failover to a nightmare. Lets see t

        I have previously written about thenew replication protocolthat comes with GTIDs in MySQL 5.6. Because of this new replication protocol, you can inadvertently create errant transactions that may turn any failover to a nightmare. Let’s see the problems and the potential solutions.

        In short

      1. Errant transactions may cause all kinds of data corruption/replication errors when failing over.
      2. Detection of errant transactions can be done with theGTID_SUBSET()andGTID_SUBTRACT()functions.
      3. If you find an errant transaction on one server, commit an empty transaction with the GTID of the errant one on all other servers.
      4. If you are using a tool to perform the failover for you, make sure it can detect errant transactions. At the time of writing, onlymysqlfailoverandmysqlrpladminfrom MySQL Utilities can do that.
      5. What are errant transactions?

        Simply stated, they are transactions executed directly on a slave. Thus they only exist on a specific slave. This could result from a mistake (the application wrote to a slave instead of writing to the master) or this could be by design (you need additional tables for reports).

        Why can they create problems that did not exist before GTIDs?

        Errant transactions have been existing forever. However because of the new replication protocol for GTID-based replication, they can have a significant impact on all servers if a slave holding an errant transaction is promoted as the new master.

        Compare what happens in this master-slave setup, first with position-based replication and then with GTID-based replication. A is the master, B is the slave:

        # POSITION-BASED REPLICATION# Creating an errant transaction on Bmysql> create database mydb;# Make B the master, and A the slave# What are the databases on A now?mysql> show databases like 'mydb';Empty set (0.01 sec)

        # POSITION-BASED REPLICATION

        # Creating an errant transaction on B

        mysql>createdatabasemydb;

        # Make B the master, and A the slave

        # What are the databases on A now?

        mysql>showdatabaseslike'mydb';

        Emptyset(0.01sec)

        As expected, the mydb database is not created on A.

        # GTID-BASED REPLICATION# Creating an errant transaction on Bmysql> create database mydb;# Make B the master, and A the slave# What are the databases on A now?mysql> show databases like 'mydb';+-----------------+| Database (mydb) |+-----------------+| mydb|+-----------------+

        # GTID-BASED REPLICATION

        # Creating an errant transaction on B

        mysql>createdatabasemydb;

        # Make B the master, and A the slave

        # What are the databases on A now?

        mysql>showdatabaseslike'mydb';

        +-----------------+

        |Database(mydb)|

        +-----------------+

        |mydb |

        +-----------------+

        mydb has been recreated on A because of the new replication protocol: when A connects to B, they exchange their own set of executed GTIDs and the master (B) sends any missing transaction. Here it is thecreate databasestatement.

        As you can see, the main issue with errant transactions is that when failing over you may execute transactions ‘coming from nowhere’ that can silently corrupt your data or break replication.

        How to detect them?

        If the master is running, it is quite easy with theGTID_SUBSET()function. As all writes should go to the master, the GTIDs executed on any slave should always be a subset of the GTIDs executed on the master. For instance:

        # Mastermysql> show master status/G*************************** 1. row *************************** File: mysql-bin.000017 Position: 376 Binlog_Do_DB: Binlog_Ignore_DB:Executed_Gtid_Set: 8e349184-bc14-11e3-8d4c-0800272864ba:1-30,8e3648e4-bc14-11e3-8d4c-0800272864ba:1-7# Slavemysql> show slave status/G[...]Executed_Gtid_Set: 8e349184-bc14-11e3-8d4c-0800272864ba:1-29,8e3648e4-bc14-11e3-8d4c-0800272864ba:1-9# Now, let's compare the 2 setsmysql> > select gtid_subset('8e349184-bc14-11e3-8d4c-0800272864ba:1-29,8e3648e4-bc14-11e3-8d4c-0800272864ba:1-9','8e349184-bc14-11e3-8d4c-0800272864ba:1-30,8e3648e4-bc14-11e3-8d4c-0800272864ba:1-7') as slave_is_subset;+-----------------+| slave_is_subset |+-----------------+| 0 |+-----------------+
        # Master

        mysql>showmasterstatus/G

        ***************************1.row***************************

        File:mysql-bin.000017

        Position:376

        Binlog_Do_DB:

        Binlog_Ignore_DB:

        Executed_Gtid_Set:8e349184-bc14-11e3-8d4c-0800272864ba:1-30,

        8e3648e4-bc14-11e3-8d4c-0800272864ba:1-7

        # Slave

        mysql>showslavestatus/G

        [...]

        Executed_Gtid_Set:8e349184-bc14-11e3-8d4c-0800272864ba:1-29,

        8e3648e4-bc14-11e3-8d4c-0800272864ba:1-9

        # Now, let's compare the 2 sets

        mysql>>selectgtid_subset('8e349184-bc14-11e3-8d4c-0800272864ba:1-29,

        8e3648e4-bc14-11e3-8d4c-0800272864ba:1-9','8e349184-bc14-11e3-8d4c-0800272864ba:1-30,

        8e3648e4-bc14-11e3-8d4c-0800272864ba:1-7')asslave_is_subset;

        +-----------------+

        |slave_is_subset|

        +-----------------+

        | 0|

        +-----------------+

        Hum, it looks like the slave has executed more transactions than the master, this indicates that the slave has executed at least 1 errant transaction. Could we know the GTID of these transactions? Sure, let’s useGTID_SUBTRACT():

        select gtid_subtract('8e349184-bc14-11e3-8d4c-0800272864ba:1-29,8e3648e4-bc14-11e3-8d4c-0800272864ba:1-9','8e349184-bc14-11e3-8d4c-0800272864ba:1-30,8e3648e4-bc14-11e3-8d4c-0800272864ba:1-7') as errant_transactions;+------------------------------------------+| errant_transactions|+------------------------------------------+| 8e3648e4-bc14-11e3-8d4c-0800272864ba:8-9 |+------------------------------------------+

        selectgtid_subtract('8e349184-bc14-11e3-8d4c-0800272864ba:1-29,

        8e3648e4-bc14-11e3-8d4c-0800272864ba:1-9','8e349184-bc14-11e3-8d4c-0800272864ba:1-30,

        8e3648e4-bc14-11e3-8d4c-0800272864ba:1-7')aserrant_transactions;

        +------------------------------------------+

        |errant_transactions |

        +------------------------------------------+

        |8e3648e4-bc14-11e3-8d4c-0800272864ba:8-9|

        +------------------------------------------+

        This means that the slave has 2 errant transactions.

        Now, how can we check errant transactions if the master is not running (like master has crashed, and we want to fail over to one of the slaves)? In this case, we will have to follow these steps:

      6. Check all slaves to see if they have executed transactions that are not found on any other slave: this is the list of potential errant transactions.
      7. Discard all transactions originating from the master: now you have the list of errant transactions of each slave
      8. Some of you may wonder how you can know which transactions come from the master as it is not available:SHOW SLAVE STATUSgives you the master’s UUID which is used in the GTIDs of all transactions coming from the master.

        How to get rid of them?

        This is pretty easy, but it can be tedious if you have many slaves: just inject an empty transaction on all the other servers with the GTID of the errant transaction.

        For instance, if you have 3 servers, A (the master), B (slave with an errant transaction: XXX:3), and C (slave with 2 errant transactions: YYY:18-19), you will have to inject the following empty transactions in pseudo-code:

        # A- Inject empty trx(XXX:3)- Inject empty trx(YYY:18)- Inject empty trx(YYY:19)# B- Inject empty trx(YYY:18)- Inject empty trx(YYY:19)# C- Inject empty trx(XXX:3)
        # A

        -Injectemptytrx(XXX:3)

        -Injectemptytrx(YYY:18)

        -Injectemptytrx(YYY:19)

        # B

        -Injectemptytrx(YYY:18)

        -Injectemptytrx(YYY:19)

        # C

        -Injectemptytrx(XXX:3)

        Conclusion

        If you want to switch to GTID-based replication, make sure to check errant transactions before any planned or unplanned replication topology change. And be specifically careful if you use a tool that reconfigures replication for you: at the time of writing, onlymysqlrpladminandmysqlfailoverfrom MySQL Utilities can warn you if you are trying to perform an unsafe topology change.

        聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        Erranttransactions:MajorhurdleforGTID-basedfailoverin_MySQL

        Erranttransactions:MajorhurdleforGTID-basedfailoverin_MySQL:I have previously written about thenew replication protocolthat comes with GTIDs in MySQL 5.6. Because of this new replication protocol, you can inadvertently create errant transactions that may turn any failover to a nightmare. Lets see t
        推薦度:
        標簽: in for mysql
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 婷婷久久久亚洲欧洲日产国码AV| 国产片免费在线观看| 亚洲综合国产一区二区三区| 色婷婷精品免费视频| 全部免费国产潢色一级| 国产精品亚洲二区在线| 免费很黄很色裸乳在线观看| 免费人成视频在线观看免费| 亚洲国产精品成人久久蜜臀 | 夜夜亚洲天天久久| 中文字幕免费在线观看| 亚洲videos| 成人黄动漫画免费网站视频| 亚洲AV无码一区二区三区电影| 国产免费av片在线无码免费看| 青娱乐在线免费观看视频| 国产成人亚洲影院在线观看| 中文成人久久久久影院免费观看| 亚洲阿v天堂在线| 日本免费一区二区在线观看| 亚洲色偷偷色噜噜狠狠99网| 在线观看免费污视频| 香蕉97碰碰视频免费| 亚洲色婷婷六月亚洲婷婷6月| 一区二区免费视频| 日韩亚洲产在线观看| 又黄又大又爽免费视频| 久久久久久噜噜精品免费直播| 亚洲人成电影在线天堂| 无码人妻一区二区三区免费 | 本道天堂成在人线av无码免费| 久久久久久a亚洲欧洲aⅴ| 波多野结衣在线免费视频| 亚洲AV永久无码天堂影院| 中文字幕亚洲一区| 日本高清在线免费| 性生大片视频免费观看一级| 久久久亚洲欧洲日产国码二区| 美女黄网站人色视频免费国产| 国产午夜精品久久久久免费视 | 亚洲午夜理论片在线观看|