MyFlash 復原mysql binlog

來源:互聯網
上載者:User

標籤:split   指定   完成   clu   必須   檔案的   簡介   美團   upd   

簡介:MyFlash是由美團點評公司技術工程部開發維護的一個復原DML操作的工具。該工具通過解析v4版本的binlog,完成復原操作。相對已有的復原工具,其增加了更多的過濾選項,讓復原更加容易。

安裝:
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 --查看協助

使用:
下面的這些參數是可以任意組合的。

* 1.databaseNames

指定需要復原的資料庫名。多個資料庫可以用“,”隔開。如果不指定該參數,相當於指定了所有資料庫。

  • 2.tableNames
    指定需要復原的表名。多個表可以用“,”隔開。如果不指定該參數,相當於指定了所有表。
  • 3.start-position
    指定復原開始的位置。如不指定,從檔案的開始處復原。請指定正確的有效位置,否則無法復原
  • 4.stop-position
    指定復原結束的位置。如不指定,復原到檔案結尾。請指定正確的有效位置,否則無法復原
  • 5.start-datetime
    指定復原的開始時間。注意格式必須是 %Y-%m-%d %H:%M:%S。 如不指定,則不限定時間
  • 6.stop-datetime
    指定復原的結束時間。注意格式必須是 %Y-%m-%d %H:%M:%S。 如不指定,則不限定時間
  • 7.sqlTypes
    指定需要復原的sql類型。目前支援的過濾類型是INSERT, UPDATE ,DELETE。多個類型可以用“,”隔開。
  • 8.maxSplitSize
    一旦指定該參數,對檔案進行固定尺寸的分割(單位為M),過濾條件有效,但不進行復原操作。該參數主要用來將大的binlog檔案切割,防止單次應用的binlog尺寸過大,對線上造成壓力
  • 9.binlogFileNames
    指定需要復原的binlog檔案,目前只支援單個檔案,後續會增加多個檔案支援
  • 10.outBinlogFileNameBase
    指定輸出的binlog檔案首碼,如不指定,則預設為binlog_output_base.flashback
  • 11.logLevel
    僅供開發人員使用,預設層級為error層級。在生產環境中不要修改這個層級,否則輸出過多
  • 12.include-gtids
    指定需要復原的gtid,支援gtid的單個和範圍兩種形式。
  • 13.exclude-gtids
    指定不需要復原的gtid,用法同include-gtids

測試:
/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 --查看復原sql
mysqlbinlog --no-defaults binlog_output_base.flashback |mysql -uroot -pyourpass --執行恢複
可以在.bash_profile增加
alias flashback="/root/test/MyFlash/binary/flashback"
以後即可這樣使用
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

MyFlash 復原mysql binlog

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.