码迷,mamicode.com
首页 > 其他好文 > 详细

rman全备份异机恢复

时间:2015-02-11 16:13:33      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

一、测试环境

[oracle@localhost ~]$ uname -a
Linux localhost.localdomain 2.6.32-131.0.15.el6.x86_64 #1 SMP Tue May 10 15:42:40 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux
[oracle@localhost ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Sun Feb 8 18:14:09 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun Feb 8 18:14:36 2015

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1380300748)

RMAN>

二、具体步骤

1.创建备份集

RMAN>backup as compressed backupset databse plus archivelog;

2.创建环境,(dbname保持一致)

3.将备份拷贝新环境可以访问的路径

4.启动RMAN,还原spfile 到pfile中。

(利用rman的dummy数据库名,启动到nomount状态)
RMAN> restore spfile to pfile /u01/app/product/11.2.0/dbhome_1/dbs/initORCL.ora from /u01/app/testRMAN/autobackup/2015_02_08/o1_mf_s_871152044_bfgh9f42_.bkp;

5.修改pfile中相关文件的路径

6.关闭数据库

7.利用该pfile重新启动数据库到nomount状态

8.restore控制文件

RMAN>restore controlfile from /u01/app/testRMAN/autobackup/2015_02_08/o1_mf_s_871152044_bfgh9f42_.bkp;

9.修改数据库到mount状态

RMAN>alter database mount;

10.至此就可以读出数据文件的具体位置

 (1) 查看数据文件及编号
    $ sqlplus / as sysdba;
    select file#,name from v$datafile;
    
    (2) 查看联机日志文件
    select member from v$logfile;
    
    (3) 查看临时文件
    SQL> select name from v$tempfile
    
    (4) 查看备份集的位置
    RMAN>list backup;

11.这样的话就有两个选择

a.根据现有控制文件中的路径,在新的数据环境下创建相关目录,将备份集拷贝到对应目录,还原数据库。
b.重新注册备份集,修改控制文件中各个数据文件的名称,还原数据库。 在此演示第二种情况: (
1).恢复了控制文件之后将备份集注册到控制文件 RMAN>catalog start with /u01/app/testRMAN/; (2)恢复数据文件 RMAN> RUN { SET NEWNAME FOR DATAFILE 1 to /u01/app/oracle/oradata/orcl/system01.dbf; SET NEWNAME FOR DATAFILE 2 to /u01/app/oracle/oradata/orcl/undotbs1.dbf; SET NEWNAME FOR DATAFILE 3 to /u01/app/oracle/oradata/orcl/sysaux01.dbf; SET NEWNAME FOR DATAFILE 4 to /u01/app/oracle/oradata/orcl/users01.dbf; SET NEWNAME FOR DATAFILE 5 to /u01/app/oracle/oradata/orcl/undotbs2.dbf; RESTORE DATABASE; SWITCH DATAFILE ALL; }; (3)修改联机日志文件的路径 # su - oracle $ sqlplus / as sysdba; SQL> alter database rename file /u01/app/oracle/redo101.log to /u01/app/oracle/oradata/orcl/redo101.log (4)尽量恢复数据
recover database until cancel;
  注:如果数据库仍然出现SCN不一致的情况,在参数文件中添加隐含参数_allow_resetlogs_corruption=true启动数据库,这时候可以expdp出需要的数据。

 

rman全备份异机恢复

标签:

原文地址:http://www.cnblogs.com/Alex-Zeng/p/4286285.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!