中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

mysql MyFlash使用

發布時間:2020-08-10 15:55:33 來源:ITPUB博客 閱讀:177 作者:wwjfeng 欄目:MySQL數據庫
一.安裝MyFlash
1.安裝條件
binlog_format=ROW
binlog_row_image=FULL
僅支持5.6與5.7,并且只能回滾DML

2.安裝
unzip MyFlash.zip
yum -y install glib2*
cd /data/MyFlash/MyFlash-master
gcc -w `pkg-config --cflags --libs glib-2.0` source/binlogParseGlib.c -o binary/flashback
*沒有報錯,證明安裝成功

二.恢復場景
1.回滾整個文件
./flashback --binlogFileNames=haha.000041
mysqlbinlog binlog_output_base.flashback | mysql -h -u -p

2.回滾某個表的DML語句
-刪除數據
mysql> show tables;
+---------------+
| Tables_in_wwj |
+---------------+
| t1            |
+---------------+
1 row in set (0.00 sec)

mysql> select * from t1;
+----+------+
| id | name |
+----+------+
|  5 | haha |
|  6 | mxt3 |
|  7 | mxt4 |
+----+------+
3 rows in set (0.00 sec)

mysql> delete from t1;
Query OK, 3 rows affected (0.02 sec)

mysql> select * from t1;
Empty set (0.00 sec)

-生成恢復文件(回滾t1表的delete操作)
cd /data/MyFlash/MyFlash-master/binary
# ./flashback --databaseNames='wwj' --tableNames='t1' --sqlTypes='DELETE' --binlogFileNames=/home/mysql3307/mysql3307/mysql-bin.000001

-查看文件
# /usr/local/mysql/bin/mysqlbinlog -vv binlog_output_base.flashback

-恢復
# /usr/local/mysql/bin/mysqlbinlog binlog_output_base.flashback|/usr/local/mysql/bin/mysql -S /tmp/mysql3307.sock -p
恢復完成
mysql> select * from t1;
+----+------+
| id | name |
+----+------+
|  5 | haha |
|  6 | mxt3 |
|  7 | mxt4 |
+----+------+
3 rows in set (0.00 sec)

3.恢復一段時間的binlog

-生成數據
[root@mysql5 mysql3307]# date
Thu Mar 29 05:41:00 CST 2018
insert into wwj.t3 values(4,'mxt2');
insert into wwj.t3 values(5,'mxt3');
insert into wwj.t3 values(6,'mxt4');
[root@mysql5 mysql3307]# date
Thu Mar 29 05:41:37 CST 2018
delete from wwj.t3;
[root@mysql5 mysql3307]# date
Thu Mar 29 05:42:57 CST 2018

- 回滾2018-03-29 05:41:37~2018-03-29 05:42:57 之間的操作
- 查看binlog
# /usr/local/mysql/bin/mysqlbinlog --start-datetime='2018-03-29 05:41:37' --stop-datetime='2018-03-29 05:42:57' mysql-bin.000001 --base64-output=decode-rows -v
- 生成恢復文件
./flashback --databaseNames='wwj' --start-datetime='2018-03-29 05:41:37' --stop-datetime='2018-03-29 05:42:57' --binlogFileNames=/home/mysql3307/mysql3307/mysql-bin.000001
- 查看回滾文件
# /usr/local/mysql/bin/mysqlbinlog -vv binlog_output_base.flashback
- 執行回滾
/usr/local/mysql/bin/mysqlbinlog binlog_output_base.flashback|/usr/local/mysql/bin/mysql -S /tmp/mysql3307.sock -p
- 查看恢復結果
mysql> select * from wwj.t3;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    8
Current database: *** NONE ***
+----+------+
| id | name |
+----+------+
|  4 | mxt2 |
|  5 | mxt3 |
|  6 | mxt4 |
+----+------+

3.恢復一段position的binlog文件
- 生成數據
insert into wwj.t3 values(4,'mxt2');
insert into wwj.t3 values(5,'mxt3');
insert into wwj.t3 values(6,'mxt4');
insert into wwj.t2 values(4,'mxt2');
insert into wwj.t2 values(5,'mxt3');
insert into wwj.t2 values(6,'mxt4');
insert into wwj.t1 values(4,'mxt2');
insert into wwj.t1 values(5,'mxt3');
insert into wwj.t1 values(6,'mxt4');

mysql> delete from wwj.t3;
Query OK, 3 rows affected (0.01 sec)
mysql> delete from wwj.t2;
Query OK, 3 rows affected (0.01 sec)
mysql> delete from wwj.t1;
Query OK, 3 rows affected (0.00 sec)

-查看binlog
/usr/local/mysql/bin/mysqlbinlog mysql-bin.000001 --base64-output=decode-rows -v

-確認恢復 mysql-bin.000001 position 1823~2487,生成恢復文件
# ./flashback --databaseNames='wwj' --start-position=1823 --stop-position=2487 --binlogFileNames=/home/mysql3307/mysql3307/mysql-bin.000001

- 查看回滾文件
# /usr/local/mysql/bin/mysqlbinlog -vv binlog_output_base.flashback

- 執行回滾
/usr/local/mysql/bin/mysqlbinlog binlog_output_base.flashback|/usr/local/mysql/bin/mysql -S /tmp/mysql3307.sock -p

-查看數據
mysql> select * from wwj.t1;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    17
Current database: *** NONE ***
+----+------+
| id | name |
+----+------+
|  4 | mxt2 |
|  7 | mxt2 |
|  5 | mxt3 |
|  8 | mxt3 |
|  6 | mxt4 |
|  9 | mxt4 |
+----+------+
6 rows in set (0.00 sec)

mysql> select * from wwj.t2;
+----+------+
| id | name |
+----+------+
|  4 | mxt2 |
|  5 | mxt3 |
|  6 | mxt4 |
+----+------+
3 rows in set (0.00 sec)

mysql> select * from wwj.t3;
+----+------+
| id | name |
+----+------+
|  4 | mxt2 |
|  5 | mxt3 |
|  6 | mxt4 |
+----+------+
3 rows in set (0.00 sec)


三.相關參數

點擊(此處)折疊或打開

  1. Application Options:
  2. --databaseNames databaseName to apply. if multiple, seperate by comma(,)
  3. --tableNames tableName to apply. if multiple, seperate by comma(,)
  4. --start-position start position
  5. --stop-position stop position
  6. --start-datetime start time (format %Y-%m-%d %H:%M:%S)
  7. --stop-datetime stop time (format %Y-%m-%d %H:%M:%S)
  8. --sqlTypes sql type to filter . support INSERT, UPDATE ,DELETE. if multiple, seperate by comma(,)
  9. --maxSplitSize max file size after split, the uint is M
  10. --binlogFileNames binlog files to process. if multiple, seperate by comma(,)
  11. --outBinlogFileNameBase output binlog file name base
  12. --logLevel log level, available option is debug,warning,error
  13. --include-gtids gtids to process
  14. --exclude-gtids gtids to skip


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

广宗县| 如东县| 九台市| 张家港市| 康保县| 固原市| 雷州市| 宿州市| 青龙| 汝州市| 波密县| 北安市| 墨玉县| 舒兰市| 合肥市| 府谷县| 西青区| 庆云县| 桐梓县| 阿合奇县| 准格尔旗| 翁牛特旗| 卢氏县| 亳州市| 古田县| 那坡县| 连州市| 芦溪县| 台安县| 澎湖县| 饶平县| 北安市| 永昌县| 高台县| 阜南县| 南宫市| 长沙市| 平定县| 涟源市| 临城县| 湖北省|