MySQL Binlog 解析工具 Maxwell 详解 (8)

前面讲过,如果我只想获取某几个表的binlog变更,需要用 include_tables 来过滤,但如果mysql server上现在删了一个表t1,但我的binlog是从昨天开始读取,被删的那个表t1在maxwell启动的时候是拉取不到表结构的。然后昨天的binlog里面有 t1 的变更,因为找不到表结构给来组装成json,会抛异常。

手动在 maxwell.tables/columns 里面插入记录是可行的。但这个问题的根本是,maxwell在binlog过滤的时候,只在处理row_event的时候,而对 tableMapCache 要求binlog里面的所有表都要有。

自己(seanlook)提交了一个commit,可以在做 tableMapCache 的时候也仅要求缓存 include_dbs/tables 这些表: https://github.com/seanlook/maxwell/commit/2618b70303078bf910a1981b69943cca75ee04fb

提高消费性能

在用rabbitmq时,routing_key 是 %db%.%table%,但某些表产生的binlog增量非常大,就会导致各队列消息量很不平均,目前因为还没做到事务xid或者thread_id级别的并发回放,所以最小队列粒度也是表,尽量单独放一个队列,其它数据量小的合在一起。

binlog

Maxwell 在 maxwell 库中维护了 binlog 的位移等信息,由于一些原因譬如 reset master;,导致 maxwell 库中的记录与实际的binlog对不上,这时将报异常,这是可以手动修正binlog位移或者直接清空/删除 maxwell 库重建

com.github.shyiko.mysql.binlog.network.ServerException: Could not find first log file name in binary log index file at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:885) at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:564) at com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:796) at java.lang.Thread.run(Thread.java:748)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wpjggp.html