本帖最后由 郑全 于 2019-8-18 16:20 编辑
数据库做了备份,一直没有机会进行恢复(其实永远没有机会恢复也好,说明系统很健壮),心里总是憋得慌,如果哪天出现问题,需要恢复时,备份不可用怎么办,有人说找一个异机恢复不就得了,关键你要有机器可用,而且要安装一堆软件,以及配套的设备,比如磁带库等,麻烦,
能否在原机器上进行恢复,但又不恢复,什么,有点绕口令哈。就是在原机上模拟恢复,只是验证一下备份到磁盘,磁带的备份的有效性,并不真正恢复。
真的吗,oracle有这种功能吗 ?
真的,oracle 12c r1开始,就有这样的功能了,不信,我们往下看:
1.先看看版本嘛
RMAN> select * from v$version;
BANNER CON_ID
--------------------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0
PL/SQL Release 12.1.0.2.0 - Production 0
CORE 12.1.0.2.0 Production 0
TNS for Linux: Version 12.1.0.2.0 - Production 0
NLSRTL Version 12.1.0.2.0 - Production 0
2.看看控制文件能否恢复到一天前
RMAN> restore controlfile until time 'sysdate-1' validate;
Starting restore at 18-AUG-19
using channel ORA_DISK_1
channel ORA_DISK_1: starting validation of datafile backup set
channel ORA_DISK_1: reading from backup piece +FRA/ORCL/BACKUPSET/2019_08_17/ncsnf0_tag20190817t124952_0.261.1016542289
channel ORA_DISK_1: piece handle=+FRA/ORCL/BACKUPSET/2019_08_17/ncsnf0_tag20190817t124952_0.261.1016542289 tag=TAG20190817T124952
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
Finished restore at 18-AUG-19
哇,还真的在读哈 。
3.看看参数文件可否
RMAN> restore spfile until time 'sysdate-1' validate;
Starting restore at 18-AUG-19
using channel ORA_DISK_1
channel ORA_DISK_1: starting validation of datafile backup set
channel ORA_DISK_1: reading from backup piece +FRA/ORCL/BACKUPSET/2019_08_17/ncsnf0_tag20190817t124952_0.261.1016542289
channel ORA_DISK_1: piece handle=+FRA/ORCL/BACKUPSET/2019_08_17/ncsnf0_tag20190817t124952_0.261.1016542289 tag=TAG20190817T124952
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
Finished restore at 18-AUG-19
RMAN>
RMAN>
4.看看数据库呢
RMAN> restore database until time 'sysdate-1' validate;
Starting restore at 18-AUG-19
using channel ORA_DISK_1
channel ORA_DISK_1: starting validation of datafile backup set
channel ORA_DISK_1: reading from backup piece +FRA/ORCL/BACKUPSET/2019_08_17/nnndf0_tag20190817t124952_0.260.1016542193
channel ORA_DISK_1: piece handle=+FRA/ORCL/BACKUPSET/2019_08_17/nnndf0_tag20190817t124952_0.260.1016542193 tag=TAG20190817T124952
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: validation complete, elapsed time: 00:00:03
Finished restore at 18-AUG-19
5.如果有磁带的情况,能否验证呢
RMAN> run{
2> allocate channel c1 device type sbt;
3> restore database validate;
4> }
released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=266 device type=SBT_TAPE
channel c1: Oracle Secure Backup
Starting restore at 18-AUG-19
new media label is "rman-000005,rman-000007,rman-000008,rman-000009,rman-000010,rman-000011" for piece "07u9hdc7_1_1"
channel c1: starting validation of datafile backup set
channel c1: reading from backup piece 07u9hdc7_1_1
channel c1: piece handle=07u9hdc7_1_1 tag=TAG20190818T161503
channel c1: restored backup piece 1
channel c1: validation complete, elapsed time: 00:00:45
Finished restore at 18-AUG-19
released channel: c1
看到了吧,oracle12c 硬是可以哈。你还可以看看以下命令,具体就不演示了,有新发现,不要忘了到思庄论坛说一声哈。
restore preview;
restore validate header;
|