MySql 中文参考指南

Chapter 24 InnoDB ReplicaSet

本章介绍 MySQL InnoDB ReplicaSet,它结合了 MySQL 技术,使你能够部署和管理 Chapter 19, Replication 。此内容是 InnoDB ReplicaSet 的高级概述,有关完整文档,请参阅 MySQL InnoDB ReplicaSet

This chapter introduces MySQL InnoDB ReplicaSet, which combines MySQL technologies to enable you to deploy and administer Chapter 19, Replication. This content is a high-level overview of InnoDB ReplicaSet, for full documentation, see MySQL InnoDB ReplicaSet.

InnoDB ReplicaSet 包含至少两个 MySQL Server 实例,并且它提供了您所熟悉的所有 MySQL 复制功能,例如读扩展和数据安全性。InnoDB ReplicaSet 使用以下 MySQL 技术:

An InnoDB ReplicaSet consists of at least two MySQL Server instances, and it provides all of the MySQL Replication features you are familiar with, such as read scale-out and data security. InnoDB ReplicaSet uses the following MySQL technologies:

  1. MySQL Shell, which is an advanced client and code editor for MySQL.

  2. MySQL Server, and Chapter 19, Replication, which enables a set of MySQL instances to provide availability and asynchronous read scale-out. InnoDB ReplicaSet provides an alternative, easy to use programmatic way to work with Replication.

  3. MySQL Router, a lightweight middleware that provides transparent routing between your application and InnoDB ReplicaSet.

对 InnoDB ReplicaSet 的界面类似于 MySQL InnoDB Cluster,你使用 MySQL Shell 来将 MySQL Server 实例作为 ReplicaSet 使用,同时 MySQL Router 也以与 InnoDB Cluster 相同的方式紧密集成。

The interface to an InnoDB ReplicaSet is similar to MySQL InnoDB Cluster, you use MySQL Shell to work with MySQL Server instances as a ReplicaSet, and MySQL Router is also tightly integrated in the same way as InnoDB Cluster.

基于 MySQL 复制,InnoDB ReplicaSet 有一个单一主实例,复制到一个或多个辅助实例。InnoDB ReplicaSet 没有提供 InnoDB 集群提供的全部功能,例如自动故障转移,或者多主模式。但是,它同样支持以类似方式配置、添加和移除实例。比如,当故障发生时,您可以手动切换或故障转移到一个辅助实例。甚至可以采用一个现有的复制部署,然后以 InnoDB ReplicaSet 的身份管理它。

Being based on MySQL Replication, an InnoDB ReplicaSet has a single primary, which replicates to one or more secondary instances. An InnoDB ReplicaSet does not provide all of the features which InnoDB Cluster provides, such as automatic failover, or multi-primary mode. But, it does support features such as configuring, adding, and removing instances in a similar way. You can manually switch over or fail over to a secondary instance, for example in the event of a failure. You can even adopt an existing Replication deployment and then administer it as an InnoDB ReplicaSet.

你使用 AdminAPI 来进行 InnoDB ReplicaSet 操作,该操作作为 MySQL Shell 的一部分提供。AdminAPI 在 JavaScript 和 Python 中可用,且非常适合 MySQL 部署的脚本编写和自动化,以实现高可用性和可扩展性。通过使用 MySQL Shell 的 AdminAPI,可以避免手动配置众多实例的需要。相反,AdminAPI 提供了一个有效的现代化界面用于 MySQL 实例集,使你能够从一个中心工具来置备、管理和监控自己的部署。

You work with InnoDB ReplicaSet using the AdminAPI, provided as part of MySQL Shell. AdminAPI is available in JavaScript and Python, and is well suited to scripting and automation of deployments of MySQL to achieve high-availability and scalability. By using MySQL Shell’s AdminAPI, you can avoid the need to configure many instances manually. Instead, AdminAPI provides an effective modern interface to sets of MySQL instances and enables you to provision, administer, and monitor your deployment from one central tool.

要开始使用 InnoDB ReplicaSet,你需要 downloadinstall MySQL Shell。你需要一些拥有 MySQL Server 实例的主机 installed,你还可以 install MySQL Router。

To get started with InnoDB ReplicaSet you need to download and install MySQL Shell. You need some hosts with MySQL Server instances installed, and you can also install MySQL Router.

InnoDB ReplicaSet 支持 MySQL Clone,使你能够轻松地置备实例。以前,要在将新实例加入 MySQL 复制部署之前将其置备,你需要以某种方式手动将事务传输到要加入的实例中。这可能涉及复制文件、手动复制文件,等等。你可以简单地 add an instance 到副本集中,然后会自动置备副本集。

InnoDB ReplicaSet supports MySQL Clone, which enables you to provision instances simply. In the past, to provision a new instance before it joined a MySQL Replication deployment, you would need to somehow manually transfer the transactions to the joining instance. This could involve making file copies, manually copying them, and so on. You can simply add an instance to the replica set and it is automatically provisioned.

类似地,InnoDB ReplicaSet 与 MySQL Router 紧密集成,你可以使用 AdminAPI 来 work with 它们。MySQL Router 可以根据 InnoDB ReplicaSet 自动配置自身,这一过程称为 bootstrapping,免去了手动配置路由的需要。然后,MySQL Router 会透明地将客户端应用程序连接到 InnoDB ReplicaSet,为客户端连接提供路由和负载均衡。此集成还使你能够使用 AdminAPI 管理引导到 InnoDB ReplicaSet 的 MySQL Router 的某些方面。InnoDB ReplicaSet 状态信息包括针对 ReplicaSet 引导的 MySQL Router 的详细信息。操作使你能够在 ReplicaSet 级别 create MySQL Router users,以使用针对 ReplicaSet 引导的 MySQL Router,等等。

Similarly, InnoDB ReplicaSet is tightly integrated with MySQL Router, and you can use AdminAPI to work with them together. MySQL Router can automatically configure itself based on an InnoDB ReplicaSet, in a process called bootstrapping, which removes the need for you to configure routing manually. MySQL Router then transparently connects client applications to the InnoDB ReplicaSet, providing routing and load-balancing for client connections. This integration also enables you to administer some aspects of a MySQL Router bootstrapped against an InnoDB ReplicaSet using AdminAPI. InnoDB ReplicaSet status information includes details about MySQL Routers bootstrapped against the ReplicaSet. Operations enable you to create MySQL Router users at the ReplicaSet level, to work with the MySQL Routers bootstrapped against the ReplicaSet, and so on.

有关这些技术的更多信息,请参阅描述中链接的用户文档。除了这份用户文档,在 MySQL Shell JavaScript API 参考或 MySQL Shell Python API 参考中还有适用于所有 AdminAPI 方法的开发人员文档,可从 Connectors and APIs 获取。

For more information on these technologies, see the user documentation linked in the descriptions. In addition to this user documentation, there is developer documentation for all AdminAPI methods in the MySQL Shell JavaScript API Reference or MySQL Shell Python API Reference, available from Connectors and APIs.