MySQL InnoDB ReplicaSet安装文档

MySQL副本集介绍

MySQL InnoDB ReplicaSet(也叫MySQL副本集,有些地方也翻译成MySQL复制集)是在 MySQL 8.0.19 版本(2020-01-13 Released)之后开始支持的,MySQL副本集中拥有一个primary节点,一个或多个secondary节点,它不像MySQL InnoDB Cluster一样提供故障自愈和多主模式,但是它提供手工的方法添加、移除和配置相关节点.说得直白一点,MySQL副本集其实就是将MySQL主从复制、MySQL Shell、MySQL Router技术融合起来的一种技术,它的优点是可以帮助用户快速、简单的部署和管理主从复制。但是它的不足与限制也非常多。这里仅仅学习、研究MySQL副本集,毕竟技术都是快速向前迭代发展的。说不定哪天就蜕变得非常惊艳了。

MySQL副本集的限制

下面是官方文档[1]中介绍的MySQL InnoDB ReplicaSet(MySQL副本集)的一些限制:

  1. 没有自动故障转移功能。在主节点不可用的情况下,需要使用 AdminAPI 手动触发故障转移,然后才能再次进行任何更改。但是,辅助实例仍可供读取数据。

    No automatic failover. In events where the primary becomes unavailable, a failover needs to be triggered manually using AdminAPI before any changes are possible again. However, secondary instances remain available for reads.

  2. 无法防止由于意外停止或不可用而导致部分数据丢失:在意外停止时未完成的事务可能会丢失。

    No protection from partial data loss due to an unexpected halt or unavailability: Transactions that are not complete at the time of the unexpected halt could be lost.

  3. 在意外退出或不可用后无法防止数据不一致。如果手动故障转移提升了一个辅助实例,而前一个主实例仍然可用(例如,由于网络分区), 则裂脑情况可能会导致数据不一致。

    No protection against inconsistencies after an unexpected exit or unavailability. If a manual failover promotes a secondary instance while the former primary is still available, for example, due to a network partition, the split-brain situation could introduce data inconsistencies.

  4. InnoDB ReplicaSet 不支持多主模式。允许写入所有成员的经典复制拓扑无法保证数据一致性。

    InnoDB ReplicaSet does not support a multi-primary mode. Data consistency cannot be guaranteed with classic replication topologies that allow writes to all members.

  5. 读取横向扩展是有限的。InnoDB ReplicaSet 基于异步复制,因此无法像 Group Replication 那样调整流量控制。

    Read scale-out is limited. InnoDB ReplicaSet is based on asynchronous replication, and therefore there is no possible tuning of flow control as there is with Group Replication.

  6. 所有从节点(次要成员)都从单一来源复制。对于某些特定的用例,这可能会影响单一来源,例如,大量的小更新。

    All secondary members replicate from a single source. For some particular use-cases, this could impact the single source, for example, numerous small updates.

  7. 仅支持运行 MySQL 8.0 及更高版本的实例。

    Only instances running MySQL version 8.0 and later are supported.

  8. 仅支持基于 GTID 的复制,二进制日志文件位置复制与 InnoDB ReplicaSet 不兼容。

    Only GTID-based replication is supported, Binary log file position replication is incompatible with InnoDB ReplicaSet.

  9. 仅支持基于行的复制 (RBR),不支持基于语句的复制 (SBR)。

    Only Row-Based Replication (RBR) is supported, Statement-Based Replication (SBR) is unsupported.

  10. 不支持复制过滤 Replication filters are not supported.

  11. 任何实例上都不允许使用非托管复制通道 Unmanaged replication channels are not allowed on any instance.

  12. 一个 ReplicaSet 最多由一个主实例组成。支持一个或多个辅助实例。尽管可以添加到 ReplicaSet 的辅助节点数量没有限制,但连接到 ReplicaSet 的每个 MySQL Router 都必须监视每个实例。因此,添加到 ReplicaSet 的实例越多,监控就越多 A ReplicaSet consists of a maximum of one primary instance. One or multiple secondaries are supported. Although there is no limit to the number of secondaries you can add to a ReplicaSet, each MySQL Router connected to a ReplicaSet has to monitor each instance. Therefore, the more instances added to a ReplicaSet, the more monitoring there is.

  13. ReplicaSet 必须由 MySQL Shell 管理。例如,复制帐户是由 MySQL Shell 创建和管理的。不支持在 MySQL Shell 之外对实例进行配置更改,例如直接使用 SQL 语句更改主实例。始终使用 MySQL Shell 来处理 InnoDB ReplicaSet。

    The ReplicaSet must be managed by MySQL Shell. For example, the replication account is created and managed by MySQL Shell. Making configuration changes to the instance outside MySQL Shell, for example, using SQL statements directly to change the primary instance, is not supported. Always use MySQL Shell to work with InnoDB ReplicaSet.

MySQL副本集的部署

这里计划在下面两台服务器上安装MySQL InnoDB ReplicaSet(MySQL副本集),MySQL数据库版本为8.0.33,操作系统版本为RHEL 8.8

192.168.9.154  dbtest04<br>192.168.9.159  dbtest05<br>