开发者社区> 问答> 正文

canal读取历史binlog异常

mysql8.0.14 canal1.1.3

希望读取旧数据,所以在canal中设置mysql的binlog位置信息 在canal的conf/example/instance.properties中设置binlog开始位置

canal.instance.master.address=192.183.3.109:3306 canal.instance.master.journal.name=mysql-bin.000001 canal.instance.master.position=1

mysql8中输入show master status; 返回

File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000054 | 37254 | | | | +------------------+----------+--------------+------------------+---------------

当我不设置position info的时候,是正常的,如果设置了position info,会报以下异常

2019-04-11 16:20:03.057 [destination = example , address = /192.183.3.109:3306 , EventParser] ERROR c.a.o.canal.parse.inbound.mysql.dbsync.DirectLogFetcher - I/O error while reading from client socket java.io.IOException: Received error packet: errno = 1236, sqlstate = HY000 errmsg = Could not find first log file name in binary log index file at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.DirectLogFetcher.fetch(DirectLogFetcher.java:102) ~[canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection.seek(MysqlConnection.java:144) [canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser.findAsPerTimestampInSpecificLogFile(MysqlEventParser.java:743) [canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser.findPositionWithMasterIdAndTimestamp(MysqlEventParser.java:407) [canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser.findStartPositionInternal(MysqlEventParser.java:452) [canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser.findStartPosition(MysqlEventParser.java:366) [canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.AbstractEventParser$3.run(AbstractEventParser.java:186) [canal.parse-1.1.3.jar:na] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201] 2019-04-11 16:20:03.057 [destination = example , address = /192.183.3.109:3306 , EventParser] ERROR c.a.o.c.p.inbound.mysql.rds.RdsBinlogEventParserProxy - ERROR ## findAsPerTimestampInSpecificLogFile has an error java.io.IOException: Received error packet: errno = 1236, sqlstate = HY000 errmsg = Could not find first log file name in binary log index file at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.DirectLogFetcher.fetch(DirectLogFetcher.java:102) ~[canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection.seek(MysqlConnection.java:144) ~[canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser.findAsPerTimestampInSpecificLogFile(MysqlEventParser.java:743) [canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser.findPositionWithMasterIdAndTimestamp(MysqlEventParser.java:407) [canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser.findStartPositionInternal(MysqlEventParser.java:452) [canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlEventParser.findStartPosition(MysqlEventParser.java:366) [canal.parse-1.1.3.jar:na] at com.alibaba.otter.canal.parse.inbound.AbstractEventParser$3.run(AbstractEventParser.java:186) [canal.parse-1.1.3.jar:na] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201] 2019-04-11 16:20:03.058 [destination = example , address = /192.183.3.109:3306 , EventParser] ERROR c.a.o.c.p.inbound.mysql.rds.RdsBinlogEventParserProxy - dump address /192.183.3.109:3306 has an error, retrying. caused by com.alibaba.otter.canal.parse.exception.CanalParseException: [fixed timestamp] can't found begin/commit position before with fixed positionmysql-bin.000001:1 2019-04-11 16:20:03.058 [destination = example , address = /192.183.3.109:3306 , EventParser] ERROR com.alibaba.otter.canal.common.alarm.LogAlarmHandler - destination:example[com.alibaba.otter.canal.parse.exception.CanalParseException: [fixed timestamp] can't found begin/commit position before with fixed positionmysql-bin.000001:1

原提问者GitHub用户windyyong

展开
收起
古拉古拉 2023-05-08 12:35:46 239 0
2 条回答
写回答
取消 提交回答
  • binlog文件都不存在了,那就没办法

    原回答者GitHub用户agapple

    2023-05-09 17:38:25
    赞同 展开评论 打赏
  • 值得去的地方都没有捷径

    根据报错信息显示,canal在读取历史binlog时,在索引文件中无法获取第一个binlog文件名,所以提示了该异常信息。

    可能的原因是在mysql实例中没有启用binlog或者没有生成任何binlog,或者配置文件中master.position值设置错误导致找不到第一个binlog。建议检查以下几个问题:

    检查MySQL是否启用了binlog 可以执行SHOW BINARY LOGS;查看当前的binlog状态,如果没有binlog则需要先启用binlog。

    检查MySQL binlog文件路径和文件名 确认MySQL的binlog日志文件路径和文件名是否正确,找到对应的第一个binlog文件。

    确认canal中的master.position的设置是否正确 可以使用SHOW MASTER STATUS\G命令来获取当前binlog的名称和位置信息,然后手动设置canal中的master.position参数。

    以上问题解决之后,重新启动canal服务即可检查是否正常读取历史binlog数据。另外,在canal配置文件中,可以增加以下参数用于控制是否读取历史binlog:

    canal.instance.includeBinlogPosition=true

    如果设置为false,则只会读取自启动时间之后的binlog数据。

    2023-05-08 12:49:34
    赞同 1 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
PolarDB-X 2.0 全局 Binlog 与备份恢复能 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载