MySQL默认Replication如何搭建异步复制-创新互联

本文主要给大家介绍MySQL默认Replication如何搭建异步复制,文章内容都是笔者用心摘选和编辑的,具有一定的针对性,对大家的参考意义还是比较大的,下面跟笔者一起了解下MySQL默认Replication如何搭建异步复制吧。

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站制作、成都网站设计、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的通辽网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

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.

--主库提交一个事物,需要等待所有从库先提交才能返回结果,执行这个事物。这样会造成一个事物延时。

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.

--介于异步复制和全复制之间,主库仅仅只要等待至少一个从库收到和记录events。它不需要等待所有的从库告诉它收到events,也不需要从库执行和提交事物,从库只是收到events就会告诉主库,这样主库就可以提前提交事物了。

MySQL默认Replication如何搭建异步复制

此外,半同步也分两种,有参数rpl_semi_sync_master_wait_point控制,这里我就不多做解释了,我们使用默认设置after_sync,这种数据零丢失

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.测试环境

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

一个master,slave1和slave2都是master的直接从库。

分两种情况测试:

(1)当slave1和slave2都是异步复制的时候

(2)当slave1是半同步复制,slave2是异步复制的时候

3.压力测试

使用TPCC压力测试软件,比较TPS判断异步和半同步复制的性能差异到底有多大。

具体如何测试,可以参考之前的博客:MySQL压测--TPCC安装,测试

  • 通过TPCC测试获得的数据库TpmC数据

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默认Replication如何搭建异步复制

4.总结

从本测试结果可以看出:

  • 无论是半同步复制还是异步复制,数据库的TpmC刚开始随着并发线程的增加而增加,到达200个左右,TpmC开始逐渐下降;

  • 当线程数在16-1024左右之间,异步复制的TpmC明显比半同步的大很多,相差大概1000-2000左右,所以半同步相比异步性能是要下降很多;

  • 如果你的数据库并发并不是很多,又对数据安全要求比较高,可以优先考虑使用半同步复制;

看完以上关于MySQL默认Replication如何搭建异步复制,很多读者朋友肯定多少有一定的了解,如需获取更多的行业知识信息 ,可以持续关注我们的行业资讯栏目的。

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

分享题目:MySQL默认Replication如何搭建异步复制-创新互联
网页链接:https://www.cdcxhl.com/article8/cshpop.html

成都网站建设公司_创新互联,为您提供全网营销推广手机网站建设面包屑导航ChatGPT定制网站标签优化

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

外贸网站制作