本文主要給大家介紹MySQL默認(rèn)Replication如何搭建異步復(fù)制,文章內(nèi)容都是筆者用心摘選和編輯的,具有一定的針對性,對大家的參考意義還是比較大的,下面跟筆者一起了解下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)時代的通遼網(wǎng)站設(shè)計(jì)、移動媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!1.背景知識
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.
--主庫只管把events寫入binlog中,不管從庫有沒有收到。
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.
--主庫提交一個事物,需要等待所有從庫先提交才能返回結(jié)果,執(zhí)行這個事物。這樣會造成一個事物延時。
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ù)制之間,主庫僅僅只要等待至少一個從庫收到和記錄events。它不需要等待所有的從庫告訴它收到events,也不需要從庫執(zhí)行和提交事物,從庫只是收到events就會告訴主庫,這樣主庫就可以提前提交事物了。
此外,半同步也分兩種,有參數(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.測試環(huán)境
Role | Hostname | IP | CPU | Memory | MySQL Version |
TPCC | sht-sgmhadoopcm-01 | 172.16.101.54 | 2Core | 8G | NO |
master | sht-sgmhadoopdn-01 | 172.16.101.58 | 2Core | 6G | 5.7.21 |
slave1 | sht-sgmhadoopdn-02 | 172.16.101.59 | 2Core | 6G | 5.7.21 |
slave2 | sht-sgmhadoopdn-03 | 172.16.101.60 | 2Core | 6G | 5.7.21 |
一個master,slave1和slave2都是master的直接從庫。
分兩種情況測試:
(1)當(dāng)slave1和slave2都是異步復(fù)制的時候
(2)當(dāng)slave1是半同步復(fù)制,slave2是異步復(fù)制的時候
3.壓力測試
使用TPCC壓力測試軟件,比較TPS判斷異步和半同步復(fù)制的性能差異到底有多大。
具體如何測試,可以參考之前的博客:MySQL壓測--TPCC安裝,測試
通過TPCC測試獲得的數(shù)據(jù)庫TpmC數(shù)據(jù)
Thread Count | Asynchronous | Semisynchronous |
4 | 1145.900 | 1081.133 |
8 | 1966.633 | 1687.933 |
16 | 3202.333 | 2538.233 |
32 | 4363.533 | 3302.167 |
64 | 5112.900 | 3638.667 |
128 | 5257.267 | 3738.100 |
256 | 5199.733 | 3823.833 |
512 | 4753.700 | 3538.633 |
1024 | 3268.633 | 2769.667 |
1536 | 2294.000 | 2215.733 |
繪制折線圖像
4.總結(jié)
從本測試結(jié)果可以看出:
無論是半同步復(fù)制還是異步復(fù)制,數(shù)據(jù)庫的TpmC剛開始隨著并發(fā)線程的增加而增加,到達(dá)200個左右,TpmC開始逐漸下降;
當(dāng)線程數(shù)在16-1024左右之間,異步復(fù)制的TpmC明顯比半同步的大很多,相差大概1000-2000左右,所以半同步相比異步性能是要下降很多;
如果你的數(shù)據(jù)庫并發(fā)并不是很多,又對數(shù)據(jù)安全要求比較高,可以優(yōu)先考慮使用半同步復(fù)制;
看完以上關(guān)于MySQL默認(rèn)Replication如何搭建異步復(fù)制,很多讀者朋友肯定多少有一定的了解,如需獲取更多的行業(yè)知識信息 ,可以持續(xù)關(guān)注我們的行業(yè)資訊欄目的。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
分享題目:MySQL默認(rèn)Replication如何搭建異步復(fù)制-創(chuàng)新互聯(lián)
網(wǎng)頁鏈接:http://jinyejixie.com/article8/cshpop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎ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)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容