参数binlog-row-event-max-size:
Specify the maximum size of a row-based binary log event, in bytes. Rows are grouped into events smaller than this size if possible. The value should be a multiple of 256. The default is 8192。

Demo:

UPDATE tb001 SET C1=3 LIMIT 10000;
Query OK, 10000 rows affected (0.03 sec)
Rows matched: 10000 Changed: 10000 Warnings: 0 SHOW BINLOG EVENTS;
+------------------+--------+----------------+-----------+-------------+--------------+
| Log_name | Pos | Event_type | Server_id | End_log_pos | Info |
| mysql-bin.000001 | 401 | Update_rows | 168199193 | 8609 | table_id: 219|
| mysql-bin.000001 | 8609 | Update_rows | 168199193 | 16817 | table_id: 219|
| mysql-bin.000001 | 16817 | Update_rows | 168199193 | 25025 | table_id: 219|
| mysql-bin.000001 | 25025 | Update_rows | 168199193 | 33233 | table_id: 219|
| mysql-bin.000001 | 33233 | Update_rows | 168199193 | 41441 | table_id: 219|
| mysql-bin.000001 | 41441 | Update_rows | 168199193 | 49649 | table_id: 219|
| mysql-bin.000001 | 49649 | Update_rows | 168199193 | 57857 | table_id: 219|
| mysql-bin.000001 | 57857 | Update_rows | 168199193 | 66065 | table_id: 219|
| mysql-bin.000001 | 66065 | Update_rows | 168199193 | 74273 | table_id: 219|
| mysql-bin.000001 | 74273 | Update_rows | 168199193 | 82481 | table_id: 219|
| mysql-bin.000001 | 82481 | Update_rows | 168199193 | 90689 | table_id: 219|
| mysql-bin.000001 | 90689 | Update_rows | 168199193 | 98897 | table_id: 219|
| mysql-bin.000001 | 98897 | Update_rows | 168199193 | 107105 | table_id: 219|
| mysql-bin.000001 | 107105 | Update_rows | 168199193 | 115313 | table_id: 219|
| mysql-bin.000001 | 115313 | Update_rows | 168199193 | 123521 | table_id: 219|
| mysql-bin.000001 | 123521 | Update_rows | 168199193 | 131729 | table_id: 219|
| mysql-bin.000001 | 131729 | Update_rows | 168199193 | 139937 | table_id: 219|
| mysql-bin.000001 | 139937 | Update_rows | 168199193 | 148145 | table_id: 219|
| mysql-bin.000001 | 148145 | Update_rows | 168199193 | 156353 | table_id: 219|
| mysql-bin.000001 | 156353 | Update_rows | 168199193 | 164561 | table_id: 219|
| mysql-bin.000001 | 164561 | Update_rows | 168199193 | 172769 | table_id: 219|
| mysql-bin.000001 | 172769 | Update_rows | 168199193 | 180977 | table_id: 219|
| mysql-bin.000001 | 180977 | Update_rows | 168199193 | 181229 | table_id: 219|
+------------------+--------+----------------+-----------+-------------+--------------+

在上面的Demo中,基于ROW模式的复制,更新10000条数据,生产约181K的binlog日志,MySQL将这些日志按照每个最大8K的拆分成23个binlog event,每个binlog event大概包含400-450个行记录的更新日志。

通过mysqlbinlog命令解析binlog文件,能在该事务中发现如下信息:

# at 293
#190514 9:34:23 server id 168199193 end_log_pos 350 CRC32 0x8889b84a Rows_query
# UPDATE tb001 SET C1=3 LIMIT 10000
# at 350
#190514 9:34:23 server id 168199193 end_log_pos 401 CRC32 0xb30edd76 Table_map: `demodb`.`tb001` mapped to number 219
# at 401
#190514 9:34:23 server id 168199193 end_log_pos 8609 CRC32 0x45274f17 Update_rows: table id 219
# at 8609
#190514 9:34:23 server id 168199193 end_log_pos 16817 CRC32 0xb1b6f3b9 Update_rows: table id 219
# at 16817
#190514 9:34:23 server id 168199193 end_log_pos 25025 CRC32 0xfb7c22c2 Update_rows: table id 219
# at 25025
#190514 9:34:23 server id 168199193 end_log_pos 33233 CRC32 0xd3ef86dc Update_rows: table id 219
# at 33233
#190514 9:34:23 server id 168199193 end_log_pos 41441 CRC32 0x031b968c Update_rows: table id 219
# at 41441
#190514 9:34:23 server id 168199193 end_log_pos 49649 CRC32 0x5c0b1de9 Update_rows: table id 219
# at 49649
#190514 9:34:23 server id 168199193 end_log_pos 57857 CRC32 0x6a548038 Update_rows: table id 219
# at 57857
#190514 9:34:23 server id 168199193 end_log_pos 66065 CRC32 0xcd46570c Update_rows: table id 219
# at 66065
#190514 9:34:23 server id 168199193 end_log_pos 74273 CRC32 0x78d5b7e6 Update_rows: table id 219
# at 74273
#190514 9:34:23 server id 168199193 end_log_pos 82481 CRC32 0x8ee1a24c Update_rows: table id 219
# at 82481
#190514 9:34:23 server id 168199193 end_log_pos 90689 CRC32 0x4f3d8afd Update_rows: table id 219
# at 90689
#190514 9:34:23 server id 168199193 end_log_pos 98897 CRC32 0x767a8ad4 Update_rows: table id 219
# at 98897
#190514 9:34:23 server id 168199193 end_log_pos 107105 CRC32 0x8bd1ed97 Update_rows: table id 219
# at 107105
#190514 9:34:23 server id 168199193 end_log_pos 115313 CRC32 0x33840a78 Update_rows: table id 219
# at 115313
#190514 9:34:23 server id 168199193 end_log_pos 123521 CRC32 0x20101fea Update_rows: table id 219
# at 123521
#190514 9:34:23 server id 168199193 end_log_pos 131729 CRC32 0x76f4d551 Update_rows: table id 219
# at 131729
#190514 9:34:23 server id 168199193 end_log_pos 139937 CRC32 0x5a05d397 Update_rows: table id 219
# at 139937
#190514 9:34:23 server id 168199193 end_log_pos 148145 CRC32 0x12fcb52e Update_rows: table id 219
# at 148145
#190514 9:34:23 server id 168199193 end_log_pos 156353 CRC32 0x425a537b Update_rows: table id 219
# at 156353
#190514 9:34:23 server id 168199193 end_log_pos 164561 CRC32 0x8180d65b Update_rows: table id 219
# at 164561
#190514 9:34:23 server id 168199193 end_log_pos 172769 CRC32 0xe913c068 Update_rows: table id 219
# at 172769
#190514 9:34:23 server id 168199193 end_log_pos 180977 CRC32 0x1a2c0483 Update_rows: table id 219
# at 180977
#190514 9:34:23 server id 168199193 end_log_pos 181229 CRC32 0x4e561c1d Update_rows: table id 219 flags: STMT_END_F

对于上千万行的超大事务,可以拆分成通过几千或几万个binlog event,以每个binlog event为单位进行处理,能有效降低超大事务的影响。

==========================================================

对于使用程序解析抽取binlog的业务,由于binlog中记录的是已提交的修改数据,如果不考虑数据一致性或对数据一致性要求较低的场景下,可以考虑将超大事务按照binlog event进行拆分,按照每个binlog event进行事务提交。

==========================================================

MySQL Binlog--基于ROW模式的binlog event大小限制的更多相关文章

  1. MySQL在ROW模式下通过binlog提取SQL语句

    Linux基于row模式的binlog,生成DML(insert/update/delete)的rollback语句通过mysqlbinlog -v 解析binlog生成可读的sql文件提取需要处理的 ...

  2. MySQL基于ROW格式的数据恢复

    大家都知道MySQL Binlog 有三种格式,分别是Statement.Row.Mixd.Statement记录了用户执行的原始SQL,而Row则是记录了行的修改情况,在MySQL 5.6以上的版本 ...

  3. mysql bin-log三种模式

    MySQL的bin-log日志备份有三种模式,分别是:ROW.Statement.Mixed 一.Row 日志会记录成每一行数据被修改成的形式,然后再slave端再对相同的数据进行修改,只记录要修改的 ...

  4. 转载-MySQL binlog三种模式及设置方法

    原文地址:http://www.cnblogs.com/yangliheng/p/6187327.html 1.1 Row Level  行模式 日志中会记录每一行数据被修改的形式,然后在slave端 ...

  5. MySQL binlog三种模式

    1.1 Row Level  行模式 日志中会记录每一行数据被修改的形式,然后在slave端再对相同的数据进行修改 优点:在row level模式下,bin-log中可以不记录执行的sql语句的上下文 ...

  6. MySQ binlog三种模式

    MySQ binlog三种模式及设置方法 1.1 Row Level  行模式 日志中会记录每一行数据被修改的形式,然后在slave端再对相同的数据进行修改 优点:在row level模式下,bin- ...

  7. ROW模式的SQL无法正常同步的问题总结

    转自:http://blog.chinaunix.net/uid-20639775-id-4664792.html#_Toc29623 ROW模式的SQL无法正常同步的问题总结 一. 问题起因.... ...

  8. mysql主从之binlog的工作模式

    一 三种模式介绍 1.1 查看mysql主库的binlog格式 binlog仅在主库设置即可,从库无需设置 binlog的默认方式为STATEMENT ( show variables like '% ...

  9. MySQL Binlog 【ROW】和【STATEMENT】选择(转)

    前言:       二进制日记录了数据库执行更改的操作,如Insert,Update,Delete等.不包括Select等不影响数据库记录的操作,因为没有对数据进行修改.二进制主要的功能有:复制(Re ...

随机推荐

  1. <div> <p> <span>的用法和区别

    <div> 标签可以把文档分割为独立的.不同的部分.它可以用作严格的组织工具,并且不使用任何格式与其关联. 更重要的意义是在网页的动态实现过程中,对划分的区域统一处理,例如换背景色.字体等 ...

  2. ES6新增函数总结和range函数实现

    Array.from  类数组,Set,字符串转为数组 Array.of   不定参数转为数组 Array.prototype.fill(value,[start],[end]) 对数组在指定范围填充 ...

  3. netty-websocket-spring-boot-starter关闭报错 io/netty/channel/AbstractChannel$AbstractUnsafe io/netty/util/concurrent/GlobalEventExecutor

    报错 java.lang.NoClassDefFoundError: io/netty/channel/AbstractChannel$AbstractUnsafe$ at io.netty.chan ...

  4. [LeetCode] 676. Implement Magic Dictionary 实现神奇字典

    Implement a magic directory with buildDict, and search methods. For the method buildDict, you'll be ...

  5. win10查看激活到期时间

    我们知道Windows系统需要激活后才可以使用全部功能,那么你的Windows10激活了吗?如何查看激活时间呢?是不是永久激活的?带着这些问题,下面我们就一个一个逐一查看一下吧. 工具/原料   Wi ...

  6. linux 软连接 ln -s

    <pre>linux 软连接 ln -sln -s /home/ /home/ss/</pre> 按照win的说法就是创建快捷方式在/home/ss/ 文件夹里(名字就是hom ...

  7. Qt5 QtQuick系列----QtQuick的Secne Graph剖析(2)--自定义QML类型 (继承QQuickItem)

    "当下即永恒"  --- 佚名 Qt用户可以方便地使用QML中的Rectangle等基本类型,但是当不够用时,或,需要开发更高级的界面时,可以自己定义QML类型. 自定义QML类型 ...

  8. python3 turtle

    一.turtle 1.操控画笔画图,turtle相当于笔头(x头?),有方向 2.https://docs.python.org/3.6/library/turtle.html 二.移动和绘制 imp ...

  9. Spring中的常用注解

    Spring中的常用注解 1.@Controller 标识一个该类是Spring MVC controller处理器,用来创建处理http请求的对象.

  10. 11 Reponse对象+ServletContext对象

    1.HTTP协议: (1)请求消息:客户端发送给服务器端的数据 数据格式: 1. 请求行 2. 请求头 3. 请求空行 4. 请求体 (2)响应消息:服务器端发送给客户端的数据 * 数据格式: 1. ...