RMAN中,restore(还原)与(recover)恢复具有不同的含义。还原指访问先前生成的备份集,从中得到一个或多个对象,然后在磁盘上的某个位置还原这些文件。还原与恢复是分离的。恢复是一个使数据库与给定时间点相一致以保证能够打开数据库的进程,该进程是通过应用重做(联机日志和归档日志)来完成的。
1. 先恢复数据库的参数文件
--下面的例子是在自动备份控制文件且使用默认配制下还原参数文件
EG:set oracle_sid=olcn Rman target / Set dbid=3652154; Startup nomount;
Restore spfile from autobackup; Shut down immediate
--自动备份控制文件并指定备份集还原
EG:set oracle_sid=olcn Rman target / Set dbid=3652154; Startup nomount;
Run { set controlfile autobackup format for device type disk to ‘c:/backup/%F’;
Allocate channel c1 device type disk; restore spfile from autobackup ; }
可以使用maxseq和maxdays参数在超过默认天数(10)的时间周期内向后查找控制文件备份集。Eg: restore spfile from autobackup maxseq 100 maxdays 10;
--未使用自动备份的控制文件还原参数文件
EG:set oracle_sid=olcn Rman target / Set dbid=3652154; Startup nomount;
Run { allocate channel c1 device type disk ;
Restore spfile to pfile ‘d:/bakcup/clne.ora’ from ‘d:/backup/ora_ock546543_1_1’; }
Shutdown immediate; sql>create spfile from pfile=’ d:/bakcup/clne.ora’;
2. 还原控制文件
与还原参数文件相似,这里只重点说一下未使用自动备份控制文件时的还原方法。
EG:set oracle_sid=olcn Rman target / Set dbid=3652154; Startup nomount;
RUN { allocate channel c1 device type disk ;
Restore controlfile to ‘d:/bakcup/clne.ora’ from ‘d:/backup/ora_pck54653_1_1’; }
Restore controlfile from ‘d:/bakcup/clne.ora’; startup mount;
3. NORACHIVELOG 恢复
--按上例恢复好参数和控制文件后,执行
Restore database; recover database noredo; alter database open resetlogs;
--在备份集时候指定了备份位置,还原如下
RUN { allocate channel c1 device type disk format ‘d:/backup/ ora_mck54983_1_1’;
Restore database ; recover database noredo; alter database open resetlogs;}
4. ARCHIVELOG恢复
与上例相似,只不过在recover database时不使用noredo 。
除了恢复库,还可以恢复表空间、数据文件。
Sql “alter tablespace users offline”; restore tablespace users; recover tablespace users;
Sql “alter database datafile 3 offline”; restore datafile 3;
Oracle在还原时候自动判断是否使用了增量备份策略,还会根据需要自动应用所需的增量备份集。
本文介绍了使用 RMAN 进行 Oracle 数据库恢复的过程,包括参数文件、控制文件的恢复方法,以及非归档日志模式和归档日志模式下的数据库恢复步骤。此外还涉及了如何恢复表空间和数据文件。
1068

被折叠的 条评论
为什么被折叠?



