文档章节

MySQL binlog之log event

秋风醉了
 秋风醉了
发布于 2016/09/26 16:58
字数 528
阅读 276
收藏 1

MySQL binlog之log event

概述

binlog是mysql以二进制形式打印的日志,它默认不加密,不压缩。每个正常的binlog文件头部,有4个字节的标记,值为0xfe 0x62 0x69 0x6e。LOG_EVENT是binlog里的单位。除去头部的标记,binlog就是一个LOG_EVENT的序列。每个LOG_EVENT都独立单元,没有互相引用的关系,它也有自己的二进制头部,主要是记录了时间戳、类型标记等描述信息。

log event 结构

http://dev.mysql.com/doc/internals/en/event-structure.html

This section describes the general properties of events as byte sequences as they are written to binary or relay log files.

All events have a common general structure consisting of an event header followed by event data:

输入图片说明

The details about what goes in the header and data parts have changed over time, which gives rise to different versions of the binary log format:

  • v1: Used in MySQL 3.23
  • v3: Used in MySQL 4.0.2 though 4.1
  • v4: Used in MySQL 5.0 and up

下面主要看v4 的结构,v4 event structure:

输入图片说明

header length = x bytes
data length = (event_length - x) bytes
fixed data length = y bytes variable data length = (event_length - (x + y)) bytes

x is given by the header_length field in the format description event (FDE). Currently, x is 19, so the extra_headers field is empty.

y is specific to the event type, and is given by the FDE. The fixed-part length is the same for all events of a given type, but may vary for different event types.

The fixed part of the event data is sometimes referred to as the "post-header" part. The variable part is sometimes referred to as the "payload" or "body."

log event type

http://dev.mysql.com/doc/internals/en/event-classes-and-types.html

常见的log event type

QUERY_EVENT
Written when an updating statement is done.
STOP_EVENT
Written when mysqld stops.
ROTATE_EVENT
Written when mysqld switches to a new binary log file. 
This occurs when someone issues a FLUSH LOGS statement or the current binary log file becomes too large. The maximum size is determined by max_binlog_size.
RAND_EVENT
Written every time a statement uses the RAND() function; precedes other events for the statement. Indicates the seed values to use for generating a random number with RAND() in the next statement. This is written only before a QUERY_EVENT and is not used with row-based logging.
XID_EVENT
Generated for a commit of a transaction that modifies one or more tables of an XA-capable storage engine. Normal transactions are implemented by sending a QUERY_EVENT containing a BEGIN statement and a QUERY_EVENT containing a COMMIT statement (or a ROLLBACK statement if the transaction is rolled back).
WRITE_ROWS_EVENT
Used for row-based binary logging. This event logs inserts of rows in a single table.

更多见http://dev.mysql.com/doc/internals/en/event-meanings.html

=====END=====

© 著作权归作者所有

秋风醉了
粉丝 246
博文 543
码字总数 412294
作品 0
朝阳
程序员
私信 提问
Mysql slave error

140109 15:13:13 [Note] Slave: received end packet from server, apparent master shutdown: 140109 15:13:13 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry......

丶永夜
2015/03/13
0
0
MySql Binlog 初识

原文出处:zhaohui Mysql日志 MySQL 的日志包括错误日志(ErrorLog),更新日志(Update Log),二进制日志(Binlog),查询日志(Query Log),慢查询日志(Slow Query Log)等; 更新日志是...

zhaohui
2017/11/20
0
0
MySQL binlog event 详解

我也是只菜鸡,blog写的不对或者不严谨的地方还请大伙指出来,我及时改正,免得误人子弟。 实验环境: CentOS7.3.1611 + MySQL社区版 5.7.19 参考: 小菜鸟DBA的微信公众号推送 官方文档: ...

lirulei90
2018/01/12
0
0
mysql配置文件不生效以及配置同步复制报错“The server is not configured as slave”解决办法

今晚给2台mysql数据库配置主从同步,因为驾轻就熟,所以很快就配置到最后一步了,谁知道执行最后一个命令“slave start”时给我来了个报错“ERROR 1200 (HY000): The server is not configu...

初级泥水工
2014/05/28
0
0
MySQL · 源码分析 · MySQL BINLOG半同步复制数据安全性分析

半同步复制(semisynchronous replication)MySQL使用广泛的数据复制方案,相比于MySQL内置的异步复制它保证了数据的安 全,本文从主机在Server层提交事务开始一直到主机确认收到备机回复进行...

阿里云RDS-数据库内核组
2017/03/08
0
0

没有更多内容

加载失败,请刷新页面

加载更多

八、RabbitMQ的集群原理

集群架构 写在前面 RabbitMQ集群是按照低延迟环境设计的,千万不要跨越WAN或者互联网来搭建RabbitMQ集群。如果一定要在高延迟环境下使用RabbitMQ集群,可以参考使用Shovel和Federation工具。...

XuePeng77
今天
1
0
mac系统下,brew 安装mysql,用终端可以连接,navicat却连接不上?

问题: 1.报错? 2059 - Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(../Frameworks/caching_sha2_password.so, 2): image not found 2.自己通过设置,已经把密......

写bug的攻城狮
昨天
2
0
老生常谈,HashMap的死循环

问题 最近的几次面试中,我都问了是否了解HashMap在并发使用时可能发生死循环,导致cpu100%,结果让我很意外,都表示不知道有这样的问题,让我意外的是面试者的工作年限都不短。 由于HashMap...

群星纪元
昨天
5
0
拉普拉斯算子

拉普拉斯算子是二阶微分算子。 我们知道,一维离散信号一阶微分公式如下: 相应的,一维离散信号二阶微分公式如下: 由于图像有x和y两个方向,因此图像信号属于二维离散信号。其在x,y两个...

yepanl
昨天
3
0
记录"正则表达式"

详细请查看我的博客:https://blog.enjoytoshare.club/article/RegularExpression.html 1 写在前面 正则表达式(Regular Expression)在代码中常常简写为regex。正则表达式通常被用来检索、替...

wugenqiang
昨天
3
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部