【MySQL】binlog_format以及binlog事务记录分析
MySQL官方对于binlog_format参数的说明:
http://dev.mysql.com/doc/refman/5.5/en/binary-log-setting.html
binlog_format可以动态修改,官网对于动态修改主库配置时提醒谨慎操作,会导致复制关系异常。
【主库flush logs,binlog_format='STATEMENT'】
【从库flush logs,binlog_format='MIXED'】
- 【主库】
- # at 107
- #140919 14:17:50 server id 16024 end_log_pos 178 Query thread_id=13 exec_time=0 error_code=0
- SET TIMESTAMP=1411107470/*!*/;
- BEGIN
- /*!*/;
- # at 178
- #140919 14:17:50 server id 16024 end_log_pos 281 Query thread_id=13 exec_time=0 error_code=0
- use jiangxu/*!*/;
- SET TIMESTAMP=1411107470/*!*/;
- delete from t1 where c1 in (50,51,52)
- /*!*/;
- # at 281
- #140919 14:17:50 server id 16024 end_log_pos 353 Query thread_id=13 exec_time=0 error_code=0
- SET TIMESTAMP=1411107470/*!*/;
- COMMIT/*!*/;
- 【从库】
- # at 107
- #140919 14:17:50 server id 16024 end_log_pos 178 Query thread_id=13 exec_time=253 error_code=0
- SET TIMESTAMP=1411107470/*!*/;
- BEGIN
- /*!*/;
- # at 178
- #140919 14:17:50 server id 16024 end_log_pos 281 Query thread_id=13 exec_time=253 error_code=0
- use `jiangxu`/*!*/;
- SET TIMESTAMP=1411107470/*!*/;
- delete from t1 where c1 in (50,51,52)
- /*!*/;
- # at 281
- #140919 14:17:50 server id 16024 end_log_pos 353 Query thread_id=13 exec_time=253 error_code=0
- SET TIMESTAMP=1411107470/*!*/;
- COMMIT/*!*/;
【主库flush logs,binlog_format='MIXED'】
【从库flush logs,binlog_format='MIXED'】
- 【主库】
- # at 107
- #140919 14:28:52 server id 16024 end_log_pos 178 Query thread_id=1 exec_time=0 error_code=0
- SET TIMESTAMP=1411108132/*!*/;
- BEGIN
- /*!*/;
- # at 178
- #140919 14:28:52 server id 16024 end_log_pos 281 Query thread_id=1 exec_time=0 error_code=0
- use jiangxu/*!*/;
- SET TIMESTAMP=1411108132/*!*/;
- delete from t1 where c1 in (40,41,42)
- /*!*/;
- # at 281
- #140919 14:28:52 server id 16024 end_log_pos 308 Xid = 14
- COMMIT/*!*/;
- 【从库】
- # at 353
- #140919 14:28:52 server id 16024 end_log_pos 412 Query thread_id=1 exec_time=253 error_code=0
- SET TIMESTAMP=1411108132/*!*/;
- BEGIN
- /*!*/;
- # at 412
- #140919 14:28:52 server id 16024 end_log_pos 515 Query thread_id=1 exec_time=253 error_code=0
- SET TIMESTAMP=1411108132/*!*/;
- delete from t1 where c1 in (40,41,42)
- /*!*/;
- # at 515
- #140919 14:28:52 server id 16024 end_log_pos 542 Xid = 25540
- COMMIT/*!*/;
【主库flush logs,binlog_format='ROW'】
【从库flush logs,binlog_format='MIXED'】
- 【主库】
- # at 107
- #140919 14:41:21 server id 16024 end_log_pos 178 Query thread_id=1 exec_time=0 error_code=0
- SET TIMESTAMP=1411108881/*!*/;
- BEGIN
- /*!*/;
- # at 178
- # at 225
- #140919 14:41:21 server id 16024 end_log_pos 225 Table_map: `jiangxu`.`t1` mapped to number 33
- #140919 14:41:21 server id 16024 end_log_pos 275 Delete_rows: table id 33 flags: STMT_END_F
- ### DELETE FROM jiangxu.t1
- ### WHERE
- ### @1=30 /* INT meta=0 nullable=0 is_null=0 */
- ### @2='a' /* VARSTRING(15) meta=15 nullable=1 is_null=0 */
- ### DELETE FROM jiangxu.t1
- ### WHERE
- ### @1=31 /* INT meta=0 nullable=0 is_null=0 */
- ### @2='a' /* VARSTRING(15) meta=15 nullable=1 is_null=0 */
- ### DELETE FROM jiangxu.t1
- ### WHERE
- ### @1=32 /* INT meta=0 nullable=0 is_null=0 */
- ### @2='a' /* VARSTRING(15) meta=15 nullable=1 is_null=0 */
- # at 275
- #140919 14:41:21 server id 16024 end_log_pos 302 Xid = 13
- COMMIT/*!*/;
- 【从库】
- # at 542
- #140919 14:41:21 server id 16024 end_log_pos 601 Query thread_id=1 exec_time=253 error_code=0
- SET TIMESTAMP=1411108881/*!*/;
- BEGIN
- /*!*/;
- # at 601
- # at 648
- #140919 14:41:21 server id 16024 end_log_pos 648 Table_map: `jiangxu`.`t1` mapped to number 1168
- #140919 14:41:21 server id 16024 end_log_pos 698 Delete_rows: table id 1168 flags: STMT_END_F
- ### DELETE FROM `jiangxu`.`t1`
- ### WHERE
- ### @1=30 /* INT meta=0 nullable=0 is_null=0 */
- ### @2='a' /* VARSTRING(15) meta=15 nullable=1 is_null=0 */
- ### DELETE FROM `jiangxu`.`t1`
- ### WHERE
- ### @1=31 /* INT meta=0 nullable=0 is_null=0 */
- ### @2='a' /* VARSTRING(15) meta=15 nullable=1 is_null=0 */
- ### DELETE FROM `jiangxu`.`t1`
- ### WHERE
- ### @1=32 /* INT meta=0 nullable=0 is_null=0 */
- ### @2='a' /* VARSTRING(15) meta=15 nullable=1 is_null=0 */
- # at 698
- #140919 14:41:21 server id 16024 end_log_pos 725 Xid = 25542
- COMMIT/*!*/;
- DELIMITER ;
- # End of log file
- ROLLBACK /* added by mysqlbinlog */;
- /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
【主库flush logs,binlog_format='MIXED'】
【从库flush logs,binlog_format='ROW'】
- 注意动态修改从库binlog_format因为原session是MIXED,所以需要重建复制关系线程。
【主库】- # at 554
- #140919 16:44:50 server id 16024 end_log_pos 625 Query thread_id=3 exec_time=0 error_code=0
- SET TIMESTAMP=1411116290/*!*/;
- BEGIN
- /*!*/;
- # at 625
- #140919 16:44:50 server id 16024 end_log_pos 728 Query thread_id=3 exec_time=0 error_code=0
- SET TIMESTAMP=1411116290/*!*/;
- delete from t1 where c1 in (13,14,15)
- /*!*/;
- # at 728
- #140919 16:44:50 server id 16024 end_log_pos 755 Xid = 44
- COMMIT/*!*/;
- 【从库】
- # at 296
- #140919 16:44:50 server id 16024 end_log_pos 355 Query thread_id=3 exec_time=253 error_code=0
- SET TIMESTAMP=1411116290/*!*/;
- BEGIN
- /*!*/;
- # at 355
- # at 402
- #140919 16:44:50 server id 16024 end_log_pos 402 Table_map: `jiangxu`.`t1` mapped to number 1168
- #140919 16:44:50 server id 16024 end_log_pos 452 Delete_rows: table id 1168 flags: STMT_END_F
- ### DELETE FROM `jiangxu`.`t1`
- ### WHERE
- ### @1=13 /* INT meta=0 nullable=0 is_null=0 */
- ### @2='a' /* VARSTRING(15) meta=15 nullable=1 is_null=0 */
- ### DELETE FROM `jiangxu`.`t1`
- ### WHERE
- ### @1=14 /* INT meta=0 nullable=0 is_null=0 */
- ### @2='a' /* VARSTRING(15) meta=15 nullable=1 is_null=0 */
- ### DELETE FROM `jiangxu`.`t1`
- ### WHERE
- ### @1=15 /* INT meta=0 nullable=0 is_null=0 */
- ### @2='a' /* VARSTRING(15) meta=15 nullable=1 is_null=0 */
- # at 452
- #140919 16:44:50 server id 16024 end_log_pos 479 Xid = 25570
- COMMIT/*!*/;
在binlog_format=MIXED时候,哪种改变会被按照ROW进行记录到binlog,参考官方说明:
http://dev.mysql.com/doc/refman/5.5/en/binary-log-mixed.html
所以看得出在MIXED的状态下基本上对于主库的DDL操作无法按照行变化进行记录。
对于行变化的日志记录磁盘IO肯定要比语句复制消耗要大,可以根据架构酌情配置。
【MySQL】binlog_format以及binlog事务记录分析的更多相关文章
- mysql 正确清理binlog日志的两种方法
前言: MySQL中的binlog日志记录了数据库中数据的变动,便于对数据的基于时间点和基于位置的恢复,但是binlog也会日渐增大,占用很大的磁盘空间,因此,要对binlog使用正确安全的方法清理掉 ...
- 监听MySQL的binlog日志工具分析:Canal
Canal是阿里巴巴旗下的一款开源项目,利用Java开发.主要用途是基于MySQL数据库增量日志解析,提供增量数据订阅和消费,目前主要支持MySQL. GitHub地址:https://github. ...
- mysql 服务端事务和客户端事务对比分析
之前做mysql事务测试的时候都是在mysql服务端存储过程里面包含事务. 例如: CREATE DEFINER=`root`@`localhost` PROCEDURE `Test`(out deb ...
- Mysql数据库之Binlog日志使用总结
binlog二进制日志对于mysql数据库的重要性有多大,在此就不多说了.下面根据本人的日常操作经历,并结合网上参考资料,对binlog日志使用做一梳理: 一.binlog日志介绍1)什么是binlo ...
- (转)Mysql数据库之Binlog日志使用总结
使用mysqlbinlog提取二进制日志 原文:http://blog.csdn.net/leshami/article/details/41962243 MySQL binlog日志记录了MySQL ...
- 1010针对一个binlog日志的分析
针对一个BINLOG日志的分析 -- 当前binlog_format | ROW[root@109 mysql]# cat wang1010.txt/*!50530 SET @@SESSION.PSE ...
- MySQL 日志之 binlog 格式 → 关于 MySQL 默认隔离级别的探讨
开心一刻 产品还没测试直接投入生产时,这尼玛... 背景问题 在讲 binlog 之前,我们先来回顾下主流关系型数据库的默认隔离级别,是默认隔离级别,不是事务有哪几种隔离级别,别会错题意了 1.Ora ...
- 【mysql】关于binlog格式
写在前面的话 1.推荐用mixed,默认使用statement,基于上下文 set session/global binlog_format=mixed; 2.二进制日记录了数据库执行更改的操作,如 ...
- MySQL binlog_format (Mixed,Statement,Row)[转]
MySQL 5.5 中对于二进制日志 (binlog) 有 3 种不同的格式可选:Mixed,Statement,Row,默认格式是 Statement.总结一下这三种格式日志的优缺点. MySQL ...
随机推荐
- [OpenGL ES 03]3D变换:模型,视图,投影与Viewport
[OpenGL ES 03]3D变换:模型,视图,投影与Viewport 罗朝辉 (http://blog.csdn.net/kesalin) 本文遵循“署名-非商业用途-保持一致”创作公用协议 系列 ...
- PLSQL_Oracle Object所有数据库对象类型汇总和简解(概念)
Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE /* Style Definitions */ table.MsoNormalTable ...
- [MySQL] 字符集的选择
1. Mysql支持的字符集 MySQL服务器可以支持多种字符集,不同的字段都可以使用不同的字符集. 查看所有可用字符集: show character set; select * from info ...
- Shell 重定向 &>file,2>&1,1>&2 的区别
Shell上:0表示标准输入1表示标准输出2表示标准错误输出> 默认为标准输出重定向,与1>相同2>&1 意思是 把标准错误输出重定向到标准输出1>&2 意思是 ...
- UCOS-消息队列(学习笔记)
消息队列的核心是一个消息的指针数组,UCOS系统初始化时根据OS_CONFI.h中的最大队列个数定义这么多个消息队列(队列的结构)并将他们串联成空的链表,创建消息队列时从空链表中抽出一个并用指针数组的 ...
- android之location02
package com.example.mars_3300_location02; import java.net.ContentHandler; import java.util.List; imp ...
- Android之SQLite
在模拟器运行的情况下,进入cmd运行adb shell 可进入模拟器的linux系统输入 lite3 mars_test_db 可进入sqlite模式.schema或者.sch 查看有哪些表 SQLi ...
- ROWNUM-Oracle中的分页代码
SELECT * FROM (SELECT ENAME,SAL,ROWNUM RN FROM EMP WHERE ROWNUM <= @CURRENTPAGE*@PAGESIZE) SUB );
- console,和自己定义事件
console.log这个指令是在浏览器控制台输出日志,用来调试程序 跟alert 类似 但不像alert那样会打断程序.
- sql如何获取一个时间段内的月份
),) from master..spt_values where type='P' and dateadd(month,number,'2010-01-01')<='2010-09-01' / ...