RMAN 的向前滚动式不完全恢复

今天测试 rman 的回归测试:

RMAN> list backup summary;

List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
1       B  F  A DISK        13-JAN-12       1       1       NO         TAG20120113T170550
2       B  F  A DISK        13-JAN-12       1       1       NO         TAG20120113T170727


RMAN> list incarnation;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       EZHOU    4046377924       PARENT  1          30-JUN-05
2       2       EZHOU    4046377924       CURRENT 446075     27-AUG-11

---------------

下面开始创建table hui_1,hui_2,hui_3:

SQL> create table hui_1 as select * from scott.emp;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/rman/archive/
Oldest online log sequence     2
Next log sequence to archive   4
Current log sequence           4
SQL> create table hui_2 as select * from scott.emp;

Table created.

记住: 当sequence =4 的时候,create table ,那么这个时候的table 就可以在sequence =4 的时候恢复。

SQL> alter system switch logfile;

System altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/rman/archive/
Oldest online log sequence     3
Next log sequence to archive   5
Current log sequence           5
SQL> create table hui_3 as select * from scott.emp;

Table created.

SQL> alter system switch logfile;

System altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/rman/archive/
Oldest online log sequence     4
Next log sequence to archive   6
Current log sequence           6
SQL>

---------------------------------------

SQL> select group#, sequence#,status from v$log;

SQL> select group#, sequence#,status from v$log;

    GROUP#  SEQUENCE# STATUS
---------- ---------- ----------------
         1          5 ACTIVE
         2          6 CURRENT
         3          4 INACTIVE
        
举例:set until sequence 15,则 RMAN 会将日志应用到 14 为止。

--------
下面开始恢复:

先看一下:
SQL> select tname from tab where TNAME like 'HUI%';

TNAME
------------------------------
HUI_1
HUI_2
HUI_3

RMAN> run {
2> set until sequence 5;
3> restore database;
4> recover database;
5> }

根据set until sequence 5 ,就是到sequence =4 的情况,
根据上面的情况,应该是hui_2 被建立;

RMAN> alter database open resetlogs;

database opened

SQL> select table_name from dba_tables where table_name like 'HUI%';

TABLE_NAME
------------------------------
HUI_2
HUI_1

RMAN> list incarnation;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       EZHOU    4046377924       PARENT  1          30-JUN-05
2       2       EZHOU    4046377924       PARENT  446075     27-AUG-11
3       3       EZHOU    4046377924       CURRENT 491939     13-JAN-12


注意到,此时数据库的生命期已经改变了,incarnation 换到下一个了,
将数据库的生命期设置到2,这样才能使用之前在生命期2中所作的备份
此时:要想继续使用之前的备份和归档文件,则必须将数据库置于 incarnation=2 的生命周期中。

RMAN> reset database to incarnation 2;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of reset command on default channel at 01/13/2012 17:31:58
ORA-19910: can not change recovery target incarnation in control file

原因是要先到mount 状态:
shutdown immediate;
startup mount;
rman target /

RMAN> reset database to incarnation 2;

using target database control file instead of recovery catalog
database reset to incarnation 2

RMAN>

下面恢复以前sequence =6 的时候的table :hui_3,

RMAN> run{  
2> set until sequence 7;
3> restore database;
4> recover database;
5> }

ALTER DATABASE OPEN RESETLOGS;

SQL> SELECT TABLE_NAME FROM DBA_TABLES WHERE TABLE_NAME LIKE 'HUI%';

TABLE_NAME
------------------------------
HUI_3
HUI_2
HUI_1

 

你可能感兴趣的:(oracle,-,数据恢复)