8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

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

19.2.3 复制线程19.2.3 Replication Threads

MySQL 的复制功能通过以下类型的线程实现:MySQL replication capabilities are implemented using the following types of threads:

  • 二进制日志传输线程。 当副本连接时,源会创建一个线程将二进制日志内容发送给副本。这个线程可以在源的 SHOW PROCESSLIST 输出中被识别为 Binlog Dump 线程。Binary log dump thread.  The source creates a thread to send the binary log contents to a replica when the replica connects. This thread can be identified in the output of SHOW PROCESSLIST on the source as the Binlog Dump thread.

  • 复制 I/O 接收线程。 当在从服务器上发出 START REPLICA 语句时,从服务器会创建一个 I/O(接收)线程,该线程连接到源服务器,并请求其发送在二进制日志中记录的更新。Replication I/O receiver thread.  When a START REPLICA statement is issued on a replica server, the replica creates an I/O (receiver) thread, which connects to the source and asks it to send the updates recorded in its binary logs.

    复制接收线程读取源服务器的 Binlog Dump 线程发送的更新(见前一项),并将它们复制到组成从服务器中继日志的本地文件中。The replication receiver thread reads the updates that the source's Binlog Dump thread sends (see previous item) and copies them to local files that comprise the replica's relay log.

    该线程的状态在 SHOW REPLICA STATUS 的输出中显示为 Slave_IO_running。The state of this thread is shown as Slave_IO_running in the output of SHOW REPLICA STATUS.

  • 复制 SQL 应用线程。 当 replica_parallel_workers 等于 0 时,副本会创建一个 SQL(应用)线程来读取由复制接收线程写入的中继日志,并执行其中包含的事务。当 replica_parallel_workers 为 N >= 1 时,将有 N 个应用线程和一个协调线程,协调线程按顺序从中继日志中读取事务,并将其调度给工作线程应用。每个工作线程会应用协调线程分配给它的事务。Replication SQL applier thread.  When replica_parallel_workers is equal to 0, the replica creates an SQL (applier) thread to read the relay log that is written by the replication receiver thread and execute the transactions contained in it. When replica_parallel_workers is N >= 1, there are N applier threads and one coordinator thread, which reads transactions sequentially from the relay log, and schedules them to be applied by worker threads. Each worker applies the transactions that the coordinator has assigned to it.

您可以通过将系统变量replica_parallel_workers设置为大于 0 的值,为副本上的任务启用进一步的并行处理。完成此操作后,副本会创建指定数量的工作线程来应用事务,以及一个协调线程,该线程从中继日志中读取事务并分配给工作线程。将replica_parallel_workers(slave_parallel_workers)设置为大于 0 的副本称为多线程副本。如果您使用多个复制通道,每个通道都有使用此变量指定的线程数。You can enable further parallelization for tasks on a replica by setting the system variable replica_parallel_workers to a value greater than 0. When this is done, the replica creates the specified number of worker threads to apply transactions, plus a coordinator thread which reads transactions from the relay log and assigns them to workers. A replica with replica_parallel_workers (slave_parallel_workers) set to a value greater than 0 is called a multithreaded replica. If you are using multiple replication channels, each channel has the number of threads specified using this variable.

NDB 集群也支持多线程副本。有关更多信息,请参见 第 25.7.11 节,“使用多线程应用器的 NDB 集群复制”。Multithreaded replicas are also supported by NDB Cluster. See Section 25.7.11, “NDB Cluster Replication Using the Multithreaded Applier”, for more information.