Oracle備份恢復之熱備份恢復及異機恢復

2021-09-07 10:17:24 字數 2628 閱讀 2645

原理:

資料庫必須執行在歸檔模式下,否則備份沒有意義。備份前凍結塊頭,使scn號不變化,然後cp物理檔案,最後解凍塊頭。此過程dml語句可以正常執行,動作被寫在日誌檔案裡面,當解凍scn號後,日誌檔案中內容會自動寫入資料檔案。

流程:

1、全庫備份:

1)alter database begin backup;

2)cp物理檔案

3)alter database end backup;

指令碼:spool /u01/oracle/jiaoben/bf2.sql

select 'ho cp '||name||' /u01/oracle/rebei/' from v$datafile;

spool off

alter database backup controlfile to '/u01/oracle/rebei/control.ctl';

create pfile='/u01/oracle/rebei/initorcl.ora' from spfile;

alter database begin backup;

@/u01/oracle/jiaoben/bf2.sql

alter database end backup;

2、表空間級備份:

1)alter tablespace begin backup;

2)cp表空間下資料檔案

3)alter tablespace end backup;

指令碼:spool /u01/oracle/home/thot.sql

select 'alter tablespace '||tablespace_name||' begin backup;'||chr(10)||'ho cp '||file_name||' /u01/oracle/home/'||chr(10)||'alter tablespace '||tablespace_name||' end backup;'||chr(10) from dba_data_files;

spool off

start /u01/oracle/home/thot.sql

ho rm /u01/oracle/home/thot.sql

alter database backup controlfile to '/u01/oracle/home/control.ctl';

create pfile='/u01/oracle/home/initorcl.ora' from spfile;

恢復:能離線的資料檔案即離線恢復,不能離線的啟動到mount階段恢復。

1、users表空間丟失還原方法:

1)將資料檔案離線

2)物理cp備份檔案

3)recover database

4)將資料檔案聯機

2、system表空間丟失還原方法:

1)啟動資料庫到mount狀態

2)物理cp備份檔案

3)recover database

4)alter database open;

3、所有資料檔案丟失:

1)shutdown abort

2)startup mount

3)cp所有備份物理檔案到資料檔案目錄

4)recover database

5)alter database open

4、日誌檔案丟失

1)shutdown immediate

2)startup(自動掛住)

3)recover database until cancel

4)alter database open resetlogs

5、控制檔案丟失恢復

1)shutdown abort

2)startup(自動掛住)

3)將control檔案cp回原位置

4)alter database mount

5)recover database using backup controlfile; > auto

7)alter database open resetlogs

6、控制檔案、日誌檔案、資料檔案丟失

1)shutdown abort

2)startup(自動掛住)

3)將control檔案cp回原位置

4)alter database mount

5)cp所有資料檔案回原位置

6)recover database using backup controlfile until cancel

7)alter database open resetlogs

異機遷移恢復+小版本公升級:(oracle 11g 11.2.0.1~oracle 11g 11.2.0.4

1、將熱備份檔案及歸檔日誌傳至目標機器

2、startup pfile='/備份pfile檔案' mount;

3、recover database using backup controlfile until cancel;

4、alter database open upgrade resetlogs;

MySQL備份與恢復之熱備

冷備是把資料庫服務,比如mysql,oracle停下來,然後使用拷貝 打包或者壓縮命令對資料目錄進行備份 那麼我們很容易想到熱備就是 一 熱備 在上兩篇文章 mysql備份與恢復之冷備,mysql備份與恢復之真實環境使用冷備 中,我們提到了冷備和真實環境中使用冷備。那從這篇文章開始我們看下熱備。顯然...

mysql熱拷貝 MySQL備份與恢復之熱拷貝

示意圖熱備模擬 第一步,熱拷貝 123 root serv01 databackup mysqlhotcopy uroot p123456 database larrydb larrydb hostcopy.sqlcan t locate dbi.pmin inc inccontains usr l...

mysql熱拷貝 MySQL備份與恢復之熱拷貝

熱備也就是在mysql或者其他資料庫服務在執行的情況下進行備份。本文分享另外一種備份的方法,也就是熱拷貝。熱拷貝跟熱備很類似,二 示意圖 三 熱備模擬 第一步,熱拷貝 root serv01 databackup mysqlhotcopy uroot p123456 database larrydb...