MySQL mysqlbinlog 讀取mysql-bin文件出錯

問題html

mysqlbinlog -v -v --base64-output=DECODE-ROWS mysql-bin.000166 | lessmysql

ERROR: Error in Log_event::read_log_event(): 'Found invalid event in binary log', data_len: 111, event_type: 35
/*!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
#190408 18:15:19 server id 311948559  end_log_pos 123 CRC32 0x56e12e5d  Start: binlog v 4, server v 5.7.21-log created 190408 18:15:19
# Warning: this binlog is either in use or was not closed properly.
BINLOG '
Nx+rXA8P9ZcSdwAAAHsAAAABAAQANS43LjIxLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA
AV0u4VY=
'/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

查看當前使用的mysqlbinlog文件位置linux

which mysqlbinlog /usr/bin/mysqlbinlogsql

ll /usr/bin/mysqlbinlog -rwxr-xr-x 1 root root 3259000 6月 10 2014 /usr/bin/mysqlbinlog 該myqlbinlog在2014年就已經存在了,推測是該機器中自帶的mariadb中的session

版本信息less

/usr/bin/mysqlbinlog --version /usr/bin/mysqlbinlog Ver 3.3 for Linux at x86_64 /usr/bin/mysqlbinlog Ver 3.3 for Linux at x86_64 Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.socket

Dumps a MySQL binary log in a format usable for viewing or for piping to the mysql command line client.this

查看當前運行的mysqld進程basedircode

ps -ef | grep defaults | grep 3308 | awk '{print $8}' /opt/mysql/base/5.7.21/bin/mysqldorm

版本信息

/opt/mysql/base/5.7.21/bin/mysqlbinlog -V /opt/mysql/base/5.7.21/bin/mysqlbinlog Ver 3.4 for linux-glibc2.12 at x86_64

刪除原可執行文件mysqlbinlog,從新創建軟連接

rm -r /usr/bin/mysqlbinlog rm:是否刪除普通文件 "/usr/bin/mysqlbinlog"?y

ln -s /opt/mysql/base/5.7.21/bin/mysqlbinlog /usr/bin

可正常使用

mysqlbinlog -v -v --base64-output=DECODE-ROWS mysql-bin.000166 | less

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#190408 18:15:19 server id 311948559  end_log_pos 123 CRC32 0x56e12e5d  Start: binlog v 4, server v 5.7.21-log created 190408 18:15:19
# Warning: this binlog is either in use or was not closed properly.
# at 123

老版本mysql可執行文件卻能正常運行

ll /usr/bin/mysql -rwxr-xr-x 1 root root 3546584 6月 10 2014 /usr/bin/mysql

mysql --version mysql Ver 15.1 Distrib 5.5.35-MariaDB, for Linux (x86_64) using readline 5.1

/opt/mysql/base/5.7.21/bin/mysql -uroot -p --socket=/datas/mysql/data/3308/mysqld.sock -e"select version()" Enter password: +------------+ | version() | +------------+ | 5.7.21-log | +------------+

結論

  • 出現 ERROR: Error in Log_event::read_log_event(): 'Found invalid event in binary log', data_len: 111, event_type: 35 錯誤是因爲當前使用的myqlbinlog可執行文件的版本和正在運行的mysqld進程basedir中mysqlbinlog的版本不一致致使的(版本低不能正常讀取高版本的mysqld產生的mysql-bin文件,產生的mysql-bin文件有event老版本的myqlbinlog不能正常讀取)

  • 低版本的mysql可執行文件能正常登錄高版本的mysqld

原文出處:https://www.cnblogs.com/YangJiaXin/p/10686151.html

相關文章
相關標籤/搜索