mariadb 使用mysqldump 位元據庫備份操作

來源:互聯網
上載者:User

標籤:Database Backup   mysql   二進位   資訊   

實驗內容

時間    資料庫.表    表內容(id)    操作內容

8點    db1.t1      1,2,3         進行全備份

9點    db1.t1      4,5(新增加)    增加資料   

10點    db1.t1     delete db1     刪除db1


11點探索資料庫內容有誤,要求回複正常的資料

8點資料全備份

mysqldump -uroot -ppassword --all-databases --single-transaction --master-data=2 > /tmp/mysql.all.sql

命令參數說明:

    --all-databases = -A 備份所有的庫

    --single-transaction 可以實現資料一致,服務可用

    --flush-logs 全備份後產生新的日誌,然後對資料庫的操作記錄會存在新的記錄檔中

    --master-data=2 記錄日誌的檔案名稱和此日誌中起始的position號.

9點資料增加

instert into db1.t1 (4),(5);

10點資料刪除

delete db1

  1. 停服務

  2. 清環境

  3. 啟服務

  4. 匯入全備份資料

    mysql -uroot -ppassword < /tmp/mysql.all.sql

  5. 匯入增量備份資料(重演日誌)

    a.確認記錄檔和MASTER_LOG_POS的相關資訊

    sed -n ‘22p‘ /tmp/mysql.all.sql  (mariadb5.5固定存放位置)

    b.顯示結果:

    [[email protected] ~]# sed -n ‘22p‘ /tmp/mysql.all.sql

    -- CHANGE MASTER TO MASTER_LOG_FILE=‘servera.000006‘, MASTER_LOG_POS=245;

    c.重演日誌

    mysqlbinlog /var/lib/mysql-log/servera.000006 --start-position=245 --stop-position=672 |mysql

  6. 測試

本文出自 “小窩棚” 部落格,謝絕轉載!

mariadb 使用mysqldump 位元據庫備份操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.