8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 23 InnoDB 集群
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

第 23 章 InnoDB 集群Chapter 23 InnoDB Cluster

本章介绍 MySQL InnoDB 集群,它结合 MySQL 技术,使您能够部署和管理完整的集成高可用性 MySQL 解决方案。本内容为 InnoDB 集群的高级概述,完整文档请参阅 MySQL InnoDB 集群。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.

Important

InnoDB 集群不支持 MySQL NDB 集群。有关 MySQL NDB 集群的更多信息,请参阅 第 25 章,MySQL NDB 集群 8.4 和 第 25.2.6 节,“使用 InnoDB 的 MySQL Server 与 NDB 集群的比较”。InnoDB Cluster does not provide support for MySQL NDB Cluster. For more information about MySQL NDB Cluster, see Chapter 25, MySQL NDB Cluster 8.4 and Section 25.2.6, “MySQL Server Using InnoDB Compared with NDB Cluster”.

InnoDB 集群至少由三个 MySQL 服务器实例组成,并提供高可用性和扩展功能。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,这是 MySQL 的一个高级客户端和代码编辑器。MySQL Shell, which is an advanced client and code editor for MySQL.

  • MySQL 服务器,以及 组复制,它使一组 MySQL 实例能够提供高可用性。InnoDB 集群提供了一种替代的、易于使用的编程方式来使用组复制。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,一个轻量级中间件,在您的应用程序与 InnoDB 集群之间提供透明路由。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

Three MySQL servers are grouped together as a high availability cluster. One of the servers is the read/write primary instance, and the other two are read-only secondary instances. Group Replication is used to replicate data from the primary instance to the secondary instances. MySQL Router connects client applications (in this example, a MySQL Connector) to the primary instance.

基于 MySQL 组复制 构建,提供自动成员管理、容错、自动故障转移等功能。InnoDB 集群通常以单主模式运行,包含一个主实例(读写)和多个从实例(只读)。高级用户还可以利用 多主模式,在该模式下所有实例都是主实例。您甚至可以在 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.

您使用 InnoDB 集群通过 AdminAPI,该 API 是 MySQL Shell 的一部分提供的。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 Cluster,您需要下载并安装 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 集群支持 MySQL 克隆,可以让您轻松配置实例。过去,在新实例加入 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 集群与 MySQL Router 紧密集成,您可以使用 AdminAPI 与它们一起协作。MySQL Router 可以根据 InnoDB 集群自动配置自己,这一过程称为 引导配置,无需您手动配置路由。然后,MySQL Router 会透明地将客户端应用程序连接到 InnoDB 集群,为客户端连接提供路由和负载均衡。这种集成还允许您使用 AdminAPI 管理通过 InnoDB 集群引导配置的一些 MySQL Router 功能。InnoDB 集群的状态信息包括通过该集群引导配置的 MySQL Router 详情。操作功能使您能够在集群级别创建 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.

有关这些技术的更多信息,请参阅描述中链接的用户文档。除了这些用户文档之外,所有 AdminAPI 方法的开发者文档均可在 MySQL Shell JavaScript API 参考或 MySQL Shell Python API 参考中找到,可从 连接器和 API 获取。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.