DM如何过滤某个操作

【 TiDB 使用环境】生产环境
【 TiDB 版本】7.5
目前tidb是作为mysql的从库保存全部数据,dm中如何过滤主库中ALTER TABLE tablename drop PARTITION 命令;

expression-filter: # 定义数据源迁移行变更的过滤规则,可以定义多个规则

过滤 expr_filter.tbl 的 c 为偶数的插入

even_c: # 规则名称
schema: “expr_filter” # 要匹配的上游数据库库名,不支持通配符匹配或正则匹配
table: “tbl” # 要匹配的上游表名,不支持通配符匹配或正则匹配
insert-value-expr: " drop PARTITION " ##yaml文件这里是这样配置吗

TIDB 小白请各位大佬指点

你这个是过滤的DDL语句,应该用这个过滤规则

mysql 和 tidb 很多语法不支持, 比如DDL 这种几乎很少, 我们这生产是手工操作的 。
即使您设置好,不一定好使,毕竟是异构的

是属于ddl 但是应该是alter table xxx drop partition,是不是 要写 events:[“alter table”]

过滤啥, 从库备份好了就行, 主从一致不是更好。

场景是mysql只保留近期生产数据,所有的数据在后端的tidb保留 所以要过滤drop partition操作

可以用truncate table partition,Mysql那边用truncate代替drop。
TiDB Data Migration Binlog 事件过滤 | PingCAP 文档中心

1 个赞

应该不能写alter table,不然你mysql端其他修改表结构的操作就被过滤了。

filters:
rule-1:
schema-pattern: “test_"
​table-pattern: "t_

​events: [“alter table”]
sql-pattern: [*\s+DROP\s+PARTITION"]
​action: Ignore
这样。过滤test_*库t_*表的alter+drop partition操作

1 个赞

使用了这个格式,但是过滤掉了所有的alter table操作 ,其他正常的alter table也被过滤掉了,哪里有问题吗?
block-allow-list: “listA”
filter-rules: [“rule-1”]

黑白名单全局配置,各实例通过配置项名引用。

block-allow-list:
listA: # 名称
ignore-dbs: [“mysql”]
##ignore truncate partition
filters:
rule-1:
schema-pattern: “db1”
table-pattern: “tablename”
events: [“alter table”]
sql-pattern: [“\s+DROP\s+PARTITION”]
action: Ignore