8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

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

19.2.2 复制通道19.2.2 Replication Channels

在 MySQL 多源复制中,副本会为每个源服务器打开多个复制通道。复制通道表示事务从源流向副本的路径。每个复制通道都有自己的接收器(I/O)线程,一个或多个应用(SQL)线程,以及中继日志。当通道的接收器线程接收到来自源的事务时,这些事务会被添加到该通道的中继日志文件中,并传递给通道的应用线程。这样可以使每个通道独立运行。In MySQL multi-source replication, a replica opens multiple replication channels, one for each source server. The replication channels represent the path of transactions flowing from a source to the replica. Each replication channel has its own receiver (I/O) thread, one or more applier (SQL) threads, and relay log. When transactions from a source are received by a channel's receiver thread, they are added to the channel's relay log file and passed through to the channel's applier threads. This enables each channel to function independently.

本节介绍了在复制拓扑中如何使用通道,以及它们对单源复制的影响。有关配置多源复制的源和副本、启动、停止和重置多源副本以及监控多源复制的说明,请参见 第 19.1.5 节,“MySQL 多源复制”。This section describes how channels can be used in a replication topology, and the impact they have on single-source replication. For instructions to configure sources and replicas for multi-source replication, to start, stop and reset multi-source replicas, and to monitor multi-source replication, see Section 19.1.5, “MySQL Multi-Source Replication”.

在多源复制拓扑中,一个副本服务器上可以创建的最大通道数为 256。每个复制通道必须具有唯一(非空)名称,如 第 19.2.2.4 节,“复制通道命名约定” 中所述。当启用多源复制时,发出的错误代码和消息会指明产生错误的通道。The maximum number of channels that can be created on one replica server in a multi-source replication topology is 256. Each replication channel must have a unique (nonempty) name, as explained in Section 19.2.2.4, “Replication Channel Naming Conventions”. The error codes and messages that are issued when multi-source replication is enabled specify the channel that generated the error.

Note

每个多源副本上的通道必须从不同的源进行复制。不能将单个副本的多个复制通道设置为来自单个源。这是因为副本的服务器 ID 在复制拓扑中必须是唯一的。源仅通过服务器 ID 来区分副本,而不是通过复制通道的名称,因此无法识别来自同一副本的不同复制通道。Each channel on a multi-source replica must replicate from a different source. You cannot set up multiple replication channels from a single replica to a single source. This is because the server IDs of replicas must be unique in a replication topology. The source distinguishes replicas only by their server IDs, not by the names of the replication channels, so it cannot recognize different replication channels from the same replica.

多源副本也可以设置为多线程副本,通过将系统变量 replica_parallel_workers 设置为大于 0 的值。当你在多源副本上执行此操作时,副本上的每个通道都有指定数量的应用线程,以及一个协调线程来管理它们。你不能为单独的通道配置应用线程的数量。A multi-source replica can also be set up as a multi-threaded replica, by setting the system variable replica_parallel_workers to a value greater than 0. When you do this on a multi-source replica, each channel on the replica has the specified number of applier threads, plus a coordinator thread to manage them. You cannot configure the number of applier threads for individual channels.

多源副本可以在特定的复制通道上配置复制过滤器。当相同的数据库或表存在于多个源时,可以使用通道特定的复制过滤器,并且您只需要副本从一个源进行复制。对于基于 GTID 的复制,如果相同的事务可能来自多个源(例如在菱形拓扑中),您必须确保所有通道上的过滤设置相同。更多信息,请参见 第 19.2.5.4 节,“基于复制通道的过滤器”。Multi-source replicas can be configured with replication filters on specific replication channels. Channel specific replication filters can be used when the same database or table is present on multiple sources, and you only need the replica to replicate it from one source. For GTID-based replication, if the same transaction might arrive from multiple sources (such as in a diamond topology), you must ensure the filtering setup is the same on all channels. For more information, see Section 19.2.5.4, “Replication Channel Based Filters”.

为了与之前版本兼容,MySQL 服务器在启动时会自动创建一个默认通道,其名称为空字符串("")。该通道始终存在;用户无法创建或销毁它。如果未创建其他通道(具有非空名称),则复制语句仅作用于默认通道,因此所有来自旧副本的复制语句都可以按预期工作(参见 第 19.2.2.2 节,“与先前复制语句的兼容性”)。本节描述的适用于复制通道的语句仅在至少存在一个命名通道时才能使用。To provide compatibility with previous versions, the MySQL server automatically creates on startup a default channel whose name is the empty string (""). This channel is always present; it cannot be created or destroyed by the user. If no other channels (having nonempty names) have been created, replication statements act on the default channel only, so that all replication statements from older replicas function as expected (see Section 19.2.2.2, “Compatibility with Previous Replication Statements”. Statements applying to replication channels as described in this section can be used only when there is at least one named channel.