NBU Rman異機恢復Oracle

背景:HostA上oracle通過NBU進行RMAN備份至帶庫,從HostB上恢復該庫;
目的:在丟失了一部分數據的情況下,但因爲沒有足夠的空間不能做整庫恢復,只想恢復部分表;
so假設:源主機HostA,目標主機HostB,NBUMaster主機Po,Oracle_sid均爲test,
Oracle用戶均爲ora。
步驟:
1、增加Po主機上文件
[Po:root]#touch /usr/openv/netbackup/db/altnames/No.Restrictions
//取消nbu的異機恢復限制
2、修改Po主機上文件,修改參數
[Po:root]#vi /usr/openv/netbackup/bp.conf
FORCE_RESTORE_MEDIA_SERVER = HostA HostB
  這步需要重啓netbackup
下面開始恢復步驟(均爲ora用戶操作)
3、copy spfile
在HostA上test數據庫的pfile(create pfile from spfile)ftp至HostB中的
   $ORACLE_HOME/db下
4、HostB上,密碼文件、相應的dump目錄
   [HostB:ora]#orapwd file=<fname> password=<password> entries=<users>
   [HostB:ora]#mkdir $admin/test/*dump
5、啓動數據庫至nomount
   [HostB:ora]#sqlplus / as sysdba
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 1526726656 bytes
Fixed Size                   2191720 bytes
Variable Size             1430245016 bytes
Database Buffers           83886080 bytes
Redo Buffers               10403840 bytes
6、登錄catalog,進行rman恢復
[HostB:ora]#rman target / catalog user/pwd@rman
connected to target database: TEST (not mounted)
connected to recovery catalog database
7、set dbid(HostA上test庫的dbid)
RMAN> set dbid=2091611406
executing command: SET DBID
database name is "TEST" and DBID is 2091611406
8、恢復control file
RMAN> RUN {
2>       ALLOCATE CHANNEL D1 TYPE 'sbt_tape';
3>       send 'NB_ORA_SERV=Po,NB_ORA_CLIENT=HostA'; //一定需要NB_ORA_CLIENT,否則找不到介質
4>       RESTORE CONTROLFILE;
5>       RELEASE CHANNEL D1;
6>       }
allocated channel: D1
channel D1: sid=166 devtype=SBT_TAPE
channel D1: VERITAS NetBackup for Oracle - Release 6.0 (2006110304)
sent command to channel: D1
Starting restore at 2009-05-11:21:24:58
channel D1: starting datafile backupset restore
channel D1: restoring control file
channel D1: reading from backup piece c-3381955389-20090511-02
channel D1: restored backup piece 1
piece handle=c-3381955389-20090511-02 tag=TAG20090511T170809
channel D1: restore complete, elapsed time: 00:01:47
output filename=/test/control01.ctl
output filename=/test/control02.ctl
output filename=/test/control03.ctl
Finished restore at 2009-05-11:21:26:56
released channel: D1
9、控制文件修復成功,將庫alter至mount狀態
RMAN> alter database mount;
database mounted
10、恢復數據庫
RMAN> run {
2>       ALLOCATE CHANNEL D1 TYPE 'SBT_TAPE';
3>       send 'NB_ORA_SERV=Po,NB_ORA_CLIENT=HostA';
4>       restore database skip tablespace users;//屏蔽不想恢復的users表空間
6>       recover database SKIP FOREVER TABLESPACE users;
5>     RELEASE CHANNEL D1;
7>   }
allocated channel: D1
channel D1: sid=44 devtype=SBT_TAPE
channel D1: VERITAS NetBackup for Oracle - Release 6.0 (2006110304)
sent command to channel: D1
Starting restore at 2009-05-11:21:46:50
channel D1: starting datafile backupset restore
channel D1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /test/sysaux01.dbf
channel D1: reading from backup piece bk_2_1_686595521
channel D1: restored backup piece 1
piece handle=bk_2_1_686595521 tag=HOT_DB_BK_LEVEL0
channel D1: restore complete, elapsed time: 00:02:26
channel D1: starting datafile backupset restore
channel D1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /test/system01.dbf
channel D1: reading from backup piece bk_1_1_686595521
channel D1: restored backup piece 1
piece handle=bk_1_1_686595521 tag=HOT_DB_BK_LEVEL0
channel D1: restore complete, elapsed time: 00:02:57
channel D1: starting datafile backupset restore
channel D1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /test/undotbs01.dbf
channel D1: reading from backup piece bk_3_1_686595521
channel D1: restored backup piece 1
piece handle=bk_3_1_686595521 tag=HOT_DB_BK_LEVEL0
channel D1: restore complete, elapsed time: 00:01:55
Finished restore at 2009-05-11:21:54:23
Starting recover at 2009-05-11:21:54:24
starting media recovery
channel D1: starting archive log restore to default destination
channel D1: restoring archive log
archive log thread=1 sequence=5
channel D1: reading from backup piece al_8_1_686595863
channel D1: restored backup piece 1
piece handle=al_8_1_686595863 tag=TAG20090511T170423
channel D1: restore complete, elapsed time: 00:01:57
archive log filename=/oracle10/app/oracle/product/10.2.0/dbs/arch1_5_686569151.dbf thread=1 sequence=5
unable to find archive log
archive log thread=1 sequence=6
released channel: D1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 05/11/2009 21:56:39
RMAN-06054: media recovery requesting unknown log: thread 1 seq 6 lowscn 608603
recover成功,因爲沒有恢復歸檔,所以會報一些錯,這裏忽略。
11,open數據庫
RMAN> alter database open resetlogs;
database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
數據庫打開成功,over!

一些tips:
1、pfile參數需要修改,否則起庫可能會報錯,內存等參數肯定在恢復庫的時候不會設置的和生產庫一樣大
SQL> startup nomount
ORA-00439: feature not enabled: Real Application Clusters
(恢復rac的時候,要刪掉一些rac庫的參數)
SQL> startup nomount
ORA-27154: post/wait create failed
ORA-27300: OS system dependent operation:semget failed with status: 28
ORA-27301: OS failure message: No space left on device
ORA-27302: failure occurred at: sskgpcreates
(這個錯可能與process、sessions、主機信號量等參數有關)
2、設置錯了NB_ORA_CLIENT或是原數據庫文件所在目錄沒有創建,在restore控制文件或數據文件的時候都會報這個錯
ORA-19511: Error received from media manager layer, error text:
   Backup file <bk_5_1_686595657> not found in NetBackup catalog
3、設置名字或位置
set newname for datafile 'filename' or filenumber to 'newlocation' ;
設置時間
set until time "to_date('12/8/2004 14:00:00','mm/dd/yyyy hh24:mi:ss')";
4、restore database skip tablespace users;
   recover database skip forever tablespace users;
使用skip參數屏蔽不想要的表空間(10g)


btw:如果空間足夠,完全可以把rman備份集全部copy至HostB上恢復,雖然最簡單,但這樣即需要大量的空間,又會耗費很長的時間,在指想恢復部分表的情況下,這種方法動靜大了點。
關鍵點:nbu的一些配置文件參數(FORCE_RESTORE_MEDIA_SERVER,NB_ORA_CLIENT等參數)、restoredatabase的skip參數。

恢復rac的還沒來及做,下一步就要恢復真實數據了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章