一、TABLE_MAP_EVENT

Used for row-based binary logging beginning with MySQL 5.1.5.The TABLE_MAP_EVENT defines the structure if the tables that are about to be changed.

用于从MySQL 5.1.5开始的基于行的二进制日志记录。每个ROW_EVENT之前都有一个TABLE_MAP_EVENT,用于描述表的内部ID和结构定义。

1)触发条件

    # ROW格式中每个ROW_EVENT之前

2)存储格式

1、事件头,占用19个字节。
2、事件体部分:
固定数据部分:
# table id:6 bytes //6个字节存储table id
# 2 bytes:Reserved for future use //2个字节保留未来使用 可变数据部分:
# 1 byte. The length of the database name. //数据库名长度:1字节
# Variable-sized. The database name (null-terminated). //数据库名:可变长度
# 1 byte. The length of the table name. //表长度:1字节
# Variable-sized. The table name (null-terminated). //表名:可变长度
# Packed integer. The number of columns in the table. //表的行数:
# Variable-sized. An array of column types, one byte per column. To find the meanings of these values, look at enum_field_types in the mysql_com.h header file. //列类型数组,每一列1个字节
# Packed integer. The length of the metadata block. //元数据块的长度
# Variable-sized. The metadata block; see log_event.h for contents and format. //元数据块
# Variable-sized. Bit-field indicating whether each column can be NULL, one bit per column. For this field, the amount of storage required for N columns is INT((N+7)/8) bytes. //位字段,指示每个列是否可以为空,每个列一位。如果表有N列,需要:INT((N+7)/8) 字节

3)实战分析

结合hexdump出来的数据和mysqlbinlog解析出的日志进行分析:

-------公有事件头--------
1、timestamp(4): 21 2e 0e 5b
2、event_type(1):13,十进制19:TABLE_MAP_EVENT = 19
3、server id(4):5c 27 6b 94 十进制:2490050396
4、event size(4):2e 00 00 00,十进制:46
5、log_pos(4):aa 01 00 00 ,十进制:426 也就是end_log_pos=426
6、flags(2):00 00,等于0表示该日志文件关闭状态 --------固定数据部分(私有事件头)-----
1、table id(6):b1 01 00 00 00 00,十进制433,table_id=433
2、reserve(2):01 00,十进制:1,未被使用 ---------可变数据部分(事件体)--------
3、db name len(1):06,数据库名占用6个字节,即darren
4、db name(6):64 61 72 72 65 6e,查询asci码,对应darren
5、00
6、table name len(1):01,表名占用1个字节
7、table name(1):74,asci码对应字母t,即表名是t
8、00
9、column count(1):01,即列的个数1
10、column type(1):03,表示MYSQL_TYPE_LONG
11、column metadata len(1):00,1个字节
12、column metadata:无
13、null bitmap(1):00,0表没有列可以为NULL,如果是01表示该列可以为NULL
14、crc32(4):8f cb 07 7d,代表CRC32=0x7d07cb8f,不在事件体里,可以认为每个事件都存在footer

MySQL Binlog解析(2)的更多相关文章

  1. MySQL Binlog 解析工具 Maxwell 详解

    maxwell 简介 Maxwell是一个能实时读取MySQL二进制日志binlog,并生成 JSON 格式的消息,作为生产者发送给 Kafka,Kinesis.RabbitMQ.Redis.Goog ...

  2. mysql binlog解析概要

    1,dump协议: 根据数据库的ip+port创建socket,如果创建成功,说明链接建立成功,接下来是使用dump协议订阅binlog 链接建立成功之后,服务端会主动向客户端发送如下问候信息gree ...

  3. MySQL Binlog解析

    https://yq.aliyun.com/articles/238364?spm=5176.8067842.tagmain.52.73PjU3 摘要: 概述 MySQL的安装可以参考:Linux(C ...

  4. MySQL Binlog解析(1)

    一.Binlog File Binlog files start with a Binlog File Header followed by a series of Binlog Event Binl ...

  5. 采用OpenReplicator解析MySQL binlog

    Open Replicator是一个用Java编写的MySQL binlog分析程序.Open Replicator 首先连接到MySQL(就像一个普通的MySQL Slave一样),然后接收和分析b ...

  6. MySQL Binlog 介绍

    Binlog 简介 MySQL中一般有以下几种日志: 日志类型 写入日志的信息 错误日志 记录在启动,运行或停止mysqld时遇到的问题 通用查询日志 记录建立的客户端连接和执行的语句 二进制日志 记 ...

  7. MySQL binlog的格式解析

    我搜集到了一些资料,对理解代码比较有帮助. 在头文件中binlog_event.h中,有描述 class Log_event_header class Log_event_footer 参见[Myst ...

  8. Mysql binlog日志解析

    1. 摘要: Mysql日志抽取与解析正如名字所将的那样,分抽取和解析两个部分.这里Mysql日志主要是指binlog日志.二进制日志由配置文件的log-bin选项负责启用,Mysql服务器将在数据根 ...

  9. 腾讯工程师带你深入解析 MySQL binlog

    欢迎大家前往云+社区,获取更多腾讯海量技术实践干货哦~ 本文由 腾讯云数据库内核团队 发布在云+社区 1.概述 binlog是Mysql sever层维护的一种二进制日志,与innodb引擎中的red ...

随机推荐

  1. 使用Using的注意事项

    参数传递 C#中有四种参数类型:值类型,Ref参数,Out参数,params参数.默认参数都是以传值方式传递,这意味着方法中的变量会在内存中被分配新的存储空间,并赋值.对于引用类型,这种传值意味着传递 ...

  2. jvm之 国际酒店 一次报表 load数据死循环导致的FULLGC

    从目前这几天的运行情况看,每天晚上0点到3点,应该是你们那边有大数据任务处理,在这个时间段,SOA会频繁报ZK断开重联的告警,见下图.   类似的问题,在CRM系统上也有出现过,我们dump内存,分析 ...

  3. springside4

    https://github.com/springside/springside4/wiki/Design Design 1. Web MVC Framwork: SpringMVC3.0 Restf ...

  4. [hihoCoder] 拓扑排序·一

    The hints of the problem has given detailed information to implement the topological sorting algorit ...

  5. mongodb3.0+ 版本内置数据压缩

    mongodb3+版本之后支持zlib和snappy. 创建压缩的集合 db.createCollection( "email", {storageEngine:{wiredTig ...

  6. Oracle Schema Objects——Tables——TableType

    Oracle Schema Objects Object Tables object type An Oracle object type is a user-defined type with a ...

  7. iOS微信打开App

    传统的方式是通过URL Scheme的方式,但是iOS9以后又出了新的更完美的方式Universal Links. 传统的URL Scheme方式微信内置的浏览器都是封锁了所有它投资的公司之外的,只有 ...

  8. 综合: Java 对象初始化过程

    class Fu { Fu() { show(); } void show() { System.out.println("xixi"); } } class Zi extends ...

  9. TCP的3次握手和四次挥手,请画图说明流程

    TCP 三次握手 TCP 四次挥手  

  10. SQL Server中行列转换 Pivot UnPivot

    PIVOT用于将列值旋转为列名(即行转列),在SQLServer 2000可以用聚合函数配合CASE语句实现 PIVOT的一般语法是:PIVOT(聚合函数(列)FOR 列 in (-) )AS P 完 ...