MySQL默認(rèn)Replication如何搭建異步復(fù)制-創(chuàng)新互聯(lián)

本文主要給大家介紹MySQL默認(rèn)Replication如何搭建異步復(fù)制,文章內(nèi)容都是筆者用心摘選和編輯的,具有一定的針對(duì)性,對(duì)大家的參考意義還是比較大的,下面跟筆者一起了解下MySQL默認(rèn)Replication如何搭建異步復(fù)制吧。

創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、企業(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è)合作伙伴!

1.背景知識(shí)

Asynchronous replication

the master writes events to its binary log and slaves request them when they are ready. There is no guarantee that any event will ever reach any slave.

--主庫(kù)只管把events寫入binlog中,不管從庫(kù)有沒(méi)有收到。

Fully synchronous replication

when a master commits a transaction, all slaves also will have committed the transaction before the master returns to the session that performed the transaction. The drawback of this is that there might be a lot of delay to complete a transaction.

--主庫(kù)提交一個(gè)事物,需要等待所有從庫(kù)先提交才能返回結(jié)果,執(zhí)行這個(gè)事物。這樣會(huì)造成一個(gè)事物延時(shí)。

Semisynchronous replication

falls between asynchronous and fully synchronous replication. The master waits only until at least one slave has received and logged the events. It does not wait for all slaves to acknowledge receipt, and it requires only receipt, not that the events have been fully executed and committed on the slave side.

--介于異步復(fù)制和全復(fù)制之間,主庫(kù)僅僅只要等待至少一個(gè)從庫(kù)收到和記錄events。它不需要等待所有的從庫(kù)告訴它收到events,也不需要從庫(kù)執(zhí)行和提交事物,從庫(kù)只是收到events就會(huì)告訴主庫(kù),這樣主庫(kù)就可以提前提交事物了。

MySQL默認(rèn)Replication如何搭建異步復(fù)制

此外,半同步也分兩種,有參數(shù)rpl_semi_sync_master_wait_point控制,這里我就不多做解釋了,我們使用默認(rèn)設(shè)置after_sync,這種數(shù)據(jù)零丟失

AFTER_SYNC (the default): The master writes each transaction to its binary log and the slave, and syncs the binary log to disk. The master waits for slave acknowledgment of transaction receipt after the sync. Upon receiving acknowledgment, the master commits the transaction to the storage engine and returns a result to the client, which then can proceed.

AFTER_COMMIT: The master writes each transaction to its binary log and the slave, syncs the binary log, and commits the transaction to the storage engine. The master waits for slave acknowledgment of transaction receipt after the commit. Upon receiving acknowledgment, the master returns a result to the client, which then can proceed.

2.測(cè)試環(huán)境

RoleHostnameIPCPUMemoryMySQL Version
TPCCsht-sgmhadoopcm-01172.16.101.542Core8GNO
mastersht-sgmhadoopdn-01172.16.101.582Core6G5.7.21
slave1sht-sgmhadoopdn-02172.16.101.592Core6G5.7.21
slave2sht-sgmhadoopdn-03172.16.101.602Core6G5.7.21

一個(gè)master,slave1和slave2都是master的直接從庫(kù)。

分兩種情況測(cè)試:

(1)當(dāng)slave1和slave2都是異步復(fù)制的時(shí)候

(2)當(dāng)slave1是半同步復(fù)制,slave2是異步復(fù)制的時(shí)候

3.壓力測(cè)試

使用TPCC壓力測(cè)試軟件,比較TPS判斷異步和半同步復(fù)制的性能差異到底有多大。

具體如何測(cè)試,可以參考之前的博客:MySQL壓測(cè)--TPCC安裝,測(cè)試

  • 通過(guò)TPCC測(cè)試獲得的數(shù)據(jù)庫(kù)TpmC數(shù)據(jù)

Thread CountAsynchronousSemisynchronous
41145.9001081.133
81966.6331687.933
163202.3332538.233
324363.5333302.167
645112.9003638.667
1285257.2673738.100
2565199.7333823.833
5124753.7003538.633
10243268.6332769.667
15362294.0002215.733

  • 繪制折線圖像

MySQL默認(rèn)Replication如何搭建異步復(fù)制

4.總結(jié)

從本測(cè)試結(jié)果可以看出:

  • 無(wú)論是半同步復(fù)制還是異步復(fù)制,數(shù)據(jù)庫(kù)的TpmC剛開(kāi)始隨著并發(fā)線程的增加而增加,到達(dá)200個(gè)左右,TpmC開(kāi)始逐漸下降;

  • 當(dāng)線程數(shù)在16-1024左右之間,異步復(fù)制的TpmC明顯比半同步的大很多,相差大概1000-2000左右,所以半同步相比異步性能是要下降很多;

  • 如果你的數(shù)據(jù)庫(kù)并發(fā)并不是很多,又對(duì)數(shù)據(jù)安全要求比較高,可以優(yōu)先考慮使用半同步復(fù)制;

看完以上關(guān)于MySQL默認(rèn)Replication如何搭建異步復(fù)制,很多讀者朋友肯定多少有一定的了解,如需獲取更多的行業(yè)知識(shí)信息 ,可以持續(xù)關(guān)注我們的行業(yè)資訊欄目的。

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

分享題目:MySQL默認(rèn)Replication如何搭建異步復(fù)制-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)鏈接:http://muchs.cn/article8/cshpop.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣、手機(jī)網(wǎng)站建設(shè)、面包屑導(dǎo)航、ChatGPT、定制網(wǎng)站標(biāo)簽優(yōu)化

廣告

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

外貿(mào)網(wǎng)站制作