oracle dbf恢复 Oracle 11g R2 备份与恢复

如何从另一个节点上将Rman备份恢复到本地不同的目录结构中

环境条件

  • Rman备份在节点1上
  • 数据库不得不将备份恢复到节点2上
  • 节点2和节点1上的目录结构并不相同。
  • Rman备份不得不传输到节点2的新的位置上进行使用。
  • 数据库备份恢复需要将数据文件恢复到节点2的新的目录结构中。

假设

  • 数据库备份在节点1的/node1/database/backup
  • 数据文件在节点1的/node1/database/prod
  • 数据库备份需要放到节点2的位置/node2/database/backup
  • 据库文件在节点2的恢复位置为/node2/database/prod
     

解决方法步骤 (基本步骤对10g以后版本都适用)
1) 对节点1上的数据库使用rman进行备份。 

$ rman target / 

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Feb 13 00:29:33 2007 
Copyright (c) 1982, 2005, Oracle. All rights reserved. 
connected to target database: ORA10G (DBID=3932056136) 


RMAN> backup database plus archivelog; 


Starting backup at 13-FEB-07 
current log archived 
using channel ORA_DISK_1 
channel ORA_DISK_1: starting archive log backupset 
channel ORA_DISK_1: specifying archive log(s) in backup set 
input archive log thread=1 sequence=143 recid=109 stamp=614392105 
channel ORA_DISK_1: starting piece 1 at 13-FEB-07 
channel ORA_DISK_1: finished piece 1 at 13-FEB-07 
piece handle=/node1/database/backup/o1_mf_annnn_TAG20070213T002825_2x21kbds 
_.bkp tag=TAG20070213T002825 comment=NONE 
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 
Finished backup at 13-FEB-07 

Starting backup at 13-FEB-07 
using channel ORA_DISK_1 
channel ORA_DISK_1: starting full datafile backupset 
channel ORA_DISK_1: specifying datafile(s) in backupset 
input datafile fno=00003 name=/node1/database/prod/sysaux01.dbf 
input datafile fno=00001 name=/node1/database/prod/system01.dbf 
input datafile fno=00002 name=/node1/database/prod/undotbs01.dbf 
input datafile fno=00004 name=/node1/database/prod/users01.dbf 
input datafile fno=00005 name=/node1/database/prod/1.dbf 
input datafile fno=00006 name=/node1/database/prod/sysaux02.dbf 
input datafile fno=00007 name=/node1/database/prod/undotbs02.dbf 
channel ORA_DISK_1: starting piece 1 at 13-FEB-07 
channel ORA_DISK_1: finished piece 1 at 13-FEB-07 
piece handle=/node1/database/backup/o1_mf_nnndf_TAG20070213T002827_2x21kd12 
_.bkp tag=TAG20070213T002827 comment=NONE 
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55 
Finished backup at 13-FEB-07 


Starting backup at 13-FEB-07 
current log archived 
using channel ORA_DISK_1 
channel ORA_DISK_1: starting archive log backupset 
channel ORA_DISK_1: specifying archive log(s) in backup set 
input archive log thread=1 sequence=144 recid=110 stamp=614392165 
channel ORA_DISK_1: starting piece 1 at 13-FEB-07 
channel ORA_DISK_1: finished piece 1 at 13-FEB-07 
piece handle=/node1/database/backup/o1_mf_annnn_TAG20070213T002925_2x21m6ty 
_.bkp tag=TAG20070213T002925 comment=NONE 
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 
Finished backup at 13-FEB-07 


Starting Control File and SPFILE Autobackup at 13-FEB-07 
piece handle=/u01/oracle/product/ora10g/dbs/c-3932056136-20070213-02 comment=NONE 
Finished Control File and SPFILE Autobackup at 13-FEB-07 


RMAN> exit

2) 将备份文件传输到节点2上:

  • 数据库备份片位置/node2/database/backup
  • 控制文件备份片位置/node2/database/backup
  • 参数文件如init.ora文件默认位置$ORACLE_HOME/dbs

3) 在节点2上,编辑修改pfile并调整相应环境参数,如:

  • user_dump_dest =  
  • background_dump_dest = 
  • control_files =

4) 修改好pfile并适配好。设置好Oracle在系统上的环境变量,并在将数据库启动到nomount状态。在节点2上启动rman:

[oracle@test-br test]$ export ORACLE_HOME=/u01/oracle/product/ora10g 
[oracle@test-br test]$ export ORACLE_SID=ora10g 
[oracle@test-br test]$ export PATH=$ORACLE_HOME/bin:$PATH 
[oracle@test-br test]$ rman target / 
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Feb 13 00:36:55 2007 
Copyright (c) 1982, 2005, Oracle.  All rights reserved. 
connected to target database (not started) 
RMAN> startup nomount 
Oracle instance started 
Total System Global Area     205520896 bytes 
Fixed Size                     1218508 bytes 
Variable Size                 75499572 bytes 
Database Buffers             121634816 bytes 
Redo Buffers                   7168000 bytes

5) 从备份片中恢复控制文件

RMAN> restore controlfile from  '/node2/database/backup/c-3932056136-20070213-02';  
Starting restore at 13-FEB-07  
using target database control file instead of recovery catalog  
allocated channel: ORA_DISK_1  
channel ORA_DISK_1: sid=155 devtype=DISK  
channel ORA_DISK_1: restoring control file  
channel ORA_DISK_1: restore complete,  
elapsed time: 00:00:02  
output filename=/node2/database/prod/control01.ctl  
Finished restore at 13-FEB-07 

6) mount数据库

RMAN > alter database mount      

7) 将从节点1传输过来的备份片进行catalog 

RMAN> catalog backuppiece '/node2/database/backup/o1_mf_annnn_TAG20070213T002925_2x21m6ty_.bkp'; 
RMAN> catalog backuppiece '/node2/database/backup/o1_mf_annnn_TAG20070213T002825_2x21kbds_.bkp'; 
RMAN> catalog backuppiece '/node2/database/backup/o1_mf_nnndf_TAG20070213T002827_2x21kd12_.bkp'; 

8) 使用以下命令了解可用的归档日志备份的序号。这可以帮助我们将数据库恢复直到最近的归档日志的位置为止。

我们假设备份中最新的归档日志序号为50.

RMAN > list backup of archivelog all;

9) 对重做日志文件进行重命名,这样就可以在新的目录位置下打开数据库。

SQL> alter database rename file '/node1/database/prod/redo01.log' to '/node2/database/prod/redo01.log'; 
...... 
...... 
...... 

10) 现在将数据库文件恢复到新位置并进行恢复。这里我们使用SET UNTIL SEQUENCE语句将数据库恢复到50号归档日志。

RMAN> run 
 { 
 set until sequence 51; 
 set newname for datafile 1 to '/node2/database/prod/sys01.dbf'; 
 set newname for datafile 2 to '/node2/database/prod/undotbs01.dbf'; 
 set newname for datafile 3 to '/node2/database/prod/sysaux01.dbf'; 
 set newname for datafile 4 to '/node2/database/prod/users01.dbf'; 
 set newname for datafile 5 to '/node2/database/prod/1.dbf'; 
 set newname for datafile 6 to '/node2/database/prod/sysaux02.dbf'; 
 set newname for datafile 7 to '/node2/database/prod/undotbs02.dbf'; 
 restore database; 
 switch datafile all; 
 recover database; 
 alter database open resetlogs; 
 } 

11) 确认临时文件建立及位置
确认临时文件目录位置,如果需要则进行重建:

SQL> select * from v$tempfile;
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE 'new tempfile path filename' REUSE;

猜你喜欢

转载自blog.csdn.net/liu_maclean/article/details/81114576