暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Mariadb flashback

小飞旅馆 2019-01-14
920

闪回是一种允许将实例,数据库或表回滚到旧快照的功能。DML-only flashback was introduced in MariaDB 10.2.4


目前仅在DML语句(INSERT,DELETE,UPDATE)上支持闪回。即将推出的MariaDB版本将通过将当前表复制或移动到保留和隐藏数据库,

然后在使用闪回时复制或移回来添加对DDL语句(DROP,TRUNCATE,ALTER等)的闪回支持。

使用对完整镜像格式二进制日志(binlog_row_image=FULL)的现有支持,在MariaDB Server中实现闪回,因此它支持所有引擎。

闪回的实际工作是由做mysqlbinlog用--flashback。这会导致事件被转换:INSERT到DELETE,DELETE到INSERT,对于UPDATEs,交换前后镜像。

执行mysqlbinlog时--flashback,闪回事件将存储在内存中。您应该确保您的服务器有足够的内存用于此功能。


新参数:

mysqlbinlog新的选项--flashback or -B能够让它工作在闪回模式

mysqld有新的选项--flashback启用binary log并且设置binlog_format=ROW


示例:

mysqlbinlog /var/lib/mysql/mysql-bin.000001 -vv -d test -T mytable --start-datetime="2013-03-27 14:54:00" > review.sql

mysqlbinlog /var/lib/mysql/mysql-bin.000001 -vv -d test -T mytable --start-datetime="2013-03-27 14:54:00" --flashback > flashback.sql


其它选项还可以是--start-position 


常见的一个用flashback场景是:

A common use case for Flashback is the following scenario:

You have one master and two slaves, one started with --flashback (i.e. with binary logging enabled, using binlog_format=ROW, and binlog_row_image=FULL).

Something goes wrong on the master (like a wrong update or delete) and you would like to revert to a state of the database (or just a table) at a certain point in time.

Remove the flashback-enabled slave from replication.

Invoke mysqlbinlog to find the exact log position of the first offending operation after the state you want to revert to.

Run mysqlbinlog --flashback --start-position=xyz | mysql to pipe the output of mysqlbinlog directly to the mysql client, or save the output to a file and then direct the file to the command-line client.


文章转载自小飞旅馆,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论