說GTID-Auto-Positioning

GTID-based的復(fù)制,在初始化階段,Slave節(jié)點(diǎn)會(huì)把已接收到的和提交的GTID集合信息,發(fā)送給Master節(jié)點(diǎn)。該GTID集合等價(jià)于后面兩個(gè)GTID集合的并集,@@GLOBAL.gtid_executed + performance_schema.replication_connection_status.RECEIVED_TRANSACTION_SET。

創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、外貿(mào)網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的東港網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

Master節(jié)點(diǎn)通過對(duì)比Slave節(jié)點(diǎn)發(fā)送過來的GTID集合信息,然后把所有記錄在現(xiàn)存二進(jìn)制日志文件中的,沒有在Slave節(jié)點(diǎn)上執(zhí)行過的GTID集合,發(fā)送給Slave節(jié)點(diǎn)。

那么,Master節(jié)點(diǎn)是如何對(duì)比Slave節(jié)點(diǎn)發(fā)送過來的GTID集合信息的呢?

Master節(jié)點(diǎn)會(huì)按照自己有的UUID為準(zhǔn),將GTID集合分類,分別計(jì)算同類GTID集合的差集。此環(huán)節(jié),若Master節(jié)點(diǎn)發(fā)現(xiàn)Slave節(jié)點(diǎn)發(fā)送過來的GTID集合中UUID的種類,比自身上UUID的種類多,Master節(jié)點(diǎn)會(huì)忽略該情況,復(fù)制邏輯還會(huì)繼續(xù)進(jìn)行。

實(shí)際例子如下,此情況復(fù)制是正常的。

Master節(jié)點(diǎn)上GTID集合信息:

[root@MySQL.sock][db1]> show master status\G

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

? ? ? ? ? ? ?File: bin.000002

? ? ? ? ?Position: 796

? ? ?Binlog_Do_DB:?

?Binlog_Ignore_DB:?

Executed_Gtid_Set: 0c34233d-b2e1-11e9-85cf-080027f22add:1-2,

4fdc13e1-b59e-11e9-b5e0-080027f22add:1-2

1 row in set (0.01 sec)

Slave節(jié)點(diǎn)上GTID集合信息:

[root@mysql.sock][lg]> show master status\G

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

? ? ? ? ? ? ?File: bin.000004

? ? ? ? ?Position: 832

? ? ?Binlog_Do_DB:?

?Binlog_Ignore_DB:?

Executed_Gtid_Set: 32a0c858-b59f-11e9-b069-0800270c3d91:1-2,

447e96e1-b59f-11e9-95fe-0800270c3d91:1-2,

b8282f18-b59e-11e9-83b0-0800270c3d91:1-5

1 row in set (0.00 sec)

建立復(fù)制關(guān)系后,Slave節(jié)點(diǎn)上集合信息:

[root@mysql.sock][lg]> show master status \G

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

? ? ? ? ? ? ?File: bin.000004

? ? ? ? ?Position: 1763

? ? ?Binlog_Do_DB:?

?Binlog_Ignore_DB:?

Executed_Gtid_Set: 0c34233d-b2e1-11e9-85cf-080027f22add:1-2,

32a0c858-b59f-11e9-b069-0800270c3d91:1-2,

447e96e1-b59f-11e9-95fe-0800270c3d91:1-2,

4fdc13e1-b59e-11e9-b5e0-080027f22add:1-2,

b8282f18-b59e-11e9-83b0-0800270c3d91:1-5

1 row in set (0.00 sec)

又若Master節(jié)點(diǎn)發(fā)現(xiàn)Slave節(jié)點(diǎn)上相同UUID對(duì)應(yīng)的GTID,比自身上的GTID多,這時(shí)Master節(jié)點(diǎn)會(huì)發(fā)送ER_SLAVE_HAS_MORE_GTIDS_THAN_MASTER報(bào)錯(cuò)給Slave節(jié)點(diǎn)。

實(shí)際例子報(bào)錯(cuò)如下:

Last_IO_Errno: 1236(MySQL error code 1236 (ER_MASTER_FATAL_ERROR_READING_BINLOG): Got fatal error %d from master when reading data from binary log: '%-.320s')

Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Slave has more GTIDs than the master has, using the master's SERVER_UUID. This may indicate that the end of the binary log was truncated or that the last binary log file was lost, e.g., after a power or disk failure when sync_binlog != 1. The master may or may not have rolled back transactions that were already replica'

Last_SQL_Errno: 0

或Master節(jié)點(diǎn)發(fā)現(xiàn)計(jì)算出來相同UUID的GTID集合的差集中,有GTID已被刪除了,這時(shí)Master節(jié)點(diǎn)會(huì)發(fā)送ER_MASTER_HAS_PURGED_REQUIRED_GTIDS報(bào)錯(cuò)給Slave節(jié)點(diǎn)。

實(shí)際例子報(bào)錯(cuò)如下:

Last_IO_Errno: 1236

Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.'

Last_SQL_Errno: 0

經(jīng)過上面的邏輯后,Master節(jié)點(diǎn)最終得以將Slave節(jié)點(diǎn)需要的GTID集合(差集)發(fā)送過來,復(fù)制就這樣開始了。

標(biāo)題名稱:說GTID-Auto-Positioning
本文鏈接:http://bm7419.com/article14/pcipde.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站品牌網(wǎng)站設(shè)計(jì)、小程序開發(fā)用戶體驗(yàn)、App開發(fā)、網(wǎng)站內(nèi)鏈

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計(jì)