RMAN备份异机恢复

一、生产库中使用RMAN备份数据库
1、RMAN备份脚本


configure retention policy to redundancy 30; 
configure maxsetsize to 10g; 
configure controlfile autobackup on; 
configure controlfile autobackup format for device type disk to '/ora_backup/controlfile/%F'; 
crosscheck backup of database; 
crosscheck archivelog all; 
delete noprompt obsolete ; 
delete noprompt expired backup; 
delete noprompt backup completed before 'sysdate-30'; 
delete noprompt archivelog until time 'sysdate-5'; 
run { 
allocate channel c0 type disk; 
backup incremental level 0 database format '/ora_backup/full_db_%d_%s_%t_%p' tag="full_db_`date +'%y%m%d%H%M'`"; 
release channel c0 ; 

configure controlfile autobackup off; 


2、查看备份
[oracle@localhost nba]$ tree /ora_backup/
/ora_backup/
|-- controlfile
|   |-- c-829384100-20160103-07
|-- full_db_NBA_26_900192470_1


3、将备份文件拷贝到目标库的相同路径下




二、在目标库上恢复


1、使用RMAN启动DUMMY实例到nomount状态
[oracle@rhel5u8 ~]$ rman target /


RMAN> startup nomount;


RMAN> restore spfile to '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilenba.ora' from '/ora_backup/controlfile/c-829384100-20160103-07';


RMAN> restore controlfile to '/u01/app/oracle/oradata/nba/control01.ctl' from '/ora_backup/controlfile/c-829384100-20160103-07';


2、根据参数文件中指定的文件,创建相应目录
[oracle@rhel5u8 dbs]$ mkdir -p /u01/app/oracle/admin/nba/adump


[oracle@rhel5u8 dbs]$ mkdir -p u01/app/oracle/fast_recovery_area/nba


[oracle@rhel5u8 dbs]$ mkdir -p /u01/app/oracle/oradata/nba


[oracle@rhel5u8 dbs]$ cp /u01/app/oracle/oradata/nba/control01.ctl /u01/app/oracle/fast_recovery_area/nba/control02.ctl




3、重新启动数据库到mount状态
SQL> shut immediate
ORA-01507: database not mounted




ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.


Total System Global Area  622149632 bytes
Fixed Size    2255792 bytes
Variable Size  398459984 bytes
Database Buffers  218103808 bytes
Redo Buffers    3330048 bytes
Database mounted.




4、还原数据库(备份数据存放路径和生产库中RMAN备份路径相同)
RMAN> restore database ;




5、恢复数据库(根据提示,将生产库中的36号归档文件拷贝到指定目录)
SQL> recover database using backup controlfile;
ORA-00279: change 1362106 generated at 01/03/2016 21:27:51 needed for thread 1
ORA-00289: suggestion :/u01/app/oracle/fast_recovery_area/NBA/archivelog/2016_01_03/o1_mf_1_36_c8l95rbl_.arc
ORA-00280: change 1362106 for thread 1 is in sequence #36


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 1362467 generated at 01/03/2016 21:40:08 needed for thread 1
ORA-00289: suggestion :/u01/app/oracle/fast_recovery_area/NBA/archivelog/2016_01_03/o1_mf_1_37_%u_.arc
ORA-00280: change 1362467 for thread 1 is in sequence #37
ORA-00278: log file'/u01/app/oracle/fast_recovery_area/NBA/archivelog/2016_01_03/o1_mf_1_36_c8l95rbl_.arc' no longer needed for this recovery


ORA-00308: cannot open archived log'/u01/app/oracle/fast_recovery_area/NBA/archivelog/2016_01_03/o1_mf_1_37_%u_.arc'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3




6、根据提示还需要37号归档,但生产库中并没有37号归档,则实例恢复所需日志在生产库的联机日志中,将生产库当前日志拷贝到目标库的/home/oracle/redo01.log
SQL> recover database using backup controlfile;
ORA-00279: change 1362467 generated at 01/03/2016 21:40:08 needed for thread 1
ORA-00289: suggestion :/u01/app/oracle/fast_recovery_area/NBA/archivelog/2016_01_03/o1_mf_1_37_%u_.arc
ORA-00280: change 1362467 for thread 1 is in sequence #37


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/home/oracle/redo01.log
Log applied.
Media recovery complete.


7、使用resetlogs打开数据库。
SQL> alter database open resetlogs;


Database altered.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30373263/viewspace-2057834/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30373263/viewspace-2057834/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值