再次测试Oracle 10g支持跨resetlogs恢复

虽然很早以前就做过测试,Oracle 10g已经支持跨resetlogs恢复,但如果遇到离线备份+resetlogs,恢复不是很智能。
现在再做一下Oracle 10g rman跨resetlogs恢复。
首先对数据库做一个全备
RMAN> backup database format '/oradata/ora10r2_bak/database_full%t';

Starting backup at 19-DEC-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=153 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oradata/ora10r2/system01.dbf
input datafile fno=00003 name=/oradata/ora10r2/sysaux01.dbf
input datafile fno=00005 name=/oradata/ora10r2/zhou01.dbf
input datafile fno=00002 name=/oradata/ora10r2/undotbs01.dbf
input datafile fno=00004 name=/oradata/ora10r2/users01.dbf
channel ORA_DISK_1: starting piece 1 at 19-DEC-10
channel ORA_DISK_1: finished piece 1 at 19-DEC-10
piece handle=/oradata/ora10r2_bak/database_full738175416 tag=TAG20101219T164336 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:56
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 19-DEC-10
channel ORA_DISK_1: finished piece 1 at 19-DEC-10
piece handle=/oradata/ora10r2_bak/database_full738175472 tag=TAG20101219T164336 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 19-DEC-10

做几个归档切换
16:36:30 SQL> alter system switch logfile;

System altered.

16:45:29 SQL> /

System altered.

16:45:29 SQL> /

System altered.

16:45:37 SQL> /

System altered.

16:45:37 SQL> /

System altered.

16:45:38 SQL> /

System altered.

将其reselogs打开
16:45:39 SQL> shutdown abort
ORACLE instance shut down.
16:46:04 SQL> startup mount
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218968 bytes
Variable Size              88082024 bytes
Database Buffers          188743680 bytes
Redo Buffers                7168000 bytes
Database mounted.
16:46:28 SQL> recover database until cancel;
ORA-00279: change 588711 generated at 12/19/2010 16:45:39 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_28_738173171.dbf
ORA-00280: change 588711 for thread 1 is in sequence #28


16:46:37 Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/oradata/ora10r2/redo02.log
Log applied.
Media recovery complete.
16:47:09 SQL> alter database open resetlogs;

Database altered.

再做几个归档切换

16:47:28 SQL> alter system switch logfile;

System altered.

16:47:55 SQL> /

System altered.

16:47:55 SQL> /

System altered.

16:48:02 SQL> /

System altered.

16:48:03 SQL> /

System altered.

16:48:11 SQL> /

System altered.

现在就做一下跨resetlogs恢复
16:48:14 SQL> shutdown abort
ORACLE instance shut down.
16:48:31 SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@linuxsvr ora10r2]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Dec 19 16:48:55 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

16:48:55 SQL> startup mount
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218968 bytes
Variable Size              88082024 bytes
Database Buffers          188743680 bytes
Redo Buffers                7168000 bytes
Database mounted.
16:49:05 SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@linuxsvr ora10r2]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Dec 19 16:49:14 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: ORA10R2 (DBID=2053467729, not open)

RMAN> restore database;

Starting restore at 19-DEC-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oradata/ora10r2/system01.dbf
restoring datafile 00002 to /oradata/ora10r2/undotbs01.dbf
restoring datafile 00003 to /oradata/ora10r2/sysaux01.dbf
restoring datafile 00004 to /oradata/ora10r2/users01.dbf
restoring datafile 00005 to /oradata/ora10r2/zhou01.dbf
channel ORA_DISK_1: reading from backup piece /oradata/ora10r2_bak/database_full738175416
channel ORA_DISK_1: restored backup piece 1
piece handle=/oradata/ora10r2_bak/database_full738175416 tag=TAG20101219T164336
channel ORA_DISK_1: restore complete, elapsed time: 00:00:47
Finished restore at 19-DEC-10

查看incarnation,可以看到incarnation不变。
RMAN> list incarnation;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       ORA10R2  2053467729       PARENT  1          30-JUN-05
2       2       ORA10R2  2053467729       PARENT  446075     31-AUG-10
3       3       ORA10R2  2053467729       ORPHAN  526664     19-DEC-10
4       4       ORA10R2  2053467729       PARENT  527413     19-DEC-10
5       5       ORA10R2  2053467729       CURRENT 588713     19-DEC-10

归档信息显示如下:
---------- ------------- ------------ -----------------
        10        548077       548079            527413
        11        548079       548081            527413
        12        548081       548083            527413
        13        548083       548086            527413
        14        548086       548088            527413
        15        548088       568090            527413
        16        568090       568274            527413
        17        568274       568276            527413
        18        568276       568279            527413
        19        568279       568282            527413
        20        568282       568284            527413

SEQUENCE# FIRST_CHANGE# NEXT_CHANGE# RESETLOGS_CHANGE#
---------- ------------- ------------ -----------------
        21        568284       588294            527413
        22        588294       588700            527413
        23        588700       588702            527413
        24        588702       588705            527413
        25        588705       588707            527413
        26        588707       588709            527413
        27        588709       588711            527413
        28        588711       588713            527413
         1        588713       588814            588713
         2        588814       588816            588713
         3        588816       588819            588713

SEQUENCE# FIRST_CHANGE# NEXT_CHANGE# RESETLOGS_CHANGE#
---------- ------------- ------------ -----------------
         4        588819       588821            588713
         5        588821       588824            588713
         6        588824       588826            588713

58 rows selected.
再次查看resetlogs_change
04:50:08 SQL> select checkpoint_change#,resetlogs_change# from v$datafile_header;

CHECKPOINT_CHANGE# RESETLOGS_CHANGE#
------------------ -----------------
            588633            527413
            588633            527413
            588633            527413
            588633            527413
            588633            527413


可以看到成功跨越!
16:50:45 SQL> recover database;
ORA-00279: change 588633 generated at 12/19/2010 16:43:36 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_22_738173171.dbf
ORA-00280: change 588633 for thread 1 is in sequence #22


16:51:21 Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 588700 generated at 12/19/2010 16:45:28 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_23_738173171.dbf
ORA-00280: change 588700 for thread 1 is in sequence #23
ORA-00278: log file '/oradata/archlog/1_22_738173171.dbf' no longer needed for
this recovery


ORA-00279: change 588702 generated at 12/19/2010 16:45:29 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_24_738173171.dbf
ORA-00280: change 588702 for thread 1 is in sequence #24
ORA-00278: log file '/oradata/archlog/1_23_738173171.dbf' no longer needed for
this recovery


ORA-00279: change 588705 generated at 12/19/2010 16:45:37 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_25_738173171.dbf
ORA-00280: change 588705 for thread 1 is in sequence #25
ORA-00278: log file '/oradata/archlog/1_24_738173171.dbf' no longer needed for
this recovery


ORA-00279: change 588707 generated at 12/19/2010 16:45:37 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_26_738173171.dbf
ORA-00280: change 588707 for thread 1 is in sequence #26
ORA-00278: log file '/oradata/archlog/1_25_738173171.dbf' no longer needed for
this recovery


ORA-00279: change 588709 generated at 12/19/2010 16:45:38 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_27_738173171.dbf
ORA-00280: change 588709 for thread 1 is in sequence #27
ORA-00278: log file '/oradata/archlog/1_26_738173171.dbf' no longer needed for
this recovery


ORA-00279: change 588711 generated at 12/19/2010 16:45:39 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_28_738173171.dbf
ORA-00280: change 588711 for thread 1 is in sequence #28
ORA-00278: log file '/oradata/archlog/1_27_738173171.dbf' no longer needed for
this recovery


ORA-00279: change 588713 generated at 12/19/2010 16:47:17 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_1_738175637.dbf
ORA-00280: change 588713 for thread 1 is in sequence #1
ORA-00278: log file '/oradata/archlog/1_28_738173171.dbf' no longer needed for
this recovery


ORA-00279: change 588814 generated at 12/19/2010 16:47:55 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_2_738175637.dbf
ORA-00280: change 588814 for thread 1 is in sequence #2
ORA-00278: log file '/oradata/archlog/1_1_738175637.dbf' no longer needed for
this recovery


ORA-00279: change 588816 generated at 12/19/2010 16:47:55 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_3_738175637.dbf
ORA-00280: change 588816 for thread 1 is in sequence #3
ORA-00278: log file '/oradata/archlog/1_2_738175637.dbf' no longer needed for
this recovery


ORA-00279: change 588819 generated at 12/19/2010 16:48:01 needed for thread 1
ORA-00289: suggestion : /oradata/archlog/1_4_738175637.dbf
ORA-00280: change 588819 for thread 1 is in sequence #4
ORA-00278: log file '/oradata/archlog/1_3_738175637.dbf' no longer needed for
this recovery


Log applied.
Media recovery complete.

resetlogs_change#已经发生变化
04:52:16 SQL> select checkpoint_change#,resetlogs_change# from v$datafile_header;

CHECKPOINT_CHANGE# RESETLOGS_CHANGE#
------------------ -----------------
            588827            588713
            588827            588713
            588827            588713
            588827            588713
            588827            588713

04:52:21 SQL> select resetlogs_change# from v$database;

RESETLOGS_CHANGE#
-----------------
           588713

04:52:34 SQL> alter database open;

Database altered.

你可能感兴趣的:(thread,oracle,sql,sun)