- 20.5.4.1 分布式恢复的连接20.5.4.1 Connections for Distributed Recovery
- 20.5.4.2 分布式恢复的克隆20.5.4.2 Cloning for Distributed Recovery
- 20.5.4.3 配置分布式恢复20.5.4.3 Configuring Distributed Recovery
- 20.5.4.4 分布式恢复的容错性20.5.4.4 Fault Tolerance for Distributed Recovery
- 20.5.4.5 分布式恢复的工作原理20.5.4.5 How Distributed Recovery Works
每当一个成员加入或重新加入复制组时,它必须追赶在它加入之前或离开期间由组成员应用的事务。这个过程称为分布式恢复。Whenever a member joins or rejoins a replication group, it must catch up with the transactions that were applied by the group members before it joined, or while it was away. This process is called distributed recovery.
加入的成员首先检查其 group_replication_applier 通道的中继日志,查看它是否已经从组中接收到但尚未应用的任何事务。如果加入的成员此前曾在该组中,它可能会发现离开之前未应用的事务,在这种情况下,它将首先应用这些事务。对于新加入组的成员,则没有任何事务需要应用。The joining member begins by checking the relay log for its
group_replication_applier channel for any
transactions that it already received from the group but did not
yet apply. If the joining member was in the group previously, it
might find unapplied transactions from before it left, in which
case it applies these as a first step. A member that is new to the
group does not have anything to apply.
之后,加入的成员会连接到一个在线的现有成员以执行状态转移。加入的成员会转移在其加入之前或离开期间在群组中发生的所有事务,这些事务由现有成员提供(称为捐赠者)。接下来,加入的成员会应用在状态转移进行过程中群组中发生的事务。当此过程完成后,加入的成员已赶上群组中其余服务器的状态,并开始正常参与群组。After this, the joining member connects to an online existing member to carry out state transfer. The joining member transfers all the transactions that took place in the group before it joined or while it was away, which are provided by the existing member (called the donor). Next, the joining member applies the transactions that took place in the group while this state transfer was in progress. When this process is complete, the joining member has caught up with the remaining servers in the group, and it begins to participate normally in the group.
群组复制在分布式恢复期间的状态转移中使用这些方法的组合:Group Replication uses a combination of these methods for state transfer during distributed recovery:
使用克隆插件功能进行远程克隆操作。要启用这种状态传输方法,必须在群组成员和加入成员上安装克隆插件。群组复制会自动配置所需的克隆插件设置并管理远程克隆操作。A remote cloning operation using the clone plugin's function. To enable this method of state transfer, you must install the clone plugin on the group members and the joining member. Group Replication automatically configures the required clone plugin settings and manages the remote cloning operation.
从捐赠者的二进制日志进行复制,并在加入成员上应用事务。此方法使用一个标准的异步复制通道,名为
group_replication_recovery,该通道在捐赠者和加入成员之间建立。Replicating from a donor's binary log and applying the transactions on the joining member. This method uses a standard asynchronous replication channel namedgroup_replication_recoverythat is established between the donor and the joining member.
在你对加入成员发出 START GROUP_REPLICATION 后,组复制会自动选择这些方法的最佳组合来进行状态传输。为此,组复制会检查哪些现有成员适合作为捐赠者,加入成员需要从捐赠者那里获取多少事务,以及是否有任何所需事务在任何组成员的二进制日志文件中已不再存在。如果加入成员与合适捐赠者之间的事务差距较大,或者某些所需事务在任何捐赠者的二进制日志文件中不存在,组复制将开始使用远程克隆操作的分布式恢复。如果事务差距不大,或者克隆插件未安装,组复制将直接从捐赠者的二进制日志进行状态传输。Group Replication automatically selects the best combination of
these methods for state transfer after you issue
START GROUP_REPLICATION on the
joining member. To do this, Group Replication checks which
existing members are suitable as donors, how many transactions the
joining member needs from a donor, and whether any required
transactions are no longer present in the binary log files on any
group member. If the transaction gap between the joining member
and a suitable donor is large, or if some required transactions
are not in any donor's binary log files, Group Replication begins
distributed recovery with a remote cloning operation. If there is
not a large transaction gap, or if the clone plugin is not
installed, Group Replication proceeds directly to state transfer
from a donor's binary log.
在远程克隆操作期间,加入成员上的现有数据将被移除,并替换为捐赠者数据的副本。当远程克隆操作完成且加入成员已重新启动后,将从捐赠者的二进制日志进行状态传输,以获取在远程克隆操作进行期间组应用的事务。During a remote cloning operation, the existing data on the joining member is removed, and replaced with a copy of the donor's data. When the remote cloning operation is complete and the joining member has restarted, state transfer from a donor's binary log is carried out to get the transactions that the group applied while the remote cloning operation was in progress.
在从捐赠者的二进制日志进行状态传输期间,加入成员会从捐赠者的二进制日志复制并应用所需的事务,并在收到事务时立即应用,直到二进制日志记录加入成员加入组的位置(视图更改事件)。在此过程中,加入成员会缓冲组应用的新事务。当从二进制日志的状态传输完成后,加入成员会应用缓冲的事务。During state transfer from a donor's binary log, the joining member replicates and applies the required transactions from the donor's binary log, applying the transactions as they are received, up to the point where the binary log records that the joining member joined the group (a view change event). While this is in progress, the joining member buffers the new transactions that the group applies. When state transfer from the binary log is complete, the joining member applies the buffered transactions.
当加入的成员与小组的所有事务同步时,它被宣布为在线状态,并可以作为普通成员参与小组,分布式恢复完成。When the joining member is up to date with all the group's transactions, it is declared online and can participate in the group as a normal member, and distributed recovery is complete.
从二进制日志进行状态传输是 Group Replication 用于分布式恢复的基本机制,如果您的复制组中的捐赠者和加入成员未设置为支持克隆,这是唯一可用的选项。由于从二进制日志进行状态传输是基于经典异步复制的,如果加入组的服务器完全没有该组的数据,或者其数据来自非常旧的备份镜像,可能需要很长时间。在这种情况下,建议在将服务器添加到组之前,通过传输已在组中的服务器的较新快照来设置其组数据。这可以最大限度地减少分布式恢复所需的时间,并减少对捐赠服务器的影响,因为它们需要保留和传输的二进制日志文件更少。State transfer from the binary log is Group Replication's base mechanism for distributed recovery, and if the donors and joining members in your replication group are not set up to support cloning, this is the only available option. As state transfer from the binary log is based on classic asynchronous replication, it might take a very long time if the server joining the group does not have the group's data at all, or has data taken from a very old backup image. In this situation, it is therefore recommended that before adding a server to the group, you should set it up with the group's data by transferring a fairly recent snapshot of a server already in the group. This minimizes the time taken for distributed recovery, and reduces the impact on donor servers, since they have to retain and transfer fewer binary log files.