event(): 'Found invalid event in binary log'

MySQL以简单易用著称,在同一个服务器上可以安装N个不同的版本,方便测试,迁移等等。此外,对于大多数Linux系统,集成了mysql,缺省会被安装。因此多版本的问题导致一些莫名的错误也是时有发生。最近在提取binlog日志时,碰到了一个read_log_event,Found invalid event in binary log。经查发现原来是mysqlbinlog版本问题引发的。如下文,供大家参考。

1、故障描述
[root@HKBO bak]# mysqlbinlog --start-datetime="2014-12-15 00:30:00" mysql-bin.000399bk |more
ERROR: Error in Log_event::read_log_event(): 'Found invalid event in binary log', data_len: 376, event_type: 19
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#141213 21:05:01 server id 11  end_log_pos 120  Start: binlog v 4, server v 5.6.12-log created 141213 21:05:01
# Warning: this binlog is either in use or was not closed properly.
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

2、故障分析与解决
#查看当前是哪一个mysqlbinlog文件
[root@HKBO bak]# which mysqlbinlog
/usr/bin/mysqlbinlog

#查看mysqlbinlog的版本,此时为3.2
[root@HKBO bak]# mysqlbinlog --version
mysqlbinlog Ver 3.2 for RedHat-linux-gnu at x86_64
#Author : Leshami
#Blog  :

[root@HKBO bak]# whereis mysqlbinlog
mysqlbinlog: /usr/bin/mysqlbinlog /usr/share/man/man1/mysqlbinlog.1.gz

#此服务器的安装路径其实质如为/app/soft/mysql/,查看mysqlbinlog的版本为3.4版
[root@HKBO bak]# /app/soft/mysql/bin/mysqlbinlog --version
/app/soft/mysql/bin/mysqlbinlog Ver 3.4 for Linux at x86_64

#下面使用正确路径的mysqlbinlog,此时成功
[root@HKBO bak]# /app/soft/mysql/bin/mysqlbinlog --start-datetime="2014-12-15 00:30:00" mysql-bin.000399bk |more
/*!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 4
#141213 21:05:01 server id 11  end_log_pos 120 CRC32 0xaafb2293        Start: binlog v 4, server v 5.6.12-log created 141213 21:05:01
# Warning: this binlog is either in use or was not closed properly.
BINLOG '
fTmMVA8LAAAAdAAAAHgAAAABAAQANS42LjEyLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAZMi
+6o=
'/*!*/;
# at 594054457

#查看当前系统mysql的版本
# /app/soft/mysql/bin/mysql --version
/app/soft/mysql/bin/mysql  Ver 14.14 Distrib 5.6.12, for Linux (x86_64) using  EditLine wrapper

#以下的为OS安装时缺省安装的版本
# rpm -qa |grep -i mysql
mysql-5.0.95-3.el5

3、小结
a、对于生产环境mysql的部署,建议在安装OS前不安装缺省的mysql或者安装后卸载缺省的mysql
b、因需要存在多版本的情形,应考虑使用直接路径方式来执行相应的mysql命令行工具

--------------------------------------分割线 --------------------------------------

用mysqldump和mysqlbinlog的MySQL数据恢复实验

Ubuntu 14.04下安装MySQL

《MySQL权威指南(原书第2版)》清晰中文扫描版 PDF

Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL

Ubuntu 14.04下搭建MySQL主从服务器

Ubuntu 12.04 LTS 构建高可用分布式 MySQL 集群

Ubuntu 12.04下源代码安装MySQL5.6以及Python-MySQLdb

MySQL-5.5.38通用二进制安装

--------------------------------------分割线 --------------------------------------

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

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