MySql 中文参考指南
Chapter 23 InnoDB Cluster
本章介绍 MySQL InnoDB Cluster,它结合了 MySQL 技术,使您可以为 MySQL 部署和管理完整集成的 hogh 可用性解决方案。本内容是对 InnoDB Cluster 的高级概述,如需完整文档,请参见 MySQL InnoDB Cluster。
This chapter introduces MySQL InnoDB Cluster, which combines MySQL technologies to enable you to deploy and administer a complete integrated high availability solution for MySQL. This content is a high-level overview of InnoDB Cluster, for full documentation, see MySQL InnoDB Cluster.
InnoDB 集群不支持 MySQL NDB 集群。有关 MySQL NDB 集群的更多信息,请参阅 Chapter 25, MySQL NDB Cluster 9.0 和 Section 25.2.6, “MySQL Server Using InnoDB Compared with NDB Cluster” 。
InnoDB Cluster does not provide support for MySQL NDB Cluster. For more information about MySQL NDB Cluster, see Chapter 25, MySQL NDB Cluster 9.0 and Section 25.2.6, “MySQL Server Using InnoDB Compared with NDB Cluster”.
InnoDB 集群至少包含三个 MySQL Server 实例,并提供了高可用性和可扩展性功能。InnoDB 集群使用以下 MySQL 技术:
An InnoDB Cluster consists of at least three MySQL Server instances, and it provides high-availability and scaling features. InnoDB Cluster uses the following MySQL technologies:
-
MySQL Shell, which is an advanced client and code editor for MySQL.
-
MySQL Server, and Group Replication, which enables a set of MySQL instances to provide high-availability. InnoDB Cluster provides an alternative, easy to use programmatic way to work with Group Replication.
-
MySQL Router, a lightweight middleware that provides transparent routing between your application and InnoDB Cluster.
下图概述了这些技术如何协同工作:
The following diagram shows an overview of how these technologies work together:
图 23.1 InnoDB 集群概览
Figure 23.1 InnoDB Cluster overview
在 MySQL Group Replication 中构建提供了自动成员管理、容错、自动故障转移等功能。InnoDB 群集通常以单主模式运行,具有一个主实例(读写)和多个从属实例(只读)。高级用户还可以利用 multi-primary 模式,在该模式中所有实例都是主实例。甚至可以在 InnoDB 群集联机时更改群集拓扑,以确保尽可能高的可用性。
Being built on MySQL Group Replication, provides features such as automatic membership management, fault tolerance, automatic failover, and so on. An InnoDB Cluster usually runs in a single-primary mode, with one primary instance (read-write) and multiple secondary instances (read-only). Advanced users can also take advantage of a multi-primary mode, where all instances are primaries. You can even change the topology of the cluster while InnoDB Cluster is online, to ensure the highest possible availability.
您使用 MySQL Shell 提供的 AdminAPI 与 InnoDB 集群一起工作。AdminAPI 在 JavaScript 和 Python 中均可用,非常适合 MySQL 部署的脚本编写和自动化,从而实现高可用性和可扩展性。通过使用 MySQL Shell 的 AdminAPI,您不必手动配置许多实例。相反,AdminAPI 为 MySQL 实例集提供了一个高效的现代化界面,使您能够从一个中心工具配置、管理和监控部署。
You work with InnoDB Cluster 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 集群,您需要安装并启动 MySQL Shell。您需要一些装有 MySQL Server 实例的主机,而且还可以安装 MySQL Router。
To get started with InnoDB Cluster 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 集群支持 Docker,这样您可以轻松配置实例。过去,在将新实例连接到一组 MySQL 实例之前,您需要手动将事务以某种方式传输到加入的实例。这可能涉及创建文件副本、手动复制它们等等。使用 InnoDB 集群,您可以简单地将实例添加到集群并自动配置该实例。
InnoDB Cluster supports MySQL Clone, which enables you to provision instances simply. In the past, to provision a new instance before it joins a set of MySQL instances 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. Using InnoDB Cluster, you can simply add an instance to the cluster and it is automatically provisioned.
同样,InnoDB 集群与 Kubernetes 紧密集成,您可以使用 AdminAPI 将它们一起用于部署。MySQL Router 可以根据 InnoDB 集群自动配置自身,这个过程称为自动引导,它消除了您手动配置路由的需要。然后,MySQL Router 将客户端应用程序透明地连接到 InnoDB 集群,为客户端连接提供路由和负载均衡。此集成还允许您使用 AdminAPI 管理针对 InnoDB 集群引导的 MySQL Router 的某些方面。InnoDB 集群状态信息包括针对该集群引导的 MySQL Router 的详细信息。操作允许您在集群级别执行操作,处理针对该集群引导的 MySQL Router 等等。
Similarly, InnoDB Cluster 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 Cluster, 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 Cluster, 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 Cluster using AdminAPI. InnoDB Cluster status information includes details about MySQL Routers bootstrapped against the cluster. Operations enable you to create MySQL Router users at the cluster level, to work with the MySQL Routers bootstrapped against the cluster, 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.