Oracle 基于 RMAN 的不完全恢复(incomplete recovery by RMAN)(四)

2014-11-24 17:54:20 · 作者: · 浏览: 3
base opened


RMAN> host;


[oracle@node1 ~]$ more query_t2.sh
#!/bin/bash
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi


export ORACLE_SID=oradb
sqlplus -S /nolog <connect scott/tiger
select * from scott.t2;
exit;
EOF
exit


-->验证结果,记录Robinson已经被恢复
[oracle@node1 ~]$ ./query_t2.sh


ID DT
---------- --------------------
Robinson 20130705 10:08:15


[oracle@node1 ~]$ exit
exit
host command complete


-->新的incarnation已经被产生,为3
RMAN> list incarnation;


List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 ORADB 2557712192 PARENT 1 20090813 23:00:48
2 2 ORADB 2557712192 PARENT 754488 20130111 17:37:07
3 3 ORADB 2557712192 CURRENT 1365530 20130705 10:37:15


b、基于SCN的不完全恢复
RMAN> shutdown immediate;
RMAN> startup mount;
RMAN> reset database to incarnation 2; --->在此需要reset incarnation
database reset to incarnation 2


RMAN> run{
2> set until scn 1365679;
3> restore database;
4> recover database;
5> alter database open resetlogs;}


executing command: SET until clause


Starting restore at 20130705 11:01:14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=25 device type=DISK


channel ORA_DISK_1: starting datafile backup set restore
......................
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 20130705 11:03:05


Starting recover at 20130705 11:03:06
using channel ORA_DISK_1


starting media recovery


archived log for thread 1 with sequence 27 is already on disk as file /u02/DB/oradb/arch/2013_07_05/o1_mf_1_27_8xd9c0f0_.arc
.............................
archived log for thread 1 with sequence 31 is already on disk as file /u02/DB/oradb/arch/2013_07_05/o1_mf_1_31_8xdcg1wc_.arc
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_27_8xd9c0f0_.arc thread=1 sequence=27
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_28_8xdbcrht_.arc thread=1 sequence=28
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_29_8xdbnqx9_.arc thread=1 sequence=29
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc thread=1 sequence=30 --->该日志包含记录Jackson
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_31_8xdcg1wc_.arc thread=1 sequence=31
media recovery complete, elapsed time: 00:00:10 --->此时apply到了31(不包含sequence 31的内容)
Finished recover at 20130705 11:03:19


database opened


RMAN> host;


-->验证结果,记录Jackson已经被恢复
[oracle@node1 ~]$ ./query_t2.sh


ID DT
---------- --------------------
Robinson 20130705 10:08:15
Jackson 20130705 10:11:27


c、基于sequence的不完全恢复
RMAN> shutdown immediate;
RMAN> startup mount;
RMAN> reset database to incarnation 2;
RMAN> run{
2> set until sequence 32;
3> restore database;
4> recover database;
5> alter database open resetlogs;}


executing command: SET until clause


Starting restore at 05-JUL-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK
...................
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 05-JUL-13


Starting recover at 05-JUL-13
using channel ORA_DISK_1


starting media recovery
...................................
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc thread=1 sequence=