温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

解析MySQL binlog --(2)FORMAT_DESCRIPTION_EVENT

发布时间:2020-07-04 17:36:00 来源:网络 阅读:12427 作者:yzs的专栏 栏目:MySQL数据库

该格式描述事件时binlog version 4中为了取代之前版本的START_EVENT_3事件而引入的。是binlog文件的第一个事件,并在一个binlog文件中仅出现一次。具体定义:
解析MySQL binlog --(2)FORMAT_DESCRIPTION_EVENT
binlog-version:binlog版本
mysql-server version:服务器版本
create timestamp:指明binlog文件的创建时间。如果该binlog是由于切换产生,那么该字段是0
event header length:189
event type header lengths:记录所有事件的私有事件头的长度,event的个数定义5.6,5.7为40个,也就是40个字节

[mysql26@localhost data]$ hexdump -Cv mysql-bin.000002 > 2.txt  
[mysql26@localhost data]$ vi 2.txt  

00000000  fe 62 69 6e 46 c4 a4 5a  0f 0b 00 00 00 74 00 00  |.binF..Z.....t..|  
00000010  00 78 00 00 00 01 00 04  00 35 2e 36 2e 32 36 2d  |.x.......5.6.26-|  
00000020  64 65 62 75 67 2d 6c 6f  67 00 00 00 00 00 00 00  |debug-log.......|  
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|  
00000040  00 00 00 00 00 00 00 00  00 00 00 46 c4 a4 5a 13  |...........F..Z.|  
00000050  38 0d 00 08 00 12 00 04  04 04 04 12 00 00 5c 00  |8.............\.|  
00000060  04 1a 08 00 00 00 08 08  08 02 00 00 00 0a 0a 0a  |................|  
00000070  19 19 00 01 c8 a1 c5 19  62 c4 a4 5a 02 0b 00 00  |........b..Z....|  
00000080  00 47 00 00 00 bf 00 00  00 08 00 01 00 00 00 00  |.G..............|  
00000090  00 00 00 03 00 00 1a 00  00 00 00 00 00 01 00 00  |................|  
000000a0  00 40 00 00 00 00 06 03  73 74 64 04 21 00 21 00  |.@......std.!.!.|  
000000b0  21 00 79 7a 73 00 42 45  47 49 4e 30 85 8c ba 62  |!.yzs.BEGIN0...b|  
000000c0  c4 a4 5a 13 0b 00 00 00  2d 00 00 00 ec 00 00 00  |..Z.....-.......|  
000000d0  00 00 46 00 00 00 00 00  01 00 03 79 7a 73 00 02  |..F........yzs..|  

分析:

1、开头4个字节binlog magic number:fe 62 69 6e,即.bin

2、第一个binlog事件是FORMAT_DESCRIPTION_EVENT。

3、timestamp: 46 c4 a4 5a,即小端显示0x5aa4c446,十进制1520747590,
[mysql26@localhost data]$ date -d "@1520747590"
Sat Mar 10 21:53:10 PST 2018

binlog解析的时间是:#180310 21:53:10 server id 11 end_log_pos 120 CRC32 0x19c5a1c8 Start: binlog v 4, server v 5.6.26-debug-log created 180310 21:53:10 at startup
3、event type:0f,即15

5、server-id:0b 00 00 00,即小端显示0x00 00 00 0b,即为11

6、event size:74 00 00 00:0x 00 00 00 74,116。120-4(.bin)

7、next-log pos:78 00 00 00:0x00 00 00 78,120,下一个event的位置,相对文件头位置,和end_log_pos 120一致

8、flag:01 00;为0X0001那么会在MYSQLBINLOG输出中报一个警告说本binlog没有关闭

9、binlog version:04 00,小端显示及0X0004,和mysqlbinlog中的解析Start: binlog v 4一致

10、mysql server version:5.6.26-debug-log,剩下的字节0填充

00000010                              35 2e 36 2e 32 36 2d  |.x.......5.6.26-|  
00000020  64 65 62 75 67 2d 6c 6f  67 00 00 00 00 00 00 00  |debug-log.......|  
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|  
00000040  00 00 00 00 00 00 00 00  00 00 00   

11、create stamp:46 c4 a4 5a,和event头一样

12、event header length:13,即19字节

13、event header lengths:array[30]-[32]:0a 0a 0a,表示 WRITE_ROWS_EVENT = 30,UPDATE_ROWS_EVENT = 31, DELETE_ROWS_EVENT = 32的私有事件头长度

00000050  38 0d 00 08 00 12 00 04  04 04 04 12 00 00 5c 00  |8.............\.|  
00000060  04 1a 08 00 00 00 08 08  08 02 00 00 00 0a 0a 0a  |................|  
00000070  19 19 00 01 c8 a1 c5 19  

参考:http://blog.itpub.net/7728585/viewspace-2133189/

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI