国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

如何用mysqldump進行全量和時間點備份

瀏覽:72日期:2023-10-12 10:05:12

mysqldump在mysql中用于邏輯備份,雖然速度不快,但非常靈活,有很多功能,靈活使用的化絕對是利器。

首先思考一個問題,mysql為什么要備份,主要還是數據安全性,比如主庫掛了,數據不小心被刪除了,所以全量備份非常重要。

是從主庫還是副庫進行全量備份呢?

1:從主庫

主庫比較重要,但其實備份的時候并不會影響數據庫

mysqldump --host= --user= --password= --single-transaction --master-data=1 --flush-logs --databases >~/db.log

—single-transaction 參數能夠報紙一致性讀,不會鎖表,也就是備份的時候不影響數據更新。

it dumps the consistent state of the database at the time when START TRANSACTION was issued without blocking any applications.

因為一致性讀,能夠保證coordinates點的位置,即使備份時間很久,也能得出正確的同步位置點。

While a —single-transaction dump is in process, to ensure a valid dump file (correct table contents and binary log coordinates)

—master-data參數也很重要,導出的語句會包含CHANGE MASTER TO語句,包括備份語句同步到的二進制文件和位置點。

Use this option to dump a master replication server to produce a dump file that can be used to set upanother server as a slave of the master. It causes the dump output to include a CHANGE MASTER TO statement that indicates the binary log coordinates (file name and position) of the dumped server. These are the master server coordinates from which the slave should start replicating after you load the dump file into the slave.

—flush-logs會強制重新生成一個新的二進制文件,這樣恢復的時候會比較方便。

2:從副庫

感覺上從副庫備份更安全。

mysqldump --host=--user= --password= --dump-slave=1 --flush-logs --apply-slave-statements --include-master-host-port --databases >~/db.log;

— dump-slave和—master-data參數很類似:

This option is similar to —master-data except that it is used to dump a replication slave server to produce a dump file that can be used to set up another server as a slave that has the same master as the dumped server. It causes the dump output to include a CHANGE MASTER TO statement that indicates the binary log coordinates (file name and position) of the dumped slave’s master. These are the master server coordinates from which the slave should start replicating.

記住一點它獲取的是主庫的bin log coordinates(不是備份庫的)

—dump-slave causes the coordinates from the master to be used rather than those of the dumped server

dump出來的語句會包含 — Position to start replication or point-in-time recovery from。

—apply-slave-statements會讓dump語句中自動包含start和stop slave語句。—include-master-host-port包含主庫的連接信息。

必須記住一點,即使有—single-transaction語句,—dump-slave也會暫停mysql同步,也就是備份庫的數據是落后于主庫的,所以一般自動化腳本在備份的時候會先摘除備份庫。

This option causes mysqldump to stop the slave SQL thread before the dump and restart it again after.

3:如何進行時間點恢復

沒有實戰過,首先基于最近的一次全量備份進行恢復,然后將后續的binlog文件導入(如果這些文件還在的話),所以副庫最好也備份binlog語句。

如果數據被誤刪除了,將備份點(—flush-logs發揮作用了)到今天凌晨的binlog語句導入進來,或者找到安全的binlog位置點進行恢復。至于如何跳過“危險語句”是比較難控制的。

以上就是如何用mysqldump進行全量和時間點備份的詳細內容,更多關于mysqldump進行全量和時間點備份的資料請關注好吧啦網其它相關文章!

標簽: MySQL 數據庫
相關文章:
主站蜘蛛池模板: 自拍 欧美 在线 综合 另类 | 国产三级三级三级三级 | 久草在线观看福利 | 日韩一级欧美一级毛片在线 | 色黄在线| 国内成人免费视频 | 亚洲产国偷v产偷v自拍涩爱 | 久久久久久久国产精品毛片 | 韩国免费毛片在线看 | 国产亚洲欧美日韩在线观看一区二区 | 成年人黄色网址 | 亚洲mm8成为人影院 亚洲m男在线中文字幕 | 午夜伦4480yy妇女久久久 | 欧美色成人tv在线播放 | 国产精品一区二区三区高清在线 | 久久网站免费观看 | 日本精品久久 | 欧美性色一级在线观看 | 久久精品久久久 | 欧美α一级毛片 | 老头巨大粗长xxxxx | 一级特黄欧美 | 巨乳激情| 99精品国产成人一区二区在线 | 久久九九免费视频 | 亚洲m男在线中文字幕 | 日本红怡院在线 | 国产欧美视频综合二区 | 真人真实毛片免费观看 | 久久久久国产视频 | 亚洲影院在线播放 | 国产三级做爰在线观看∵ | 国产福利最新手机在线观看 | 亚洲欧美久久精品1区2区 | 欧美毛片a级毛片免费观 | 亚洲人成网站在线观看播放 | 色屁屁一区二区三区视频国产 | 亚洲美女免费视频 | 日韩乱码中文字幕视频 | 三上悠亚免费一区二区在线 | 国产精品日韩欧美一区二区 |