TiDB Syncer不同表名库名同步且支持pt-osc改表
mysql端库名叫sysbench, 表名sbtest11
tidb端库名ptosc_sysbench,表名ptosc_sbtest11
执行的pt-osc命令
代码语言:javascript复制#pt-online-schema-change --ask-pass --check-interval=1 --no-check-replication-filters --no-check-alter --no-version-check --chunk-size 3 --recursion-method=none --max-load='Threads_running=200' --critical-load='Threads_running=500' --recurse=0 --no-drop-old-table --alter="drop index c" --print h=10.133.x.52,P=3308,u=fanboshi,D=sysbench,t=sbtest11,A=utf8 --execute
正确的syncer配置写法:
代码语言:javascript复制[[replicate-do-table]]
db-name = "ptosc_sysbench"
tbl-name = "ptosc_sbtest11"
[[replicate-do-table]]
db-name = "ptosc_sysbench"
tbl-name = "~.*_sbtest11_new"
[[replicate-do-table]]
db-name = "ptosc_sysbench"
tbl-name = "~.*_sbtest11_old"
[[route-rules]]
pattern-schema = "sysbench"
pattern-table = "sbtest11"
target-schema = "ptosc_sysbench"
target-table = "ptosc_sbtest11"
错误的syncer配置写法:
代码语言:javascript复制[[replicate-do-table]]
db-name = "ptosc_sysbench"
tbl-name = "ptosc_sbtest11"
[[route-rules]]
pattern-schema = "sysbench"
pattern-table = "sbtest11"
target-schema = "ptosc_sysbench"
target-table = "ptosc_sbtest11"
原因:
代码语言:javascript复制pt-osc是通过创建影子表,执行DDL,通过触发器拷贝数据,最后rename表名来实现DDL的。
在同步binlog的时候,需要过程中涉及到把影子表的变更也同步到下游,否则会出现下游执行到对应的binlog报错的情况。
详情请参考原文地址 http://fuxkdb.com/2019/12/12/2019-12-12-TiDB-Syncer不同表名库名同步且支持pt-osc改表/