DM 分库分表合并场景

    假设上游库结构如下:

    • 实例 1
    • 实例 2
    • 实例 3
    1. 合并三个实例中的 .information 表至下游 TiDB 中的 user.information 表。
    2. 合并三个实例中的 user.log_{north|south|east} 表至下游TiDB中的 user.log_{north|south|east} 表。
    3. 合并三个实例中的 store_{01|02}.sale_{01|02} 表至下游TiDB中的 store.sale 表。
    4. 过滤掉三个实例的 user.log_{north|south|east} 表的所有删除操作。
    5. 过滤掉三个实例的 user. 表的所有删除操作。
    6. 过滤掉三个实例的 store_{01|02}.sale_{01|02} 表的所有删除操作。
    7. 因为 store_{01|02}.sale_{01|02} 表带有 bigint 型的自增主键,将其合并至 TiDB 时会引发冲突。你需要有相应的方案来避免冲突。

    假设同步后下游库结构如下:

    • 要满足同步需求 #1 和 #2,配置 Table routing 规则 如下:

      1. routes:
      2. ...
      3. store-route-rule:
      4. schema-pattern: "store_*"
      5. target-schema: "store"
      6. sale-route-rule:
      7. schema-pattern: "store_*"
      8. table-pattern: "sale_*"
      9. target-table: "sale"
    • 要满足同步需求 #4 和 #5,配置 如下:

    • 要满足同步需求 #7,配置 Black & white table lists 如下:

    • 要满足同步需求 #8,首先参考来解决冲突,保证在同步到下游时不会因为分表中有相同的主键值而使同步出现异常;然后需要配置 来跳过自增主键冲突的检查:

      1. ignore-checking-items: ["auto_increment_ID"]

    同步任务的完整配置如下。详情请参阅 Data Migration 任务配置文件