色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

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

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

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

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

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

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

1:從主庫(kù)

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

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

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

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

因?yàn)橐恢滦宰x,能夠保證coordinates點(diǎn)的位置,即使備份時(shí)間很久,也能得出正確的同步位置點(diǎn)。

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)出的語(yǔ)句會(huì)包含CHANGE MASTER TO語(yǔ)句,包括備份語(yǔ)句同步到的二進(jìn)制文件和位置點(diǎ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會(huì)強(qiáng)制重新生成一個(gè)新的二進(jìn)制文件,這樣恢復(fù)的時(shí)候會(huì)比較方便。

2:從副庫(kù)

感覺(jué)上從副庫(kù)備份更安全。

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.

記住一點(diǎn)它獲取的是主庫(kù)的bin log coordinates(不是備份庫(kù)的)

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

dump出來(lái)的語(yǔ)句會(huì)包含 — Position to start replication or point-in-time recovery from。

—apply-slave-statements會(huì)讓dump語(yǔ)句中自動(dòng)包含start和stop slave語(yǔ)句。—include-master-host-port包含主庫(kù)的連接信息。

必須記住一點(diǎn),即使有—single-transaction語(yǔ)句,—dump-slave也會(huì)暫停mysql同步,也就是備份庫(kù)的數(shù)據(jù)是落后于主庫(kù)的,所以一般自動(dòng)化腳本在備份的時(shí)候會(huì)先摘除備份庫(kù)。

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

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

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

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

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

標(biāo)簽: MySQL 數(shù)據(jù)庫(kù)
相關(guān)文章:
主站蜘蛛池模板: 手机日韩理论片在线播放 | 欧美中文在线 | 久草网在线观看 | 欧美一级毛片香蕉网 | 欧美日韩视频一区三区二区 | 黄色a一片 | 欧美手机手机在线视频一区 | 亚洲精品成人网久久久久久 | 亚洲第一网站在线观看 | 91香蕉成人免费网站 | 欧美不卡一区 | 欧美日韩一区二区视频免费看 | 99在线视频播放 | 全部毛片 | 免费视频日本 | 成人a毛片手机免费播放 | 日韩在线视频网址 | 仑乱高清在线一级播放 | 日本免费人成黄页网观看视频 | 亚洲欧洲一二三区机械有限公司 | 日本黄页网站免费大全 | 成人国产第一区在线观看 | 欧美日韩精品在线播放 | 在线视频观看免费视频18 | 日本国产在线 | 成人精品在线 | 亚洲欧美国产一区二区三区 | 日本道综合一本久久久88 | 久久只有精品视频 | 日本www免费视频网站在线观看 | 日鲁夜鲁鲁狠狠综合视频 | 免费aa在线观看 男人的天堂 | 真人一级毛片 | 成人18免费视频 | 欧美日韩一区二区不卡三区 | 国产亚洲欧美一区二区三区 | 免费毛片全部不收费的 | 国产成人影院一区二区 | 99久久综合国产精品免费 | 久久777国产线看是看精品 | 精品玖玖玖视频在线观看 |