8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

MySQL 8.4 参考手册 / 19 复制 / 19.4 复制解决方案 / 19.4.3 监控基于行的复制
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

19.4.3 监控基于行的复制19.4.3 Monitoring Row-based Replication

当使用基于行的复制时,通过 Performance Schema 仪器阶段监控复制应用程序 (SQL) 线程的当前进度,使您能够跟踪操作的处理情况,并检查已完成的工作量和预估的工作量。当启用这些 Performance Schema 仪器阶段时,events_stages_current 表显示应用线程的阶段及其进度。有关背景信息,请参见 第 29.12.5 节,“Performance Schema 阶段事件表”。The current progress of the replication applier (SQL) thread when using row-based replication is monitored through Performance Schema instrument stages, enabling you to track the processing of operations and check the amount of work completed and work estimated. When these Performance Schema instrument stages are enabled the events_stages_current table shows stages for applier threads and their progress. For background information, see Section 29.12.5, “Performance Schema Stage Event Tables”.

要跟踪所有三种基于行的复制事件类型(写入、更新、删除)的进度:To track progress of all three row-based replication event types (write, update, delete):

  • 通过执行以下命令启用三个 Performance Schema 阶段:Enable the three Performance Schema stages by issuing:

    mysql> UPDATE performance_schema.setup_instruments SET ENABLED = 'YES'
        -> WHERE NAME LIKE 'stage/sql/Applying batch of row changes%';
    
  • 等待一些事件被复制应用线程处理,然后通过查看 events_stages_current 表来检查进度。例如,要获取 update 事件的进度,可以执行:Wait for some events to be processed by the replication applier thread and then check progress by looking into the events_stages_current table. For example to get progress for update events issue:

    mysql> SELECT WORK_COMPLETED, WORK_ESTIMATED FROM performance_schema.events_stages_current
        -> WHERE EVENT_NAME LIKE 'stage/sql/Applying batch of row changes (update)'
    
  • 如果 binlog_rows_query_log_events 已启用,有关查询的信息会存储在二进制日志中,并显示在 processlist_info 字段中。要查看触发此事件的原始查询:If binlog_rows_query_log_events is enabled, information about queries is stored in the binary log and is exposed in the processlist_info field. To see the original query that triggered this event:

    mysql> SELECT db, processlist_state, processlist_info FROM performance_schema.threads
        -> WHERE processlist_state LIKE 'stage/sql/Applying batch of row changes%' AND thread_id = N;