数据库异机恢复 (RMAN)
1.講備份的文件copy至新機器上:
rsync -avlR /home/oracle/app/oracle/fast_recovery_area/ORCL/backupset/2018_05_10/ -e ssh 192.168.9.138:/(rsync命令無法執行的,則需要安裝。root 權限執行:yum install rsync -y)
2.恢復spfile
啟動數據庫至nomount狀態RMAN> restore spfile from ' /home/oracle/app/oracle/fast_recovery_area/ORCL/backupset/2018_05_10/o1_mf_ncsnf_TAG20180510T102038_fh7c4tp1_.bkp'
這個文件就是剛才copy過來的數據文件,其中mcsnf代表的控制文件和參數文件,nnndf表示數據文件,類型如下:-rw-r-----. 1 oracle oinstall 9.4M May 10 10:21 o1_mf_ncsnf_TAG20180510T102038_fh7c4tp1_.bkp-rw-r-----. 1 oracle oinstall 1.1G May 10 10:21 o1_mf_nnndf_TAG20180510T102038_fh7c3pgt_.bkp
3.恢復控制文件
RMAN> restore controlfile from ' /home/oracle/app/oracle/fast_recovery_area/ORCL/backupset/2018_05_10/o1_mf_ncsnf_TAG20180510T102038_fh7c4tp1_.bkp'
4.啟動至mount狀態
alter database mount
5.還原數據庫
restore database;
6.恢復數據庫
如果有歸檔日誌,則: recover database ;如果出現:Starting recover at 10-MAY-18using channel ORA_DISK_1starting media recoveryunable to find archived logarchived log thread=1 sequence=2RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 05/10/2018 14:33:02RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 2 and starting SCN of 1242586
則:recover database until scn 1242586
如果沒有歸檔日誌需要恢復,則:recover database noredo;若果還是報錯,如ORA-01113:file 1 nneds media recoveryORA-01110: data file 1 : '/home/oracle/app/oracle/oradata/orcl/system.dbf'則需添加隱藏參數,取消數據庫啟動前的一致性檢查即可:SQL>create pfile='/tmp/a.ora' from spfile;shutdown immediatevi /tmp/a.ora加上: *._allow_resetlogs_corruption=trueSQL>startup mount pfile='/tmp/a.ora'
7.open 數據庫
alter database open resetlogs;
(如果恢復的數據庫版本不一致,則會提示:
ORA-01092:ORACLE instance terminated. Disconnection forced
ORA-00704:bootstrap process failure
ORA-39700:database must be opened with UPGRADE option
Process ID:13147
Session ID:1 Serial number:5
則開啟數據庫需執行:alter upgrade open resetlogs;