当使用基于行的复制时,通过 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 theevents_stages_currenttable. For example to get progress forupdateevents 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字段中。要查看触发此事件的原始查询:Ifbinlog_rows_query_log_eventsis enabled, information about queries is stored in the binary log and is exposed in theprocesslist_infofield. 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;