文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

25.7 NDB 集群复制25.7 NDB Cluster Replication

NDB 集群支持 异步复制,通常简称为 “复制”。本节解释了如何设置和管理一种配置,即一组作为 NDB 集群运行的计算机复制到第二台计算机或计算机组。我们假设读者对本手册其他部分讨论的标准 MySQL 复制有一定了解。(参见 第 19 章,复制)。NDB Cluster supports asynchronous replication, more usually referred to simply as “replication”. This section explains how to set up and manage a configuration in which one group of computers operating as an NDB Cluster replicates to a second computer or group of computers. We assume some familiarity on the part of the reader with standard MySQL replication as discussed elsewhere in this Manual. (See Chapter 19, Replication).

Note

NDB 集群不支持使用 GTID 的复制;半同步复制和组复制也不被 NDB 存储引擎支持。NDB Cluster does not support replication using GTIDs; semisynchronous replication and group replication are also not supported by the NDB storage engine.

普通(非集群)复制涉及一个源服务器和一个副本服务器,之所以称源服务器为源,是因为要复制的操作和数据起源于它,而副本是这些操作和数据的接收者。在 NDB 集群中,复制在概念上非常相似,但在实际操作中可能更为复杂,因为它可以扩展以覆盖多种不同的配置,包括在两个完整集群之间进行复制。虽然 NDB 集群本身依赖于 NDB 存储引擎来实现集群功能,但没有必要将 NDB 用作副本中复制表的存储引擎(参见 从 NDB 到其他存储引擎的复制)。然而,为了实现最大可用性,可以(并且最好)将一个 NDB 集群的数据复制到另一个 NDB 集群,我们讨论的就是这种场景,如下图所示:Normal (non-clustered) replication involves a source server and a replica server, the source being so named because operations and data to be replicated originate with it, and the replica being the recipient of these. In NDB Cluster, replication is conceptually very similar but can be more complex in practice, as it may be extended to cover a number of different configurations including replicating between two complete clusters. Although an NDB Cluster itself depends on the NDB storage engine for clustering functionality, it is not necessary to use NDB as the storage engine for the replica's copies of the replicated tables (see Replication from NDB to other storage engines). However, for maximum availability, it is possible (and preferable) to replicate from one NDB Cluster to another, and it is this scenario that we discuss, as shown in the following figure:

图 25.10 NDB 集群到集群复制布局Figure 25.10 NDB Cluster-to-Cluster Replication Layout

Much of the content is described in the surrounding text. It visualizes how a MySQL source is replicated. The replica differs in that it shows an I/O (receiver) thread pointing to a relay binary log which points to an SQL (applier) thread. In addition, while the binary log points to and from the NDBCLUSTER engine on the source server, on the replica it points directly to an SQL node (MySQL server).

在这种情况下,复制过程是将源集群的连续状态记录并保存到副本集群中的过程。这个过程由一个称为 NDB 二进制日志注入线程的特殊线程完成,该线程在每个 MySQL 服务器上运行,并生成二进制日志(binlog)。该线程确保生成二进制日志的集群中的所有更改——不仅仅是通过 MySQL 服务器进行的更改——都按照正确的序列顺序插入到二进制日志中。我们将 MySQL 源服务器和副本服务器称为复制服务器或复制节点,而它们之间的数据流或通信线路称为 复制通道。In this scenario, the replication process is one in which successive states of a source cluster are logged and saved to a replica cluster. This process is accomplished by a special thread known as the NDB binary log injector thread, which runs on each MySQL server and produces a binary log (binlog). This thread ensures that all changes in the cluster producing the binary log—and not just those changes that are effected through the MySQL Server—are inserted into the binary log with the correct serialization order. We refer to the MySQL source and replica servers as replication servers or replication nodes, and the data flow or line of communication between them as a replication channel.

有关使用 NDB Cluster 和 NDB Cluster 复制执行时间点恢复的信息,请参阅 第 25.7.9.2 节,“使用 NDB Cluster 复制进行时间点恢复”。For information about performing point-in-time recovery with NDB Cluster and NDB Cluster Replication, see Section 25.7.9.2, “Point-In-Time Recovery Using NDB Cluster Replication”.

NDB API 副本状态变量。 NDB API 计数器可以为副本集群提供增强的监控能力。这些计数器被实现为 NDB 统计 _replica 状态变量,如在 SHOW STATUS 的输出中所示,或在针对 Performance Schema session_status 或 global_status 表的查询结果中,在连接到作为 NDB 集群复制副本的 MySQL 服务器的 mysql 客户端会话里。通过比较影响被复制的 NDB 表的语句执行前后的这些状态变量的值,可以观察副本在 NDB API 层面上采取的相应操作,这在监控或排查 NDB 集群复制时非常有用。第 25.6.14 节,“NDB API 统计计数器和变量” 提供了更多信息。NDB API replica status variables.  NDB API counters can provide enhanced monitoring capabilities on replica clusters. These counters are implemented as NDB statistics _replica status variables, as seen in the output of SHOW STATUS, or in the results of queries against the Performance Schema session_status or global_status table in a mysql client session connected to a MySQL Server that is acting as a replica in NDB Cluster Replication. By comparing the values of these status variables before and after the execution of statements affecting replicated NDB tables, you can observe the corresponding actions taken on the NDB API level by the replica, which can be useful when monitoring or troubleshooting NDB Cluster Replication. Section 25.6.14, “NDB API Statistics Counters and Variables”, provides additional information.

从 NDB 到非 NDB 表的复制。 可以将 NDB 表从作为复制源的 NDB 集群复制到使用其他 MySQL 存储引擎的表,如副本上的 InnoDB 或 MyISAM 的 mysqld。这需要满足一些条件;更多信息请参见 从 NDB 复制到其他存储引擎 和 从 NDB 复制到非事务性存储引擎。Replication from NDB to non-NDB tables.  It is possible to replicate NDB tables from an NDB Cluster acting as the replication source to tables using other MySQL storage engines such as InnoDB or MyISAM on a replica mysqld. This is subject to a number of conditions; see Replication from NDB to other storage engines, and Replication from NDB to a nontransactional storage engine, for more information.