书生笔记-mysql binlog Event详解-概述

Binlog是一种二进制格式的文件,理解Binlog二进制格式能够帮助我们进一步理解MySQL的主从复制原理。本文将对Binlog event文件格式进行分析

官方文档:

https://dev.mysql.com/doc/internals/en/binlog-event.html


 

Binlog文件头

Binlog文件,前4个字节固定为一个Magic Number,十六进制值为fe62696e。

[root@localhost logs]# hexdump -Cv mysql-relay-bin.000004 
00000000  fe 62 69 6e df 5d aa 5f  0f 5a 34 00 00 77 00 00  |.bin.]._.Z4..w..|
00000010  00 7b 00 00 00 40 00 04  00 35 2e 37 2e 33 31 2d  |.{[email protected]|
00000020  6c 6f 67 00 00 00 00 00  00 00 00 00 00 00 00 00  |log.............|

源码位置:log_event.h

/* 4 bytes which all binlogs should begin with */
#define BINLOG_MAGIC        "\xfe\x62\x69\x6e"

Binlog event:

Binlog文件除了最前面的4个字节之外,就是一个一个的event,event包含两个部分,event header和event data。通常event header大小固定,event data大小可变。

The events contain the actual data that should be shipped from the master to the slave. Depending on the use, different events are sent.

一,Binlog Management

binlog管理类的event包含:

event里包含了实际的数据,需要传送给从库的,根据用处不同,不同的event类型将被发送。

The first event is either a START_EVENT_V3 or a FORMAT_DESCRIPTION_EVENT while the last event is either a

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值