欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

binlog_format 为 ROW 的分析

程序员文章站 2022-07-15 13:24:17
...

os: centos 7.4.1708
db: mysql 8.0.20

版本

# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core) 
# 
# 
# yum list installed |grep -i mysql80
mysql-community-client.x86_64              8.0.20-1.el7                @mysql80-community
mysql-community-common.x86_64              8.0.20-1.el7                @mysql80-community
mysql-community-devel.x86_64               8.0.20-1.el7                @mysql80-community
mysql-community-libs.x86_64                8.0.20-1.el7                @mysql80-community
mysql-community-libs-compat.x86_64         8.0.20-1.el7                @mysql80-community
mysql-community-server.x86_64              8.0.20-1.el7                @mysql80-community
mysql-community-test.x86_64                8.0.20-1.el7                @mysql80-community
mysql80-community-release.noarch           el7-3                       installed

# mysql -e "select version();"
+-----------+
| version() |
+-----------+
| 8.0.20    |
+-----------+

binlog_format = ROW

# vi /etc/my.cnf

binlog_format = ROW

# systemctl restart mysqld.service
# mysql

mysql> use test;

mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin       | ON    |
+---------------+-------+
1 row in set (0.00 sec)

mysql> show variables like 'binlog_format';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW   |
+---------------+-------+
1 row in set (0.01 sec)

mysql> show master status;
+---------------+----------+--------------+------------------+-------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| binlog.000024 |      156 |              |                  |                   |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

mysql> insert into tmp_t0 values(1,'1','1'),(2,'2','2');
Query OK, 2 rows affected (0.33 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> show master status;
+---------------+----------+--------------+------------------+-------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| binlog.000024 |      467 |              |                  |                   |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

# /usr/bin/mysqlbinlog --no-defaults --base64-output=decode-rows -v --start-position=156 --stop-position=467  /var/lib/mysql/binlog.000024

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @[email protected]@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 125
#200629  9:20:22 server id 1  end_log_pos 125 CRC32 0xb7bca599 	Start: binlog v 4, server v 8.0.20 created 200629  9:20:22 at startup
# Warning: this binlog is either in use or was not closed properly.
ROLLBACK/*!*/;
# at 156
#200629  9:21:53 server id 1  end_log_pos 235 CRC32 0xd499075e 	Anonymous_GTID	last_committed=0	sequence_number=1	rbr_only=yes	original_committed_timestamp=1593393713676335	immediate_commit_timestamp=1593393713676335	transaction_length=311
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
# original_commit_timestamp=1593393713676335 (2020-06-29 09:21:53.676335 CST)
# immediate_commit_timestamp=1593393713676335 (2020-06-29 09:21:53.676335 CST)
/*!80001 SET @@session.original_commit_timestamp=1593393713676335*//*!*/;
/*!80014 SET @@session.original_server_version=80020*//*!*/;
/*!80014 SET @@session.immediate_server_version=80020*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 235
#200629  9:21:53 server id 1  end_log_pos 310 CRC32 0x9744271c 	Query	thread_id=8	exec_time=0	error_code=0
SET TIMESTAMP=1593393713/*!*/;
SET @@session.pseudo_thread_id=8/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1168113696/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb4 *//*!*/;
SET @@session.character_set_client=255,@@session.collation_connection=255,@@session.collation_server=255/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
/*!80011 SET @@session.default_collation_for_utf8mb4=255*//*!*/;
BEGIN
/*!*/;
# at 310
#200629  9:21:53 server id 1  end_log_pos 371 CRC32 0xc46cb76d 	Table_map: `test`.`tmp_t0` mapped to number 86
# at 371
#200629  9:21:53 server id 1  end_log_pos 436 CRC32 0x7664abb3 	Write_rows: table id 86 flags: STMT_END_F
### INSERT INTO `test`.`tmp_t0`
### SET
###   @1=1
###   @2='1'
###   @3='1'
### INSERT INTO `test`.`tmp_t0`
### SET
###   @1=2
###   @2='2'
###   @3='2'
# at 436
#200629  9:21:53 server id 1  end_log_pos 467 CRC32 0x976464f4 	Xid = 12
COMMIT/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET [email protected]_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

参考:
https://dev.mysql.com/doc/refman/8.0/en/binary-log-setting.html

相关标签: # mysql parameter

上一篇: X形图案

下一篇: Spring MVC 文件上传