RMAN 异机恢复
测试准备:
1.修改rman默認的備份路徑:
show parameter db_recovery_file_dest;
alter system set db_recovery_file_dest='/temp/archivedump' scope=spfile;
2.備份的腳本。旨在將所有文件備份在一個目錄上。(參數文件、控制文件、數據文件、歸檔文件)
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
allocate channel c5 device type disk;
crosscheck backup;
sql 'alter system archive log current';
backup database format '/tmp/archivedump/DB_%U';
sql 'alter system archive log current';
backup archivelog all format '/tmp/archivedump/arc_%U';
backup current controlfile format '/tmp/archivedump/ctl_%U';
backup spfile format '/tmp/archivedump/spf_%U';
crosscheck archivelog all;
DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-7';
delete noprompt expired backup;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
}
3.rman異機恢復 無dbid,只有備份.
rman異機恢復:
目標庫安裝oracle 及新建DB。
複製備份至目標庫 ftp
-------------------------------------------------------------
目标库
1. 進入rman,恢復出spfile,此刻DB還是新建的DB(test)
RMAN>restore spfile to '/tmp/DG01spile.ora' from '/tmp/archivedump1/spf_42r6iju c_1_1';
2. 根據sfile創建pfile,此刻DB還是新建的DB(test)
SQL>create pfile='/tmp/DG01pfile.ora' from spfile='/tmp/DG01spile.ora';
3. 關閉DB,開啟nomount狀態,開啟后為要恢復的DB(DG01)
SQL>shutdown immediate
SQL>startup nomount pfile='/tmp/DG01pfile.ora'
----------開啟報錯,是因為參數文件中很多目錄不存在,可根據/tmp/DG01pfile.ora中的
配置創建相應目錄,也可修改DG01pfile.ora的中相應目錄。
4.恢復controlfile。
RMAN> restore controlfile to '/oradata/DG01/control01.ctl' from '/tmp/archivedump1/ctl_41r6ijua_1_1';
5.關閉DB,再開啟mount狀態。
SQL> shutdown immediate;
SQL> startup mount pfile='/tmp/DG01pfile.ora'
6.恢復DB,重新進入RMAN,進rman時,會發現DBID就是源庫的DBID。
RMAN>crosscheck backup;
----根據crosscheck backup,或list backup可以看到備份的原來路徑。
創建相關恢復所需的路徑,進行恢復。
RMAN>restore database;
RMAN>recover database;
SQL>alter database open resetlogs;
最後DB可以打開,check数据是否正常