canal icon indicating copy to clipboard operation
canal copied to clipboard

MySQL同步到MySQL修改库名,canal-adapter如何配置dbMapping

Open sgjr opened this issue 1 year ago • 3 comments

Question

canal版本

1.1.7

问题描述

  • 想要增量同步test0718库的数据到改名的库test0723中,如何写dbMapping配置, 目前只要指定表名才能正常同步,配置如下:
concurrent: true
dataSourceKey: demoSyncDS
destination: test-1721045534
groupId: g1
outerAdapterKey: mysql0
dbMapping:
  commitBatch: 3000
  database: test0718
  targetDb: test0723
  table: t1
  targetTable: t1
  mapAll: true
  targetPk:
    id: id

  • 尝试了以下好几种配置都不行,以下是错误配置

错误配置1:

concurrent: true
dataSourceKey: demoSyncDS
destination: test-1721045534
groupId: g1
outerAdapterKey: mysql0
dbMapping:
  commitBatch: 3000
  database: test0718
  targetDb: test0723

错误配置2

concurrent: true
dataSourceKey: demoSyncDS
destination: test-1721045534
groupId: g1
outerAdapterKey: mysql0
dbMapping:
  commitBatch: 3000
  database: test0718
  targetDb: test0723
  table: *
  targetTable: *

sgjr avatar Jul 23 '24 12:07 sgjr

建议用mirror模式,数据库也同名

xiaobai1017 avatar Aug 01 '24 08:08 xiaobai1017

@xiaobai1017 多对1的场景、用途不一样经常是不同库名

jiugem avatar Aug 07 '24 08:08 jiugem

目前是全库映射配置后,只能映射schema, 但数据同步不了

dantanqikun avatar Aug 15 '24 08:08 dantanqikun