当前位置:网站首页>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 .
边栏推荐
- 【Matplotlib绘图】
- [leetcode ladder] linked list · 206 reverse linked list
- Finding all paths between two points in a directed graph
- Getting started database Days1
- ES6 use of arrow function
- 系列文章|云原生时代下微服务架构进阶之路 - 微服务拆分的最佳实践
- Is the height of binary tree [log2n]+1 equal to log2 (n+1)
- VIM common shortcut keys
- Niuke C basic exercises
- Introduction and project development of MVVM and mvvmlight (I)
猜你喜欢

糖尿病遗传风险检测挑战赛Baseline

Tap series article 7 | easy to manage pipeline configuration

Tap series article 9 | application development accelerator

H7-tool serial port offline burning operation instructions, support TTL serial port, RS232 and RS485 (2022-06-30)

Crazy God redis notes 10

FL Studio 20.9 update Chinese version host Daw digital audio workstation

ES6 other syntax and extended syntax summary

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

(CVPR-2022)BiCnet

TAP 系列文章5 | 云原生构建服务
随机推荐
砺夏行动 2022|源启数字化圆桌论坛即将上线
Raspberry pie SSH login
糖尿病遗传风险检测挑战赛进阶
Stm32+esp8266+mqtt protocol connects Alibaba cloud Internet of things platform
疯狂的牛市,下半场何去何从?2021-04-30
Tap series article 5 | cloud native build service
关于电脑端同步到手机端数据
None和nan、NaN、NAN
Array - 977. Square of ordered array
Stm32f4 check the frequency of each part of the system
Tools in the tools package of Damon database (operate Damon database)
STM32 MCU uses ADC function to drive finger heartbeat detection module
作为开发,你不得不知道的三个性能测试工具|Jmeter、Apipost、JMH使用指南
小说里的编程 【连载之二十】元宇宙里月亮弯弯
[unity3d daily bug] unity3d solves "the type or namespace name" XXX "cannot be found (are you missing the using directive or assembly reference?)" Etc
Programming in the novel [serial 18] the moon bends in the yuan universe
The font of Siyuan notes is thinner and lighter than that in other editors (atom, VSC, sublime)
Data sorting and usage before torchvision.datasets.imagefolder
巴菲特股东大会的启示 2021-05-06
ospf终极实验——学会ospf世纪模板例题