手动创建binary log files和手动编辑binary log index file会有什么影响
2018-01-13 17:34
537 查看
基本环境:官方社区版MySQL 5.7.19
View Code
解析binlog可以在末尾看到Rotate to mysql-bin.9223372036854775808 pos: 4
也就是说再怎么切,也只能切到9223372036854775808,这个文件感觉有点不太正常,不受max_binlog_size限制,解析出的日志莫名不完整~
恢复原始:手工删除 mysql-bin.2147483647 这类大文件,然后修改 mysql-bin.index;或者直接清空logs文件夹,再重新启动数据库服务
High-Level Binary Log Structure and Contents:https://dev.mysql.com/doc/internals/en/binary-log-structure-and-contents.html
Binary Log Versions:https://dev.mysql.com/doc/internals/en/binary-log-versions.html
Event Structure:https://dev.mysql.com/doc/internals/en/event-structure.html
一、了解Binary Log结构
1.1、High-Level Binary Log Structure and Contents
• Binlog包括binary log files和index file
• 每个binary log文件的前4字节是Magic Number,紧接着是一组描述数据修改的Events
• The magic number bytes are 0xfe 0x62 0x69 0x6e = 0xfe 'b''i''n'
• 每个Event包括header bytes和data bytes
header bytes:Event类型,什么时候,由哪个server生成等信息
data bytes:特定的数据修改
• 第一个Event是Description Event,描述文件的格式版本
• 其他Events按照binlog_version(1、3、4)进行记录
• 最后一个Event是Log-rotation Event,指定下一个binary log的文件名称
• index文件里面是当前binary log的一个列表
• 每个binary log文件的前4字节是Magic Number,紧接着是一组描述数据修改的Events
• The magic number bytes are 0xfe 0x62 0x69 0x6e = 0xfe 'b''i''n'
• 每个Event包括header bytes和data bytes
header bytes:Event类型,什么时候,由哪个server生成等信息
data bytes:特定的数据修改
• 第一个Event是Description Event,描述文件的格式版本
• 其他Events按照binlog_version(1、3、4)进行记录
• 最后一个Event是Log-rotation Event,指定下一个binary log的文件名称
• index文件里面是当前binary log的一个列表
1.2、Binary Log结构示意图
[root@ZST1 logs]# mysqlbinlog -v --base64-output=decode-rows mysql-bin.9223372036854775808 /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 #180112 15:57:18 server id 1323308 end_log_pos 123 CRC32 0x798b200f Start: binlog v 4, server v 5.7.19-log created 180112 15:57:18 # Warning: this binlog is either in use or was not closed properly. # at 123 #180112 15:57:18 server id 1323308 end_log_pos 154 CRC32 0xf3252c32 Previous-GTIDs # [empty] # at 154 #180112 15:57:18 server id 1323308 end_log_pos 214 CRC32 0x6054f256 Rotate to mysql-bin.9223372036854775808 pos: 4 SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; DELIMITER ; # End of log file /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; [root@ZST1 logs]#
View Code
解析binlog可以在末尾看到Rotate to mysql-bin.9223372036854775808 pos: 4
也就是说再怎么切,也只能切到9223372036854775808,这个文件感觉有点不太正常,不受max_binlog_size限制,解析出的日志莫名不完整~
恢复原始:手工删除 mysql-bin.2147483647 这类大文件,然后修改 mysql-bin.index;或者直接清空logs文件夹,再重新启动数据库服务
四、参考文档
MySQL binlog后面的编号最大是多大:http://wubx.net/mysql-binlog-max-sequence/High-Level Binary Log Structure and Contents:https://dev.mysql.com/doc/internals/en/binary-log-structure-and-contents.html
Binary Log Versions:https://dev.mysql.com/doc/internals/en/binary-log-versions.html
Event Structure:https://dev.mysql.com/doc/internals/en/event-structure.html
相关文章推荐
- mysql error :Could not find first log file name in binary log index file?
- 'Could not find first log file name in binary log index file'的解决办法
- Could not find first log file name in binary log index file
- 'Could not find first log file name in binary log index file
- MySQL主从error1236:‘Could not find first log file name in binary log index file’处理#Olivia丶长歌#
- 【体系结构】MySQL 日志文件--二进制日志:Binary Log & Binary Log Index
- 做dg时遇到的log_archive_dest、log_archive_dest_1、db_recovery_file_dest之间互相影响
- mysqlbinlog — Utility for Processing Binary Log Files
- php error_log记录日志的使用方法和配置 (日志目录一定要手动创建)
- php error_log记录日志的使用方法和配置 (日志目录一定要手动创建)
- CentOS配置MySQL基于日志点的复制Binary Log File Position Based Replication
- 什么是cookie?js手动创建和存储cookie
- Binary file app.log matches
- innodb_file_per_table是否打开对创建或删除表的影响
- 当spfile、pfile以及init.ora文件丢失时,根据alert_log日志警告文件去创建spfile和pfile文件
- 创建Control Files/Redo Log Files的目录顺序
- 打LOG对机器没什么影响
- 当spfile、pfile以及init.ora文件丢失时,根据alert_log日志警告文件去创建spfile和pfile文件
- Could not find first log file name in binary log
- 用Vue脚手架创建webpack模板后,webStorm卡在scanning files to index