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 : http://blog.csdn.net/leshami
[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命令行工具
--转自
该贴由koei123转至本版2015-6-1 14:57:08