> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-fbfa8bee.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 控制 MySQL ClickPipe 的同步

> 用于控制 MySQL ClickPipe 同步的文档

export const Image = ({img, alt, size}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

本文档介绍如何在 ClickPipe 处于 **CDC (运行中) 模式** 时，对 MySQL ClickPipe 的同步进行控制。

<div id="overview">
  ## 概述
</div>

数据库 ClickPipes 的架构由两个并行流程组成：从源数据库拉取，以及向目标数据库推送。拉取流程由同步配置控制，该配置定义了数据拉取的频率，以及每次拉取的数据量。这里的“每次”指的是一个批次——因为 ClickPipe 是按批次拉取和推送数据的。

控制 MySQL ClickPipe 同步的方式主要有两种。当以下任一设置生效时，ClickPipe 就会开始推送。

<div id="interval">
  ### 同步间隔
</div>

管道的同步间隔，是指 ClickPipe 从源数据库拉取记录的持续时间 (以秒为单位) 。将已拉取的数据推送到 ClickHouse 所花费的时间不计入该间隔。

默认值为 **1 分钟**。
同步间隔可设置为任意正整数值，但建议保持在 10 秒以上。

<div id="batch-size">
  ### 拉取批次大小
</div>

拉取批次大小是指 ClickPipe 单个批次从源数据库拉取的记录数。这里的记录包括对属于该管道的表执行的 insert、update 和 delete 操作。

默认值为 **100,000** 条记录。
安全的最大值为 1000 万。

<div id="transactions">
  ### 一个例外：源端的长时间运行事务
</div>

当源数据库上有事务在运行时，ClickPipe 会一直等待，直到收到该事务的 COMMIT 后才会继续处理。这会**覆盖**同步间隔和拉取批次大小。

<div id="configuring">
  ### 配置同步设置
</div>

您可以在创建 ClickPipe 时设置同步间隔和拉取批次大小，也可以编辑现有 ClickPipe 的这些设置。
创建 ClickPipe 时，这些设置会显示在创建向导的第二步，如下所示：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/kkh98eOd_iRyUp1R/images/integrations/data-ingestion/clickpipes/postgres/create_sync_settings.png?fit=max&auto=format&n=kkh98eOd_iRyUp1R&q=85&s=dbcccdd0f80f4f70e2ad1aea1c9f0124" alt="创建同步设置" size="md" width="902" height="654" data-path="images/integrations/data-ingestion/clickpipes/postgres/create_sync_settings.png" />

编辑现有 ClickPipe 时，前往该管道的 **设置** 选项卡，暂停管道，然后点击此处的 **配置**：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/kkh98eOd_iRyUp1R/images/integrations/data-ingestion/clickpipes/postgres/edit_sync_button.png?fit=max&auto=format&n=kkh98eOd_iRyUp1R&q=85&s=ef8e8adfc27a5c01c7af37fb67a4c3e8" alt="编辑同步按钮" size="md" width="933" height="417" data-path="images/integrations/data-ingestion/clickpipes/postgres/edit_sync_button.png" />

这将打开一个包含同步设置的弹出面板，您可以在其中更改同步间隔和拉取批次大小：

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/kkh98eOd_iRyUp1R/images/integrations/data-ingestion/clickpipes/postgres/sync_settings_edit.png?fit=max&auto=format&n=kkh98eOd_iRyUp1R&q=85&s=fee0afbd90b0b8d88cc66b7ea2342a36" alt="编辑同步设置" size="md" width="598" height="588" data-path="images/integrations/data-ingestion/clickpipes/postgres/sync_settings_edit.png" />

<div id="monitoring">
  ### 监控同步控制的运行情况
</div>

你可以在 ClickPipe 的 **指标** 选项卡中的 **CDC Syncs** 表里查看每个批次的耗时。请注意，这里的耗时既包括推送时间；如果没有新行传入，ClickPipe 会进入等待状态，这段等待时间也会计入耗时。

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/kkh98eOd_iRyUp1R/images/integrations/data-ingestion/clickpipes/postgres/cdc_syncs.png?fit=max&auto=format&n=kkh98eOd_iRyUp1R&q=85&s=d5e8baded42e7b1448e913b86a2374ec" alt="CDC Syncs 表" size="md" width="2428" height="626" data-path="images/integrations/data-ingestion/clickpipes/postgres/cdc_syncs.png" />
