仔细观察可以发现,MGR在MySQL 5.7.17上宣布GA, Mysql 5.7的后续版本的发布日志(release notes)中bug fix的部分,绝大部分bug是关于mgr的,从侧面也反映社区跟官方一直在关注跟重视MGR,MGR将变得越来越稳定,越来越安全,可以肯定的是,MGR(或类似解决方案)将成为主流,普通的主从模式很有可能在不久的将来成为历史。
在MySQL 5.7.20版本发布之后,今天仔细浏览该版本的release note, 看到下面这部分的内容。让作者有些惊喜:
Functionality Added or Changed
-
Replication: In previous versions issuing
STOP GROUP_REPLICATION
stopped the plugin but the server still accepted transactions. This meant the transactions were not transmitted to the group. To make
STOP GROUP_REPLICATION
safer, now
super_read_only
is set to
ON
immediately upon issuing
STOP GROUP_REPLICATION
, which ensures no transactions are accepted. (Bug #25495067, Bug #84795)
-
Replication: The
group_replication_member_weight
variable has been added which enables you to control the election of new primaries in single-primary mode. In previous versions primary election was based on the member\’s UUID, with the lowest UUID elected as the new primary in the event of fail over. Use this variable to assign numeric weights to members to ensure that specific members are elected, for example during scheduled maintenance of the primary or to ensure certain hardware is prioritised.
原因 :
第一个功能: 在以前的版本中,任何一个mgr节点在执行stop group_replication命令之后,该节点马上就变成了一个脱离集群的可写节点,如果这时有写流量“闯入”,将严重破坏集群内各节点的数据最终一致性。该缺陷作者9月份在某某大会上讲过,今天在5.7.20的发布日志上看到这个新功能,所以有点惊喜。
第二个功能:使用过MHA做高可用的朋友都知道,MHA有候选主库的设置,可以约定当主库挂掉之后,由候选主库接管。 但5.7.20之前的版本,使用单主模式的MGR时,当主节点挂掉,重新选择新的主节点的时,采用的uuid来排序,如果靠使用uuid来设置候选主库,这个深层的含义得深挖才能让人懂。所以基本上看作是没有设置候选主库的功能。现在可以通过参数group_replication_member_weight 来设置,妥了。这个功能对于高可用方案太重要了——主库挂了,新的主库可不能随机“乱”选。
另外,提一下一个没什么非常大意义的内容。 query cache在该版本废弃了, 本来query cache的意义也不大,对于mysql来说,基本都是在线交易处理居多,query cache意义不大,结果就是废弃了。
The query cache is now deprecated and is removed in MySQL 8.0. Deprecation includes these items: