一个同事问我,说他用innobackupex恢复数据后用mysqlbinlog导入增量数据时,发现数据没有导入进去并且也没有报错。

mysqlbinlog /u01/mysql_py/database/mysql3306/logs/mysql-bin.  /u01/mysql_py/database/mysql3306/logs/mysql-bin. --start-position= | mysql -uroot -p

最后发现是因为启动GTID导致,解决方法,添加 --skip-gtids=true参数

mysqlbinlog --skip-gtids=true /u01/mysql_py/database/mysql3306/logs/mysql-bin.  /u01/mysql_py/database/mysql3306/logs/mysql-bin. --start-position=  | mysql -uroot -p
我们先来看一下使用了GTID的数据库binlog解析后是什么样的:

mysqlbinlog -vvv  -bin. >test.sql  

vi test.sql  

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at
# :: server id end_log_pos CRC32 0xfe109258 Start: binlog v , server v 5.6.-enterprise-commercial-advanced-log created ::
BINLOG '
lDaVWA8CAAAAdAAAAHgAAAAAAAQANS42LjI2LWVudGVycHJpc2UtY29tbWVyY2lhbC1hZHZhbmNl
ZC1sb2cAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAViS
EP4=
'/*!*/;
# at
# :: server id end_log_pos CRC32 0xaeaa9a7f Previous-GTIDs
# 6876c0ce-b41e-11e5-a40c-005056b1efab:-
# at
# :: server id end_log_pos CRC32 0xb257069f GTID [commit=yes]
SET @@SESSION.GTID_NEXT= '6876c0ce-b41e-11e5-a40c-005056b1efab:2895702'/*!*/;
# at
# :: server id end_log_pos CRC32 0x2342af31 Query thread_id= exec_time= error_code=
use `test1`/*!*/;
SET TIMESTAMP=/*!*/;
SET @@session.pseudo_thread_id=/*!*/;
SET @@session.foreign_key_checks=, @@session.sql_auto_is_null=, @@session.unique_checks=, @@session.autocommit=/*!*/;
SET @@session.sql_mode=/*!*/;
SET @@session.auto_increment_increment=, @@session.auto_increment_offset=/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=,@@session.collation_connection=,@@session.collation_server=/*!*/;
SET @@session.lc_time_names=/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
DROP TABLE IF EXISTS `test` /* generated by server */
/*!*/;
# at
# :: server id end_log_pos CRC32 0x761a7e8f GTID [commit=yes]
SET @@SESSION.GTID_NEXT= '6876c0ce-b41e-11e5-a40c-005056b1efab:2895703'/*!*/;
# at
# :: server id end_log_pos CRC32 0x8975b5b5 Query thread_id= exec_time= error_code=

##我们发现解析后的binlog文件中每个事物开始前,都执行了SET @@SESSION.GTID_NEXT=操作来执行下一个要执行的GTID。但是这些GTID都已经存在数据库的Executed_Gtid_Set中(因为这些GTID都之前已经在实例上执行过),所以我们执行解析后的binlog文件时,所有的事物都被忽略(已经存在于Executed_Gtid_Set集合中的GTID会跳过)。

在使用GTID时,如果我们想通过解析binlog来恢复数据的话,在使用mysqlbinlog解析binlog日志时需要指定--skip-gtids=true,这样的话解析出来的文件中就不会包含SET @@SESSION.GTID_NEXT=

参考:

GTID binlog解析后导入无效 - CSDN博客
https://blog.csdn.net/shaochenshuo/article/details/54863522

MySQL binlog导入失败的更多相关文章

  1. Mysql文件太大导入失败解决办法总结

    Mysql文件太大导入失败解决办法总结 在使用phpmyadmin导入数据库的时候可能会碰到由于数据库文件太大而无法导入的问题! 英文提示如下:File exceeds the maximum all ...

  2. MySQL Binlog Mixed模式记录成Row格式

    背景: 一个简单的主从结构,主的binlog format是Mixed模式,在执行一条简单的导入语句时,通过mysqlbinlog导出发现记录的Binlog全部变成了Row的格式(明明设置的是Mixe ...

  3. Java实现MySQL数据库导入

    距离上班还有一段时间.现在总结一下如何使用Java语言实现MySQL数据库导入: 首先新建名为test的数据库: 其次执行下面Java代码: import java.io.File; import j ...

  4. [转]mysql binlog in realtime

    原文:http://guweigang.com/blog/2013/11/18/mysql-binlog-in-realtime/ 众所周知,MySQL是最受欢迎的互联网数据库(没有之一)—————— ...

  5. 使用phpExcel向mysql数据库导入excel

    使用phpExcel向mysql数据库导入excel from:http://blog.163.com/dustye_l/blog/static/172439513201242491016834/ 使 ...

  6. Mysql binlog日志解析

    1. 摘要: Mysql日志抽取与解析正如名字所将的那样,分抽取和解析两个部分.这里Mysql日志主要是指binlog日志.二进制日志由配置文件的log-bin选项负责启用,Mysql服务器将在数据根 ...

  7. Windows下命令行连接mysql及导入sql文件

    嗯,今天要把phpcms的模板放到服务器上,,,呃,phpMyAdmin死活连接不上数据库,这又是个神马情况无奈,又想到命令行了,好吧,最近喜欢上命令行了,不过这果然还是命令行强大啊,啊哈哈下面呢,我 ...

  8. 【转载】mysql binlog日志自动清理及手动删除

    说明:当开启mysql数据库主从时,会产生大量如mysql-bin.00000* log的文件,这会大量耗费您的硬盘空间.mysql-bin.000001mysql-bin.000002mysql-b ...

  9. 排查 Maxwell can not find database 并且使用 MySQL binlog 解决相关问题

    目前我们在使用 Maxwell 在读线上机器的 binlog 同步我们的离线数据库. 这次错误定位上,首先线要确定问题是发生在生产者 还是队列 还是消费者.经过查看各机器上任务的运行日志,定位到了问题 ...

随机推荐

  1. UIO,大页内存,CPU亲和性,NUMA机制等

    Linux环境下的UIO(Userspace I/O) UIO 用户空间下驱动程序的支持机制.DPDK使用UIO机制使网卡驱动程序运行在用户态,并采用轮询和零拷贝方式从网卡收取报文,提高收发报文的性能 ...

  2. 团队项目作业五 - 旅游行业App分析

    随着经济的发展,不论是在工作中的男女老少,还是在校园中的童鞋,都喜欢在假期来一场说走就走的旅行,来缓解生活中的各种压力.当然,在国家面临经济转型的情况下,更多的将工业,农业转向服务型的旅游业,各个省市 ...

  3. css实现table中td单元格鼠标悬浮时显示更多内容

    table中,td单元格无法显示下全部内容,需要在鼠标hover时显示全部内容. 正常显示样式: 鼠标hover时: html: <td>displayAddress<span cl ...

  4. delphi xe 的替代者 Lazarus

    Lazarus的设计目标是应用Free Pascal,所以所有凡是Free Pascal能运行的平台,Lazarus都可以运行.最新版本能运行于Linux,Win32和Mac OS.整个界面的外观和操 ...

  5. mybatis之一对一关联

    MapperAsso.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper ...

  6. Make Palindrome CodeForces - 600C(思维)

    A string is called palindrome if it reads the same from left to right and from right to left. For ex ...

  7. 【BZOJ1413】[ZJOI2009]取石子游戏(博弈论,动态规划)

    [BZOJ1413][ZJOI2009]取石子游戏(博弈论,动态规划) 题面 BZOJ 洛谷 题解 神仙题.jpg.\(ZJOI\)是真的神仙. 发现\(SG\)函数等东西完全找不到规律,无奈只能翻题 ...

  8. Python multiprocessing模块的Pool类来代表进程池对象

    #-*-coding:utf-8-*- '''multiprocessing模块提供了一个Pool类来代表进程池对象 1.Pool可以提供指定数量的进程供用户调用,默认大小是CPU的核心数: 2.当有 ...

  9. linux shell重定向

    http://note.youdao.com/noteshare?id=e944e6315d1566b3417e6f59305ddedc

  10. linux c 编程 ------ 获取时间,计算程序执行时间

    #include <time.h> #include <stdio.h> #include <unistd.h> int main(int argc, char a ...