溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

MySQL半同步SLAVE是什么

發(fā)布時間:2021-12-04 09:43:16 來源:億速云 閱讀:132 作者:iii 欄目:MySQL數(shù)據(jù)庫

這篇文章主要介紹“MySQL半同步SLAVE是什么”,在日常操作中,相信很多人在MySQL半同步SLAVE是什么問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”MySQL半同步SLAVE是什么”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!

Mysql半同步SLAVE,類似于ORACLE安全模式的DATAGUARD(但不完全是);
為什么是半同步呢,因為MYSQL只保證“至少一個”SLAVE接收到日志后返回;
 雖然可能不會有太多的人去用這個東西(因為對網(wǎng)絡(luò)的要求和機器的穩(wěn)定性很高);但MYSQL還是補全了這一塊的功能缺失

 A commit performed on the master side blocks before returning to the session
 that performed the transaction until at least one slave acknowledges that it has received
 and logged the events for the transaction.
 
 Semisynchronous replication is implemented through an optional plugin component.
 See Section 17.3.8, “Semisynchronous Replication”.
 http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html


The slave acknowledges receipt of a transaction's events only after the events have been written to its relay log and flushed to disk.
只有SLAVE接收到日志寫入到RELAY-LOG,并刷新到磁盤才算同步成功;
If a timeout occurs without any slave having acknowledged the transaction, the master reverts to asynchronous replication
如果日志傳輸過程中發(fā)生超時現(xiàn)象;那么SLAVE將恢復(fù)到異步方式;
Semisynchronous replication must be enabled on both the master and slave sides. If semisynchronous replication is disabled on the master, or enabled on the master but on no slaves, the master uses asynchronous replication
半同步復(fù)制方式必須在MASTER和SLAVE同時打開;否則還是采用異步方式;
While the master is blocking (waiting for acknowledgment from a slave after having performed a commit), it does not return to the session that performed the transaction
在SLAVE接受到日志或超時之前,MASTER對SESSION的COMMIT請求不作返回響應(yīng);
The rolled-back transaction is logged even though it has no effect for transactional tables because the modifications to the nontransactional tables cannot be rolled back and must be sent to slaves.
滾回操作,即使對事務(wù)表沒有影響,也同樣會被記錄到日志里,因為“修改”會非事務(wù)表是不可回滾的,所以必須也傳輸?shù)絊LAVE;
對于自動提交的語句; MASTER將被在每個語句結(jié)束后BLOCK??;

## 幾個系統(tǒng)變量設(shè)置
rpl_semi_sync_master_enabled=1 # 打開MASTER支持semisynchronous replication
rpl_semi_sync_slave_enabled=1  # 打開Slave 支持semisynchronous replication
rpl_semi_sync_master_timeout   # 等待SLAVE超時時間;1MS,默認(rèn)10000MS
rpl_semi_sync_master_wait_no_slave  # 在超時之前,如果SLAVE都DOWN了,是不是還繼續(xù)等待直到超時;默認(rèn)打開 ;

## 幾個狀態(tài)變量
Rpl_semi_sync_master_status   # 查看MASTER是否支持semisynchronous replication
Rpl_semi_sync_slave_status    # 查看SLAVE 是否支持semisynchronous replication
Rpl_semi_sync_master_clients  # 查看后面跟著幾個semisynchronous slaves
Rpl_semi_sync_master_yes_tx   # 成功傳輸了多少個事務(wù);
Rpl_semi_sync_master_no_tx    # 失敗傳輸了多少個事務(wù);

到此,關(guān)于“MySQL半同步SLAVE是什么”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI