mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
Created FAQ (markdown)
27
FAQ.md
Normal file
27
FAQ.md
Normal file
@@ -0,0 +1,27 @@
|
||||
问1:INSERT/UPDATE/DELETE被解析为Query或DDL语句?
|
||||
答1:
|
||||
出现这类情况主要原因为收到的binlog就为Query事件,比如:
|
||||
1. binlog格式为非row模式,通过show variables like 'binlog\_format'可以查看. 针对statement/mixed模式,DML语句都会是以SQL语句存在
|
||||
2. mysql5.6+之后,在binlog为row模式下,针对DML语句通过一个开关(binlog-rows-query-log-events=true),记录DML的原始SQL,对应binlog事件为RowsQueryLogEvent,同时也有对应的row记录. ps. canal可以通过properties设置来过滤:canal.instance.filter.query.dml = true
|
||||
|
||||
|
||||
|
||||
问2:设置了数据表的过滤条件,但貌似没有生效?
|
||||
答2:
|
||||
1. 首先看文档[AdminGuide](AdminGuide),了解<span data-type="color" style="color:rgb(36, 41, 46)"><span data-type="background" style="background-color:rgb(255, 255, 255)">canal.instance.filter.regex的书写格式</span></span>
|
||||
```plain
|
||||
mysql 数据解析关注的表,Perl正则表达式.
|
||||
多个正则之间以逗号(,)分隔,转义符需要双斜杠(\\)
|
||||
常见例子:
|
||||
1. 所有表:.* or .*\\..*
|
||||
2. canal schema下所有表: canal\\..*
|
||||
3. canal下的以canal打头的表:canal\\.canal.*
|
||||
4. canal schema下的一张表:canal.test1
|
||||
5. 多个规则组合使用:canal\\..*,mysql.test1,mysql.test2 (逗号分隔)
|
||||
```
|
||||
2. 检查binlog格式,过滤条件只针对row模式的数据有效(ps. mixed/statement因为不解析sql,所以无法准确提取tableName进行过滤)
|
||||
3. 检查下CanalConnector是否调用subscribe(filter)方法;有的话,filter需要和instance.properties的canal.instance.filter.regex一致,否则subscribe的filter会覆盖instance的配置,如果subscribe的filter是.\*\\..\*,那么相当于你消费了所有的更新数据 <span data-type="color" style="color:#F5222D">【特别注意】</span>
|
||||
4. 检查一下[历史的issue列表](https://github.com/alibaba/canal/issues?utf8=%E2%9C%93&q=subscribe),很有可能你的提问别人已经遇到过并解决了,比如表达式不对,特别是双斜杠的问题
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user