设为首页 加入收藏

TOP

MySQL参数binlog-do-db对binlogs写入的影响(二)
2015-07-24 10:42:56 来源: 作者: 【 】 浏览:4
Tags:MySQL 参数 binlog-do-db binlogs 写入 影响
rows affected (0.01 sec) 那么来查看一下上面的操作有没有写入binlog中:
# mysqlbinlog --verbose --base64-output=decode-rows mysql-bin.000006
……
SET @@session.collation_database=DEFAULT/*!*/;
create table bosco1.bosco1_tb01(id int)
/*!*/;
# at 211
#141026  1:37:44 server id 1303308  end_log_pos 315 	Query	thread_id=14	exec_time=0	error_code=0
SET TIMESTAMP=1414258664/*!*/;
create table bosco2.bosco2_tb01(id int)
/*!*/;
# at 315
#141026  1:37:44 server id 1303308  end_log_pos 385 	Query	thread_id=14	exec_time=0	error_code=0
SET TIMESTAMP=1414258664/*!*/;
BEGIN
/*!*/;
# at 385
# at 437
#141026  1:37:44 server id 1303308  end_log_pos 437 	Table_map: `bosco1`.`bosco1_tb01` mapped to number 49
#141026  1:37:44 server id 1303308  end_log_pos 471 	Write_rows: table id 49 flags: STMT_END_F
### INSERT INTO `bosco1`.`bosco1_tb01`
### SET
###   @1=1
# at 471
#141026  1:37:44 server id 1303308  end_log_pos 498 	Xid = 200
COMMIT/*!*/;
# at 498
#141026  1:37:49 server id 1303308  end_log_pos 541 	Rotate to mysql-bin.000011  pos: 4
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
可见,指定了binlog-do-db=bosco1,事务隔离级别RR + binlog_format=row:
在使用指定的database(bosco1数据库)下操作本身库中的表所有DDL/DML操作都会记录到binlogs中,而操作其他库中的表时,只有DDL操作被记录下来,DML操作都不会记录。

4. 测试3:use bosco1及SBR/MBR下

binlog-do-db=bosco1;

MySQL [bosco2]> use bosco1;

MySQL [bosco1]> select @@tx_isolation,@@binlog_format;
+-----------------+-----------------+
| @@tx_isolation  | @@binlog_format |
+-----------------+-----------------+
| REPEATABLE-READ | STATEMENT       |
+-----------------+-----------------+
1 row in set (0.00 sec)

MySQL [bosco1]> flush logs;
Query OK, 0 rows affected (0.00 sec)

MySQL [bosco1]> create table bosco1.bosco1_tb01(id int);
Query OK, 0 rows affected (0.00 sec)

MySQL [bosco1]> create table bosco2.bosco2_tb01(id int);
Query OK, 0 rows affected (0.00 sec)

MySQL [bosco1]> insert into bosco1.bosco1_tb01(id) values(1);
Query OK, 1 row affected (0.00 sec)

MySQL [bosco1]> insert into bosco2.bosco2_tb01(id) values(1);
Query OK, 1 row affected (0.00 sec)

MySQL [bosco1]> flush logs;
Query OK, 0 rows affected (0.00 sec)
那么来查看一下上面的操作有没有写入binlog中:
# mysqlbinlog --verbose --base64-output=decode-rows mysql-bin.000008
……
SET @@session.collation_database=DEFAULT/*!*/;
create table bosco1.bosco1_tb01(id int)
/*!*/;
# at 211
#141026  1:33:43 server id 1303308  end_log_pos 315 	Query	thread_id=14	exec_time=0	error_code=0
SET TIMESTAMP=1414258423/*!*/;
create table bosco2.bosco2_tb01(id int)
/*!*/;
# at 315
#141026  1:33:48 server id 1303308  end_log_pos 385 	Query	thread_id=14	exec_time=0	error_code=0
SET TIMESTAMP=1414258428/*!*/;
BEGIN
/*!*/;
# at 385
#141026  1:33:48 server id 1303308  end_log_pos 494 	Query	thread_id=14	exec_time=0	error_code=0
SET TIMESTAMP=1414258428/*!*/;
insert into bosco1.bosco1_tb01(id) values(1)
/*!*/;
# at 494
#141026  1:33:48 server id 1303308  end_log_pos 521 	Xid = 188
COMMIT/*!*/;
# at 521
#141026  1:33:50 server id 1303308  end_log_pos 591 	Query	thread_id=14	exec_time=0	error_code=0
SET TIMESTAMP=1414258430/*!*/;
BEGIN
/*!*/;
# at 591
#141026  1:33:50 server id 1303308  end_log_p
首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇【Mysql】Mysql数据库处理Servlet.. 下一篇mysql子查询慢的问题

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·HyperText Transfer (2025-12-26 07:20:48)
·半小时搞懂 HTTP、HT (2025-12-26 07:20:42)
·CPython是什么?PyPy (2025-12-26 06:50:09)
·Python|如何安装seab (2025-12-26 06:50:06)
·python要学习数据分 (2025-12-26 06:50:03)