oracle用备份的控制文件恢复后不用resetlogs打开方式的恢复

在一般恢复备份 的控制文件,打开数据库 都要 用resetlogs 重置日志这种方式,

这是因为备份的控制文件恢复后,没有最新的当前在线日志信息 ,而重建控制文件

就 可以用 NORESETLOGS  这种方式打开

这是因为:

备份的控制文件里面有一个 截止 SCN
.F S ?1]GI1`�VB$L467815 正常关闭的数据库的控制文件里面也 有一个截止scnITPUB个人空间E{/_jV3@/;d/
正 常打开的数据库的控制文件截止scn是无穷大(crash 也是)ITPUB个人空间$y c5wC3gU
重新创建控制文件的截止SCN也是无穷大,也就是apply日志文件直到scn达到截止scn,于是这就导致你 应用完了所有归档的日志还没有达到这无穷大,open的时候数据库认为是非正常关闭进行崩溃恢复,自动应用了所有联机日志

操作方法:

使 用旧的控制文件mount 然后 alter database  backup  controlfile to  trace ,restore database  然后手工创建控制文件,使用 reuse database  pubtest  noresetlogs .这样就可以 recover database 自动恢复并open database 而不用 resetlogs 了ITPUB个人空间'S6s1HPR g{

以下是测试过程:

9.2.0.4版本

1.先用rman备份数 据数据

rman>backup database format 'e:/testbk/%U.bak';

2.插入数据

SQL> create table test tablespace users as select rownum id from dba_objects;

Table created.

SQL> select count(*) from test;

  COUNT(*)
"I$o6w Wm467815 ----------ITPUB个人空 间&S9f0m#H!h!N6E
      6441

SQL> alter system switch logfile;

System altered.

SQL> insert into test select * from test;

6441 rows created.

SQL> commit;

Commit complete.

SQL> select count(*) from test;

  COUNT(*)
+~*d!F Q /h F467815 ----------ITPUB个人空间#];H6h T/[8y
     12882

SQL> exit
or*} t#t.d+j467815 Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
^-z,Q"z�Q7`%s2J~fl467815 With the Partitioning, OLAP and Oracle Data Mining optionsITPUB个人空间6L;I z ~c7aH,y
JServer Release 9.2.0.8.0 - Production

C:/Documents and Settings/Paul Yi>sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.8.0 - Production on Tue Aug 12 10:17:33 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

ITPUB个人空间 T/v}qXA'c K
Connected to:ITPUB个人空间U+a,w8c rP;MQ
Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
2I7lcC)vy467815 With the Partitioning, OLAP and Oracle Data Mining options
WM;Py D?_3~*y-f0vF467815 JServer Release 9.2.0.8.0 - Production

SQL> shutdown immediate;
i_{ m ai.Lot467815 Database closed.
QV7[@8]#_ Y467815 Database dismounted.
j(hB2w"q"HH467815 ORACLE instance shut down.ITPUB个人空间c*LC M%_ov
SQL> exit
A5zMh!q'|4~ h3R:h$`.L467815 Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - ProductionITPUB个人空 间!B&~QJ5J;`e/kL _C
With the Partitioning, OLAP and Oracle Data Mining options
h./)I"I~ e"e7F�B n467815 JServer Release 9.2.0.8.0 - Production

C:/Documents and Settings/Paul Yi>rman target /

Recovery Manager: Release 9.2.0.8.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area     101785012 bytes

Fixed Size                      454068 bytes
th0t}3N.C;G$O467815 Variable Size                 75497472 bytesITPUB个人 空间�TrnX4M)zG
Database Buffers              25165824 bytes
W'POO*n4xjr7h S�m467815 Redo Buffers                    667648 bytes

RMAN> set dbid=799229701

executing command: SET DBID

RMAN> restore controlfile from 'd:/backup/C-799229701-20080812-00';

Starting restore at 12-AUG-08

using channel ORA_DISK_1
;_-ts0f O(S i[467815 channel ORA_DISK_1: restoring controlfile
7`9} i�T1FE F[/]467815 channel ORA_DISK_1: restore complete
0T)b)cz|i@467815 replicating controlfile
,U ]m /t8D467815 input filename=D:/ORACLE/ORADATA/PUBTEST/CONTROL01.CTL
3jw1a6^M*@V3]`467815 output filename=D:/ORACLE/ORADATA/PUBTEST/CONTROL02.CTLITPUB个人空间G,u3xB/Z9d^)u
output filename=D:/ORACLE/ORADATA/PUBTEST/CONTROL03.CTL
4G/{yE$Ht8R467815 Finished restore at 12-AUG-08

RMAN> restore database;

RMAN> alter database mount;

database mounted

RMAN> restore database;

Starting restore at 12-AUG-08

using channel ORA_DISK_1ITPUB个人空间2cn7p5[U;V5z}
channel ORA_DISK_1: starting datafile backupset restoreITPUB个人空间l @&RB PX7I%r%/
channel ORA_DISK_1: specifying datafile(s) to restore from backup setITPUB个人空间 O5y.l8NwT
restoring datafile 00001 to D:/ORACLE/ORADATA/PUBTEST/SYSTEM01.DBF
*Ihrbt3r ]#u467815 restoring datafile 00002 to D:/ORACLE/ORADATA/PUBTEST/UNDOTBS01.DBFITPUB 个人空间3j:K&Q]}F/?F L$`9D
restoring datafile 00003 to D:/ORACLE/ORADATA/PUBTEST/EXAMPLE01.DBF
X0UC6K N%/0B467815 restoring datafile 00004 to D:/ORACLE/ORADATA/PUBTEST/INDX01.DBF
b6Jh-lFw1D1j467815 restoring datafile 00005 to D:/ORACLE/ORADATA/PUBTEST/TOOLS01.DBF
$^#f^h6~/T E Q467815 restoring datafile 00006 to D:/ORACLE/ORADATA/PUBTEST/USERS01.DBF
dr1y(yy467815 channel ORA_DISK_1: restored backup piece 1
'u2[;M$t1T467815 piece handle=E:/TESTBK/4HJNRFDE_1_1.BAK tag=TAG20080812T101302 params=NULL
0d(]5Y t{C/3[g467815 channel ORA_DISK_1: restore completeITPUB个人空间Q9Ey$N](z?p
Finished restore at 12-AUG-08

RMAN> recover database;

Starting recover at 12-AUG-08
.v:X'I[M2C467815 using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 10 is already on disk as file D:/ORACLE/ORADATA/PU
HR'Nx`q467815 BTEST/REDO3_01.LOG
w!/:Vg.}467815 archive log thread 1 sequence 11 is already on disk as file D:/ORACLE/ORADATA/PUITPUB个人空间s2D%nFnU
BTEST/REDO1_02.LOG
o;y;u4q)y467815 archive log filename=D:/ORACLE/ORADATA/PUBTEST/REDO3_01.LOG thread=1 sequence=10

archive log filename=D:/ORACLE/ORADATA/PUBTEST/REDO1_02.LOG thread=1 sequence=11

media recovery completeITPUB 个人空间5g1]2J p2gA
Finished recover at 12-AUG-08

RMAN> alter database open;

RMAN-00571: ===========================================================ITPUB个人空间$so,TsAeK
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
2Tsy7Z;Z7P0T467815 RMAN-00571: ===========================================================
} et9sC&[m467815 RMAN-03002: failure of alter db command at 08/12/2008 10:21:12
^o+i1M|Q0`;c467815 ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> exit;  --需要用restlogs 打开


9s)i7P(^�q.X467815 Recovery Manager complete.

C:/Documents and Settings/Paul Yi>sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.8.0 - Production on Tue Aug 12 10:21:40 2008

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


YuGX:]Dz%_6tM467815 Connected to:
7N?Y [I /};x-ga!k467815 Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
s$~z0kEY467815 With the Partitioning, OLAP and Oracle Data Mining optionsITPUB个人空间3EW~xC%[
JServer Release 9.2.0.8.0 - Production

SQL> shutdown immediate;ITPUB个人空间S0qo5cN.d
ORA-01109: database not open


f1f-I t.//yP467815 Database dismounted.
3{7_ Hyi`&nX467815 ORACLE instance shut down.
SJG%RH5Cl&[LG467815 SQL> startup mount;
e zf1vi$n E AY467815 ORACLE instance started.

Total System Global Area  101785012 bytesITPUB个人空间2d3M;H^1]
Fixed Size                   454068 bytes
{0^#J O6xk;WyX*[467815 Variable Size              75497472 bytesITPUB个人空 间.B h w/kyDc
Database Buffers           25165824 bytes
+l5uJ$jC'sT6C467815 Redo Buffers                 667648 bytes
A-X9?g er467815 Database mounted.ITPUB个人空间8Zy5| pb+Jg ]8]
SQL> alter database backup controlfile to trace;

Database altered.

SQL> shutdown immediate;
0w f*],](v0t467815 ORA-01109: database not open


"} VQ'C${S467815 Database dismounted.
flRvzZ467815 ORACLE instance shut down.ITPUB个人空间2o+qK4A6o"u0K
SQL> startup nomount;ITPUB个人空间R!c7P2Wr
ORACLE instance started.

Total System Global Area  101785012 bytesITPUB个人空间(XC%jhqGcg`
Fixed Size                   454068 bytesITPUB个人空 间?.A i J$@|np
Variable Size              75497472 bytesITPUB个人空间0V�D1t T kQA
Database Buffers           25165824 bytesITPUB个人空间2{/N/D M'a0D g1t
Redo Buffers                 667648 bytes
w:g*epX8}467815 SQL> CREATE CONTROLFILE REUSE DATABASE "PUBTEST" NORESETLOGS  ARCHIVELOGITPUB个人空间 Wkz nY-HoX9m,Z
  2  --  SET STANDBY TO MAXIMIZE PERFORMANCE
&i$/j G.f467815   3      MAXLOGFILES 5ITPUB个人空间 P&te3B#O�P(A
  4      MAXLOGMEMBERS 3ITPUB个人空间&Uq uP6QD^
  5      MAXDATAFILES 100ITPUB个人空间1VB}6EO.oH
  6      MAXINSTANCES 1
//POE'{c/~]467815   7      MAXLOGHISTORY 226
S6c3}y6Ik)a0/467815   8  LOGFILEITPUB个人空间 E*e'W/0s
  9    GROUP 1 (
4U~F'N%E:Q4}467815  10      'D:/ORACLE/ORADATA/PUBTEST/REDO1_02.LOG',
h'uK9C.N$s;e3a,} V O467815  11      'D:/ORACLE/ORADATA/PUBTEST/REDO1_01.LOG'ITPUB 个人空间'Y4KdK5Q-]|~H
 12    ) SIZE 100M,ITPUB个人空间J-R e7M)/ gFS$M
 13    GROUP 2 (
7w8uwN7A467815  14      'D:/ORACLE/ORADATA/PUBTEST/REDO2_01.LOG',
x;QY%jC} Dh467815  15      'D:/ORACLE/ORADATA/PUBTEST/REDO2_02.LOG'ITPUB 个人空间 E3]:E RdMay�?^
 16    ) SIZE 100M,
.PW:vzz6Jq8I467815  17    GROUP 3 (
%ufE${[467815  18      'D:/ORACLE/ORADATA/PUBTEST/REDO3_01.LOG',ITPUB 个人空间"CX#V6GA#q]0_o
 19      'D:/ORACLE/ORADATA/PUBTEST/REDO3_02.LOG'ITPUB 个人空间{Gi8y&?L.LP
 20    ) SIZE 100MITPUB个人空间2y^8a+^D A
 21  -- STANDBY LOGFILE
dC+C/F"}8C$K:S E/p n467815  22  DATAFILEITPUB个人空间 k5ZN"Br?�Zm X
 23    'D:/ORACLE/ORADATA/PUBTEST/SYSTEM01.DBF',ITPUB 个人空间+iQ+d{U
 24    'D:/ORACLE/ORADATA/PUBTEST/UNDOTBS01.DBF',
N6in#`9o2}w467815  25    'D:/ORACLE/ORADATA/PUBTEST/EXAMPLE01.DBF',ITPUB 个人空间&xDWIo]K
 26    'D:/ORACLE/ORADATA/PUBTEST/INDX01.DBF',
p$_WDS,nho FuY467815  27    'D:/ORACLE/ORADATA/PUBTEST/TOOLS01.DBF',
/"I!G&}J�Y7h467815  28    'D:/ORACLE/ORADATA/PUBTEST/USERS01.DBF'ITPUB 个人空间0d yR'N!X%{}
 29  CHARACTER SET ZHS16GBKITPUB个人空间9Z8}3Oo(FN#R
 30  ;

Control file created.

SQL> recover database;ITPUB个人空间%f2Gio,Dmz X}
Media recovery complete.
0z(S8X8B'f]467815 SQL> alter database open;

Database altered.

SQL> archive log list;
_ kz+e(M4}I![467815 Database log mode              Archive ModeITPUB个人空 间L/rBu}yY}
Automatic archival             EnabledITPUB个人空间&u)AF _*Xs?8HU
Archive destination            d:/archpaul
m�_%}'SS4V467815 Oldest online log sequence     10 ITPUB个人空间 (Y7fT6b Tc%]
Next log sequence to archive   12ITPUB个人空间'M{_ Gjq&y0i&tCS
Current log sequence           12
n cL` kn(N|467815 SQL> select count(*) from test;

  COUNT(*)ITPUB个人 空间9}3iiS'RL UG
----------
yf ?,N"c^)K`G467815      12882

SQL>

可以看到日志序列不用重置

 

原文:http://space.itpub.net/7199859/viewspace-423083

你可能感兴趣的:(oracle用备份的控制文件恢复后不用resetlogs打开方式的恢复)