浅析MySQL 5.7组复制技术(Group Replication)
Group Replication is know as an up to date HA(High Availablity) solution which is supported in official version of MySQL 5.7 since Dec. 2016.It's similar with the other two tools —— MHA(By Yoshinorim) & PXC(By Percona),but not as same as them. Group Replication(I'll call it MGR later) provides features below:
Mr Lamport's introduction on wiki: https://en.wikipedia.org/wiki/Leslie_Lamport MGR provides a built-in membership service which can strongly coordinate the servers in the same group to do switchover between master and slave automatically with high efficiency and strong consistency.All members in the same group will communicate with each other from time to time by GSC protocols.The group members always come up to an agreement in an order of global transaction sequence in order to decide whether to commit or abort transactions when commit operations happen.
One server in group can be replicated from another one automatically until it become equal when adding or removing it.MGR will maintain a view which contains informations about these group members if they changes,All the members join or leave the group voluntarilly or not will dynamically reconfigure the view. In order to distinguish MGR and traditional replication technology,let's see the pictures below: Asynchronous Replication:
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄
- high consistency
Mr Lamport's introduction on wiki: https://en.wikipedia.org/wiki/Leslie_Lamport MGR provides a built-in membership service which can strongly coordinate the servers in the same group to do switchover between master and slave automatically with high efficiency and strong consistency.All members in the same group will communicate with each other from time to time by GSC protocols.The group members always come up to an agreement in an order of global transaction sequence in order to decide whether to commit or abort transactions when commit operations happen.
- high flexibility
- high fault-tolerance
- high scalability
One server in group can be replicated from another one automatically until it become equal when adding or removing it.MGR will maintain a view which contains informations about these group members if they changes,All the members join or leave the group voluntarilly or not will dynamically reconfigure the view. In order to distinguish MGR and traditional replication technology,let's see the pictures below: Asynchronous Replication:
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
Semisynchronous Replication(after_sync):
From the above two pictures,we can see that there's no HA function in the master-slave traditional replication(both asyn mode and semisync mode).whenever the master crashes,the service won't be available anymore.
In most scenarios,master has one or more slaves.Commits of transactions take place merely on the master.Binlogs are transited(asynchronously).Each server has a full copy of data 'cause it shares nothing here.
Group Replication(multi-primary):
Above is the multi-primary mode of MGR,There're something diffrerent such as "certify" and "consensus" in the picture.The consensus based on paxos make sure the consistencies between the masters.but it's still a shared-nothing replication the same as the classical replication.
Notice,in multi-primary mode,all ther masters can execute transactions and commit independently,if there's a confilct(which always happens in the certification procedure),for example,they want to update the same row of one table,only one master who has the earlier golobal transaction sequence will get the privilege to finish the operation(what seems like first commit win principle). Summary:
- Be compared with MHA & PXC,MGR is the newest supplement in MySQL high availability family.
- There're still few case using MGR to implement in product system nowadays.
- MySQL Servers don't need to failover but the application does.
- The practical usage of MGR is together with some middleware product such as ProxySQL.

更多精彩