一.恢复的前提条件.
1. )日常备份都是成功的。至少有一次全备份及全备份以来的增量备份和Archivelog.
2. )原主机的OS及ORACLE版本与目标主机的OS及ORACLE版本保持一致.
3. )需要原数据库的下列信息:
1) IP Address, Hostname, Nbu media server/client
2) Oracle DB version, SID,DBID,Datafile Path,Controlfile Path,Archivelog Path
3) Catalog DB IP,SID/Service name ,user/password
4. )在目标主机上安装与原数据库版本相同的oracle软件 (Install type :Software only)
5. )在目标主机上安装Veritas 软件,安装类型与原主机一致 (media server or client)
二. 下面以aush49上的s1rel DB恢复到aush61为例对veritas及oracle进行配置.
1 )在目标主机上(aush61)配置veritas
1) Edit $ORACLE_HOME/bp.conf file (aush61) s3pis> cd $ORACLE_HOME (aush61) s3pis> vi bp.conf SERVER = aush06 /*master server host name*/ CLIENT_NAME = aush49 /*source host name ,如果aush49是media server则写 SERVER = aush49*/ CLINET_READ_TIMEOUT = 1800
2)Edit /usr/openv/netbackup/bp.conf ( aush61) aush61#vi bp.conf SERVER = aush06 /*master server name*/ CLIENT_NAME = aush49 /*source host name , 如果aush49是media server则写 SERVER = aush49*/ CLIENT_NAME = aush61 /*target host name */ VERBOSE = 5 CLIENT_READ_TIMEOUT = 1800
CLIENT_CONNECT_TIMEOUT = 1800
3) Touch a file on Master Server (aush06) aush06#cd /usr/openv/netbackup/db/altnames aush06#touch aush61 /*target host name */
2 ) 在master server (aush06)与目标主机(aush61)上配置/etc/hosts 文件
aush61#vi /etc/hosts 127.0.0.1 localhost 10.5.15.61 aush61 10.5.15.6 aush06 10.5.15.49 aush49 10.5.15.58 aush58
aush06#vi /etc/hosts 127.0.0.1 localhost 10.5.15.61 aush61 10.5.15.6 aush06 10.5.15.49 aush49 10.5.15.58 aush58
3 ) 在目标主机上(aush61)配置ORACLE.
1 )创建于原数据库(aush49)相同的oracle user/group : s3pis/dba
2 ) 配置s3pis环境变量
(aush61) s3pis> more .profileORACLE_HOME=/u01/s3pis;export ORACLE_HOMEORACLE_SID=s3rel;export ORACLE_SIDPATH=$PATH:$ORACLE_HOME/bin;export PATHPS1="(`hostname`) `whoami`> "LD_LIBRARY_PATH=$ORACLE_HOME/lib;export LD_LIBRARY_PATH
3 ) 安装与原数据库相同版本的Oracle 软件,安装类型:SOFTWARE ONLY.
4 ) 创建$ORACLE_HOME/network/admin/tnsnames.ora 文件连接catalog DB.
(aush61) s3pis> more tnsnames.oracatalog =(description= (address_list= (address=(protocol=tcp)(host=10.5.13.178)(port=1521)) ) (connect_data= (service_name=catalog) ) )
5 ) 创建pfile
如果有原数据库(s1rel db)的pfile 或spfile ,可以直接使用;如果没有可以手动创建pfile !
6 )创建与原数据库(s1rel db)相同的文件存放路径!
1) 根据对原数据库(s1rel )的日常维护信息,可以知道controlfile,datafile,archivelog file 的存取路径。可以通过link 方式在目标主机(aush61)上创建相应的目录,并赋予oracle 用户(s1pis)读写权限.
2) 如果要将数据文件恢复到不同位置,需要在恢复语句上用set newname 及switch datafile 的参数!
3) 根据pfile或spfile 创建cdump ,bdump ,udump 目录
三. 恢复步骤.
1) 使用pfile或spfile在目标主机(aush61)上启动数据库(s1rel)到nomount 状态
(aush61) s3pis> sqlplus "/ as sysdba";
SQL*Plus: Release 9.0.1.4.0 - Production on Thu Dec 9 11:00:24 2004
(c) Copyright 2001 Oracle Corporation. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile=/u01/s3pis/dbs/inits3rel.oraORACLE instance started.
Total System Global Area 806283128 bytesFixed Size 436088 bytesVariable Size 268435456 bytesDatabase Buffers 536870912 bytesRedo Buffers 540672 bytesSQL>
2.恢复控制文件
(aush61) s3pis> rman catalog auss3pis/auss3pis@catalog;
Recovery Manager: Release 9.0.1.4.0 - Production
(c) Copyright 2001 Oracle Corporation. All rights reserved.
connected to recovery catalog database
RMAN> set dbid=4227459251 (aush49 s3rel dbid )
executing command: SET DBID
RMAN> connect target /
connected to target database: (not mounted)
RMAN> run {2> allocate channel ch00 type 'sbt_tape';3> send 'nb_ora_serv=aush06';4> send 'nb_ora_client=aush49';5> restore controlfile;6> }allocated channel: ch00channel ch00: sid=11 devtype=SBT_TAPEchannel ch00: VERITAS NetBackup for Oracle - Release 4.5FP_3GA (2002121901)
sent command to channel: ch00
sent command to channel: ch00
Starting restore at 09-DEC-04
channel ch00: starting datafile backupset restorechannel ch00: restoring controlfileoutput filename=/u22/oradata/control01.ctlchannel ch00: restored backup piece 1piece handle=cntrl_3973_1_544399339 tag=null params=NULLchannel ch00: restore completereplicating controlfileinput filename=/u22/oradata/control01.ctloutput filename=/u22/oradata/control02.ctloutput filename=/u22/oradata/control03.ctlFinished restore at 09-DEC-04released channel: ch00
RMAN> exit
3.重新启动数据库到mount 状态
SQL> shutdown immediate;ORA-01109: database not open
Database dismounted.ORACLE instance shut down.SQL> startup mount pfile=/u01/s3pis/dbs/inits3rel.oraORACLE instance started.
Total System Global Area 806283128 bytesFixed Size 436088 bytesVariable Size 268435456 bytesDatabase Buffers 536870912 bytesRedo Buffers 540672 bytesDatabase mounted.SQL>
4.对数据库做基于时间点的恢复!
(aush61) s3pis> rman catalog auss3pis/auss3pis@catalog;
Recovery Manager: Release 9.0.1.4.0 - Production
(c) Copyright 2001 Oracle Corporation. All rights reserved.
connected to recovery catalog database
RMAN> set dbid=4227459251
executing command: SET DBID
RMAN> connect target /
connected to target database: S3REL (DBID=4227459251)
RMAN> run {2> allocate channel ch00 type 'sbt_tape';3> send 'nb_ora_serv=aush06';4> send 'nb_ora_client=aush49';5> set until time "to_date('12/8/2004 14:00:00','mm/dd/yyyy hh24:mi:ss')";6> restore database;7> recover database;8> sql "alter database open resetlogs";9> }
注:如果将数据文件恢复到与原路径不同的位置则按照如下写法:
\\RMAN> run {2> allocate channel ch00 type 'sbt_tape';3> send 'nb_ora_serv=aush06';4> send 'nb_ora_client=aush49';5> set until time "to_date('12/8/2004 14:00:00','mm/dd/yyyy hh24:mi:ss')";
6> set newname for datafile ‘filename’ or filenumber to ‘newlocation’ ;
7> restore database ;
8> switch datafile all;
}
RMAN> run {2> allocate channel ch00 type 'sbt_tape';3> send 'nb_ora_serv=aush06';4> send 'nb_ora_client=aush49';5> set until time "to_date('12/8/2004 14:00:00','mm/dd/yyyy hh24:mi:ss')";
6> set archivelog destination to ‘full path’ ;
}
//channel ch00: sid=11 devtype=SBT_TAPEchannel ch00: VERITAS NetBackup for Oracle - Release 4.5FP_3GA (2002121901)
sent command to channel: ch00
sent command to channel: ch00
executing command: SET until clause
Starting restore at 09-DEC-04
channel ch00: starting datafile backupset restorechannel ch00: specifying datafile(s) to restore from backup setrestoring datafile 00036 to /u23/oraindx/SMSR_I01.dbf
........................................................................................................
restoring datafile 00051 to /u23/oraindx/SMS_AV_04092.dbfchannel ch00: restored backup piece 1piece handle=bk_3947_1_544370120 tag=HOT_DB_BK_LEVEL0 params=NULLchannel ch00: restore completeFinished restore at 09-DEC-04
Starting recover at 09-DEC-04
channel ch00: starting incremental datafile backupset restorechannel ch00: specifying datafile(s) to restore from backup setdestination for restore of datafile 00070: /u22/oradata/SMS_ID_04121.dbfchannel ch00: restored backup piece 1piece handle=bk_3927_1_544280863 tag=HOT_DB_BK_LEVEL0 params=NULLchannel ch00: restore completechannel ch00: starting incremental datafile backupset restorechannel ch00: specifying datafile(s) to restore from backup set............................................................................................................
channel ch00: starting incremental datafile backupset restorechannel ch00: specifying datafile(s) to restore from backup setdestination for restore of datafile 00025: /u22/oradata/SCS_T01.dbfdestination for restore of datafile 00036: /u23/oraindx/SMSR_I01.dbfdestination for restore of datafile 00043: /u23/oraindx/SCS_I02.dbfdestination for restore of datafile 00059: /u23/oraindx/SMS_AV_04093.dbfchannel ch00: restored backup piece 1piece handle=bk_3931_1_544281553 tag=HOT_DB_BK_LEVEL0 params=NULLchannel ch00: restore complete
starting media recovery
channel ch00: starting archive log restore to default destinationchannel ch00: restoring archive logarchive log thread=1 sequence=2562channel ch00: restoring archive log..........................................................................................................
archive log filename=/u21/s3rel/archive/1_2574.dbf thread=1 sequence=2574archive log filename=/u21/s3rel/archive/1_2575.dbf thread=1 sequence=2575archive log filename=/u21/s3rel/archive/1_2576.dbf thread=1 sequence=2576archive log filename=/u21/s3rel/archive/1_2577.dbf thread=1 sequence=2577media recovery completeFinished recover at 09-DEC-04
sql statement: alter database open resetlogsreleased channel: ch00
RMAN>
恢复成功,数据库已经打开!