当前位置:网站首页>Introduction to mysqlbinlog command (remote pull binlog)
Introduction to mysqlbinlog command (remote pull binlog)
2022-07-23 23:04:00 【lgq2016】
from MySQL5.6 Start ,mysqlbinlog Support to transfer binlog Live copy to local server .
mysqlbinlog The real-time binary copy function of is not simply to copy the logs of the remote server , It's through MySQL 5.6 released Replication API Get binary events in real time . Essentially , Equivalent to MySQL From the server . Similar to a normal server , After the main server event , Usually in 0.5~1 Backup in seconds .
Here is the main introduction mysqlbinlog Remote pull log command and main parameters :
Order sample :mysqlbinlog -v --base64-output=DECODE-ROWS --read-from-remote-server --raw --host=x.x.x.x --port=3306 --user=root --password=123456 --stop-never mysql-bin.000001
--read-from-remote-server: For backing up remote servers binlog. If you do not specify this option , The local binlog.
--raw:binlog Logs are stored on disk in binary format , If you do not specify this option , Will be saved as text , For text mode, you need to specify the file name , Otherwise, it is printed on the console .
--user: Copy of the MySQL user , Just grant REPLICATION SLAVE jurisdiction .
--stop-never:mysqlbinlog You can only get the specified number of... From the remote server binlog,
Can also be generated by binlog Save to local . Specify this option , Represents as long as the remote server is not shut down or the connection is not disconnected ,
mysqlbinlog Will continue to copy the remote server binlog.
mysql-bin.000001: From which binlog Start copying , It's just a combination --stop-never You can copy files that do not appear on the command line in order ( such as mysql-bin.000002,mysql-bin.000003 etc. ).
-v --base64-output=DECODE-ROWS Command for binary log files sql command base64 The decoding
--database Specify database name
In addition to the above options , There are also several options to note :
--stop-never-slave-server-id: On the backup remote server binlog when ,mysqlbinlog It's essentially a slave server ,
This option is used to specify the slave server server-id Of . The default is -1.
--to-last-log: representative mysqlbinlog Not only can I get the specified binlog, You can also get what's generated later binlog,
It's over , To terminate . If you specify --stop-never The options are implicitly turned on --to-last-log Options .
--result-file: To set up a remote server binlog, Save to local prefix ( without --row, Is the file name ). For example, for mysql-bin.000001,
If specified --result-file=/test/backup-, The file name saved locally is /test/backup-mysql-bin.000001.
Be careful : If you will --result-file Set to directory , Must be accompanied by a directory separator “/”. for example --result-file=/test/,
instead of --result-file=/test, Otherwise, the local file name is /testmysql-bin.000001
--raw I won't support it --database,--start-datetime,--end-datetime,--end-position
--stop-never When it appears , From the target file (mysql-bin.000001) Start continuous copying of subsequent files , Otherwise, only pull the target file Next, let's show the command
mysqlbinlog -v --base64-output=DECODE-ROWS mysql-bin.000002
Example results after execution ( among mysql-bin.000002 For local files )
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @[email protected]@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#220720 15:07:06 server id 1 end_log_pos 0 CRC32 0xfc718567 Start: binlog v 4, server v 5.7.30-log created 220720 15:07:06
# at 123
#220720 17:19:00 server id 1 end_log_pos 1071 CRC32 0xe3719127 Anonymous_GTID last_committed=3 sequence_number=4 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 188
#220720 17:19:00 server id 1 end_log_pos 1151 CRC32 0x4fbd6189 Query thread_id=47 exec_time=0 error_code=0
SET TIMESTAMP=1658308740/*!*/;
SET @@session.pseudo_thread_id=47/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1436549120/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb4 *//*!*/;
SET @@session.character_set_client=45,@@session.collation_connection=45,@@session.collation_server=45/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at 268
#220720 17:19:00 server id 1 end_log_pos 1214 CRC32 0x58b5cbd4 Table_map: `mysql_shiyan`.`employee` mapped to number 110
# at 331
#220720 17:19:00 server id 1 end_log_pos 1259 CRC32 0xa71b0d0e Write_rows: table id 110 flags: STMT_END_F
### INSERT INTO `mysql_shiyan`.`employee`
### SET
### @1=5
### @2='Dog7'
### @3=NULL
# at 376
#220720 17:19:00 server id 1 end_log_pos 1290 CRC32 0x49c4796a Xid = 305
COMMIT/*!*/;
# at 407
#220720 17:24:41 server id 1 end_log_pos 1355 CRC32 0x21f52f84 Anonymous_GTID last_committed=4 sequence_number=5 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 472
#220720 17:24:41 server id 1 end_log_pos 1435 CRC32 0x4f39b2d6 Query thread_id=47 exec_time=0 error_code=0
SET TIMESTAMP=1658309081/*!*/;
BEGIN
/*!*/;
# at 552
#220720 17:24:41 server id 1 end_log_pos 1498 CRC32 0x04b33e43 Table_map: `mysql_shiyan`.`employee` mapped to number 110
# at 615
#220720 17:24:41 server id 1 end_log_pos 1639 CRC32 0x86990db1 Update_rows: table id 110 flags: STMT_END_F
### UPDATE `mysql_shiyan`.`employee`
### WHERE
### @1=5
### @2='Dog5'
### @3=NULL
### SET
### @1=5
### @2='Dog77'
### @3=NULL
### UPDATE `mysql_shiyan`.`employee`
### WHERE
### @1=5
### @2='Dog5'
### @3=NULL
### SET
### @1=5
### @2='Dog77'
### @3=NULL
### UPDATE `mysql_shiyan`.`employee`
### WHERE
### @1=5
### @2='Dog5'
### @3=NULL
### SET
### @1=5
### @2='Dog77'
### @3=NULL
### UPDATE `mysql_shiyan`.`employee`
### WHERE
### @1=5
### @2='Dog6'
### @3=NULL
### SET
### @1=5
### @2='Dog77'
### @3=NULL
### UPDATE `mysql_shiyan`.`employee`
### WHERE
### @1=5
### @2='Dog7'
### @3=NULL
### SET
### @1=5
### @2='Dog77'
### @3=NULL
# at 756
#220720 17:24:41 server id 1 end_log_pos 1670 CRC32 0x0dce8341 Xid = 361
COMMIT/*!*/;
# at 787
#220720 17:26:09 server id 1 end_log_pos 1735 CRC32 0xe778776d Anonymous_GTID last_committed=5 sequence_number=6 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 852
#220720 17:26:09 server id 1 end_log_pos 1815 CRC32 0xb766cc4f Query thread_id=47 exec_time=0 error_code=0
SET TIMESTAMP=1658309169/*!*/;
BEGIN
/*!*/;
# at 932
#220720 17:26:09 server id 1 end_log_pos 1878 CRC32 0x83f37203 Table_map: `mysql_shiyan`.`employee` mapped to number 110
# at 995
#220720 17:26:09 server id 1 end_log_pos 1968 CRC32 0xb3d7455c Delete_rows: table id 110 flags: STMT_END_F
### DELETE FROM `mysql_shiyan`.`employee`
### WHERE
### @1=5
### @2='Dog77'
### @3=NULL
### DELETE FROM `mysql_shiyan`.`employee`
### WHERE
### @1=5
### @2='Dog77'
### @3=NULL
### DELETE FROM `mysql_shiyan`.`employee`
### WHERE
### @1=5
### @2='Dog77'
### @3=NULL
### DELETE FROM `mysql_shiyan`.`employee`
### WHERE
### @1=5
### @2='Dog77'
### @3=NULL
### DELETE FROM `mysql_shiyan`.`employee`
### WHERE
### @1=5
### @2='Dog77'
### @3=NULL
# at 1085
#220720 17:26:09 server id 1 end_log_pos 1999 CRC32 0xf3a5f5f8 Xid = 377
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*/;It can be seen from the above that no matter it is increasing , Delete and change operations ,binglog All data of relevant records are stored in , among @1,@2,@3 Is the field sequence number .
A final reminder , The party that pulls logs does not need to install mysql, Just need to have mysqlbinlog Executable files ( Already installed mysql Of bin Get... In the directory ) that will do .
边栏推荐
- ES6箭頭函數的使用
- 糖尿病遗传风险检测挑战赛进阶
- Stm32+esp8266+mqtt protocol connects Alibaba cloud Internet of things platform
- Mongodb - Introduction to the usage of logical operators not, and, or, nor in query statements
- At the forefront of the times, Huawei aims at the wind and sea of digital finance
- unity visual studio2019升级到2022版本(扔掉盗版红渣)
- 接口测试
- ospf终极实验——学会ospf世纪模板例题
- Profit logic of DFI project 2021-04-26
- openEuler 资源利用率提升之道 01:概论
猜你喜欢

Microsoft SQL Server database language and function usage (XIII)

浅析基于NVR技术的视频能力与未来发展趋势

使用itextpdf提取PDF文件中的任意页码

The role of physical layer, link layer, network layer, transport layer and application layer of tcp/ip model of internet protocol stack

Light up the LED light of little bear patting learning

Series of articles | the way to advance the microservice architecture in the cloud native era - best practices of microservice splitting

TAP 系列文章4 | 基于 Backstage 的 TAP 开发者门户

Stm32+esp8266+mqtt protocol connects Alibaba cloud Internet of things platform

Tap series article 6 | application model of tap

unity visual studio2019升级到2022版本(扔掉盗版红渣)
随机推荐
Build your own target detection environment, model configuration, data configuration mmdetection
FL Studio 20.9 update Chinese version host Daw digital audio workstation
About: enable delivery optimization in enterprise LAN
DeFi項目的盈利邏輯 2021-04-26
What if the content of software testing is too simple?
The font of Siyuan notes is thinner and lighter than that in other editors (atom, VSC, sublime)
Crazy bull market, where to go in the second half? 2021-04-30
TAP 系列文章9 | 应用开发加速器
None和nan、NaN、NAN
Drools (1): introduction to drools
海外资深玩家的投资建议(3) 2021-05-04
Merge.Avhd into.Vhd manually in Hyper-V
接口测试
狂神redis笔记10
Exch:pop3 and IMAP4 operation guide
思源笔记的字体比其他的编辑器(Atom,VSC,sublime)内字体渲染更细更淡
QT set cache and compile output path
TikTok推出多语种字幕和翻译工具
Programming in the novel [serial 17] the moon bends in the yuan universe
(CVPR-2022)BiCnet