参数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. # advanced packaging

    目录 advanced packaging ASM NEXX ASMPT完成收購NEXX 準備就緒迎接先進半導體封裝之高速增長 Intro Bumping 产品供应 晶圆溅镀– Apollo 300 ...

  2. Java架构师之路(参考这个学习吧)

  3. leetcode 266.Palindrome Permutation 、267.Palindrome Permutation II

    266.Palindrome Permutation https://www.cnblogs.com/grandyang/p/5223238.html 判断一个字符串的全排列能否形成一个回文串. 能组 ...

  4. nodejs爬虫如何设置动态ip以及userAgent

    nodejs爬虫如何设置动态ip以及userAgent 转https://blog.csdn.net/u014374031/article/details/78833765 前言 在写nodejs爬虫 ...

  5. [转]c++ pthread 多线程简介

    链接:https://blog.csdn.net/u013894427/article/details/83827173 pthread 入口函数类型说明void * func1(void * t)v ...

  6. nodejs 管道判断

    // 不优雅的判断管道判断 let d process.stdin.on('data', chunk => { d = String(chunk) }) setTimeout(() => ...

  7. 安装tensorflow2.0

    pip install tensorflow==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple import tensorflow as tfpri ...

  8. 【tensorflow基础】tensorflow中 tf.reduce_mean函数

    参考 1. tensorflow中 tf.reduce_mean函数: 完

  9. mysql使用yum源安装各个版本的mysql数据库

    每次想用yum安装旧版本的mysql时,发现都找不到mysql的yum安装源,在官网只能找到最新版本mysql的yum源.后来才知道,原来最新的mysql的yum源也是包含了旧版本的mysql的yum ...

  10. mysql instr()函数

    1)instr()函数的格式  (俗称:字符查找函数) 格式一:instr( string1, string2 )    /   instr(源字符串, 目标字符串) 格式二:instr( strin ...