MySQL Binlog--基于ROW模式的binlog event大小限制
参数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大小限制的更多相关文章
- MySQL在ROW模式下通过binlog提取SQL语句
Linux基于row模式的binlog,生成DML(insert/update/delete)的rollback语句通过mysqlbinlog -v 解析binlog生成可读的sql文件提取需要处理的 ...
- MySQL基于ROW格式的数据恢复
大家都知道MySQL Binlog 有三种格式,分别是Statement.Row.Mixd.Statement记录了用户执行的原始SQL,而Row则是记录了行的修改情况,在MySQL 5.6以上的版本 ...
- mysql bin-log三种模式
MySQL的bin-log日志备份有三种模式,分别是:ROW.Statement.Mixed 一.Row 日志会记录成每一行数据被修改成的形式,然后再slave端再对相同的数据进行修改,只记录要修改的 ...
- 转载-MySQL binlog三种模式及设置方法
原文地址:http://www.cnblogs.com/yangliheng/p/6187327.html 1.1 Row Level 行模式 日志中会记录每一行数据被修改的形式,然后在slave端 ...
- MySQL binlog三种模式
1.1 Row Level 行模式 日志中会记录每一行数据被修改的形式,然后在slave端再对相同的数据进行修改 优点:在row level模式下,bin-log中可以不记录执行的sql语句的上下文 ...
- MySQ binlog三种模式
MySQ binlog三种模式及设置方法 1.1 Row Level 行模式 日志中会记录每一行数据被修改的形式,然后在slave端再对相同的数据进行修改 优点:在row level模式下,bin- ...
- ROW模式的SQL无法正常同步的问题总结
转自:http://blog.chinaunix.net/uid-20639775-id-4664792.html#_Toc29623 ROW模式的SQL无法正常同步的问题总结 一. 问题起因.... ...
- mysql主从之binlog的工作模式
一 三种模式介绍 1.1 查看mysql主库的binlog格式 binlog仅在主库设置即可,从库无需设置 binlog的默认方式为STATEMENT ( show variables like '% ...
- MySQL Binlog 【ROW】和【STATEMENT】选择(转)
前言: 二进制日记录了数据库执行更改的操作,如Insert,Update,Delete等.不包括Select等不影响数据库记录的操作,因为没有对数据进行修改.二进制主要的功能有:复制(Re ...
随机推荐
- linux hexdump使用
# hexdump -h hexdump: invalid option -- 'h' Usage: hexdump [options] file... Options: -b one-byte oc ...
- django -xadmin 详解 功能实现及orm 的复习
django 在xadmin中自定义内容的变量及优化汇总 一: 首先下载xadmin pip install git+git://github.com/sshwsfc/xadmin.git@djang ...
- RabbitMQ整合Spring Booot【消费者应答模式】
生产者代码不变,消费者: package com.toov5.Consumer; import java.io.IOException; import java.util.concurrent.Tim ...
- python web开发——django学习(二)orm介绍与model检查
原始是这样连接数据库的: 现在改用django orm (1)先在setting里配置app (2)在modle.py里建model class UserMessage(models.Model): ...
- 调用k8s api遇到CERTIFICATE_VERIFY_FAILED的问题解决方法
前言 python3.5.6版本,django1.1.12版本 最近要调用k8s接口,k8s接口的使用方法请参考官网的说明:戳我 调用k8s接口时,遇到 CERTIFICATE_VERIFY_FAIL ...
- [LeetCode] 437. Path Sum III 路径和 III
You are given a binary tree in which each node contains an integer value. Find the number of paths t ...
- [LeetCode] 557. Reverse Words in a String III 翻转字符串中的单词 III
Given a string, you need to reverse the order of characters in each word within a sentence while sti ...
- Java之Java程序的基本结构
Java的基本结构是 /** * 可以用来自动创建文档的注释 */ public class Hello { public static void main(String[] args) { // 向 ...
- nrm -- npm镜像源管理
nrm nrm(npm registry manager )是npm的镜像源管理工具,有时候国外资源太慢,使用这个就可以快速地在 npm 源间切换 安装nrm 在命令行执行命令,npm install ...
- 安装hbase分布式集群出现的报错- ERROR:org.apache.hadoop.hbase.PleaseHoldException: Master is initializing
可能的原因如下: 1. 时间没有同步 HBase需要结点间的时间必须是同步的,可以使用date命令在Linux查看时间(同步时间命令:ntpdate 1.cn.pool.ntp.org) 2. 底层采 ...