Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MyFlash rollback mysql binlog

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Introduction: MyFlash is a tool for rolling back DML operations developed and maintained by the Technical Engineering Department of Meituan Dianping Company. The tool completes the rollback operation by parsing the v4 version of binlog. Compared with the existing rollback tools, it adds more filtering options to make rollback easier.

Installation:

Git clone https://github.com/Meituan-Dianping/MyFlash.git

Cd MyFlash

Gcc-w pkg-config-- cflags-- libs glib-2.0 source/binlogParseGlib.c-o binary/flashback

Cd binary

. / flashback-- help-- View help

Use:

The following parameters can be combined arbitrarily.

* 1.databaseNames

Specify the database name that needs to be rolled back. Multiple databases can be separated by ",". If you do not specify this parameter, it is equivalent to specifying all databases.

2.tableNames

Specify the table name that needs to be rolled back. Multiple tables can be separated by ",". If you do not specify this parameter, it is equivalent to specifying all tables. 3.start-position

Specify the location where the rollback begins. If not specified, rollback from the beginning of the file. Please specify the correct and valid location, otherwise the 4.stop-position cannot be rolled back

Specify the location where the rollback ends. If not specified, roll back to the end of the file. Please specify the correct and valid location, otherwise the 5.start-datetime cannot be rolled back

Specifies the start time of the rollback. Note that the format must be Y-%m-%d H:%M:%S. If not specified, there is no time limit 6.stop-datetime

Specifies the end time of the rollback. Note that the format must be Y-%m-%d H:%M:%S. If not specified, there is no time limit 7.sqlTypes

Specifies the sql type that needs to be rolled back. Currently, the supported filter types are INSERT, UPDATE and DELETE. Multiple types can be separated by ",". 8.maxSplitSize

Once this parameter is specified, the file is segmented in a fixed size (in M), and the filter condition is valid, but no rollback operation is performed. This parameter is mainly used to cut large binlog files to prevent the binlog size of a single application from being too large and causing pressure 9.binlogFileNames on the line.

Specify the binlog file that needs to be rolled back. Currently, only a single file is supported. Multiple files will be added to support 10.outBinlogFileNameBase later.

Specifies the output binlog file prefix, if not specified, defaults to binlog_output_base.flashback11.logLevel

For developers only. The default level is error. Do not modify this level in a production environment, or you will output too much 12.include-gtids

Specify the gtid that needs to be rolled back, supporting both single and scope forms of gtid. 13.exclude-gtids

Specify the gtid that does not need to be rolled back, using the same as include-gtids

Test:

/ root/test/MyFlash/binary/flashback-binlogFileNames=/mysqllog/mysql-bin.000011-start-datetime= "2018-01-04 13:50:00"-- stop-datetime= "2018-01-04 14:35:00"-- databaseNames=test-- tableNames=test_tb-- sqlTypes='UPDATE','DELETE'-- outBinlogFileNameBase=test_tb

Mysqlbinlog-- no-defaults-- base64-output=decode-rows-vv binlog_output_base.flashback-- View rollback sql

Mysqlbinlog-- no-defaults binlog_output_base.flashback | mysql-uroot-pyourpass-perform recovery

Can be added in .bash _ profile

Alias flashback= "/ root/test/MyFlash/binary/flashback"

You can use it like this later.

Flashback-binlogFileNames=/mysqllog/mysql-bin.000011-start-datetime= "2018-01-04 13:50:00"-- stop-datetime= "2018-01-04 14:35:00"-- databaseNames=test-- tableNames=test_tb-- sqlTypes='UPDATE','DELETE'-- outBinlogFileNameBase=test_tb

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report