午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁技術(shù)文章
文章詳情頁

如何用mysqldump進(jìn)行全量和時間點備份

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

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

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

是從主庫還是副庫進(jìn)行全量備份呢?

1:從主庫

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

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

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

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參數(shù)也很重要,導(dǎo)出的語句會包含CHANGE MASTER TO語句,包括備份語句同步到的二進(jìn)制文件和位置點。

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會強(qiáng)制重新生成一個新的二進(jìn)制文件,這樣恢復(fù)的時候會比較方便。

2:從副庫

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

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

— dump-slave和—master-data參數(shù)很類似:

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同步,也就是備份庫的數(shù)據(jù)是落后于主庫的,所以一般自動化腳本在備份的時候會先摘除備份庫。

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

3:如何進(jìn)行時間點恢復(fù)

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

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

以上就是如何用mysqldump進(jìn)行全量和時間點備份的詳細(xì)內(nèi)容,更多關(guān)于mysqldump進(jìn)行全量和時間點備份的資料請關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: MySQL 數(shù)據(jù)庫
相關(guān)文章:
主站蜘蛛池模板: 亚洲影音先锋 | 亚洲欧洲日韩 | 自拍视频一区二区 | 97麻豆视频 | 久久com| 亚洲欧洲在线观看 | 91丨porny丨海角社区 | 成人av影院 | 国产成人愉拍精品久久 | 国产精品人人人人 | 男女国产精品 | 欧美老司机 | 精品一区二区三区毛片 | 久久精品国产精品亚洲精品色 | 日韩中文字幕有码 | 超碰97成人 | 超污网站在线观看 | 欧洲天堂网 | 日本一区视频在线观看 | 超碰在线国产97 | 久久久久久久九九九九 | 一区二区三区免费在线观看视频 | 制服.丝袜.亚洲.另类.中文 | 欧美高清久久 | 日韩一区在线视频 | 狠狠干夜夜干 | 日日射天天射 | 性一级录像 | 久久中字| 免费成人深夜在线观看 | 青娱乐欧美 | 欧美黄色aaa | 欧美成人另类 | 亚洲精品国 | 国产麻豆一区二区 | 狠狠躁日日躁夜夜躁2022麻豆 | 国内毛片| 久久在线观看视频 | 99欧美| 色呦呦中文字幕 | 日韩视频免费观看 |