ORA-01152 file 1 was not restored from a sufficiently old backup解决过程

[oracle@localhost ~]$ export ORACLE_SID=ge
[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 29 19:03:33 2008

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

SQL> connect / as sysdba
Connected.
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/opt/oracle/oradata/ge/system01.dbf'

在打开数据库的时候出现上面的错误,解决过程如下:
错误原因分析:
是由于controlfile里所记录的scn与datafile里的scn不一致。比如从备份里restore出的controlfile上的scn < datafile上所记录的scn,因此理论上二种思路:
1、以old controlfile为准的,datafile上的scn是新的,这样存在着数据的不一致,要继续恢复下去,将datafile上的scn也要restore到与controlfile一致的情况,
但这样会丢失datafile上的数据。
2、就是以datafile上的scn为基准,将controlfile恢复到与datafile scn一致。

于是,在restore过后如果遭遇到ORA-01152之类的问题,可以这样来操作(实际上就是上面第二种思路的实现):


RMAN>RECOVER DATABASE; ---找出同步controlfile scn和datafile scn所需的archivelog,如果归档目录缺少所列出log就从备份里
---(比如说是在磁带里)取出来并放回归档目录,比如说所列的archivelog是1_215.dbf - 1_230.dbf。


然后进行时间点的数据恢复
RMAN> run{
2> allocate channel d1 type disk;
3> allocate channel d2 type disk;
4> set until sequence 27 thread 1;
5> recover database;
6> release channel d1;
7> release channel d2;
8> }
using target database control file instead of recovery catalog
allocated channel: d1
channel d1: sid=155 devtype=DISK
allocated channel: d2
channel d2: sid=154 devtype=DISK
executing command: SET until clause
Starting recover at 29-DEC-08
released channel: d1
released channel: d2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/29/2008 19:29:45
RMAN-06556: datafile 1 must be restored from backup older than scn 1040340

还是失败,于是查找RMAN-06556的错误解决方法,此错误是由于datafile 1 必须只能从SCN比1040340旧的备份中还原出来,此时还是可以
通过时间点来进行还原,可以采用SCN来确定还原的时间点,此时时间就是 SCN=1040340的所在时刻
RMAN> run{
2> set until scn 1040340;
3> restore database;
4> recover database;
5> alter database open resetlogs;
6> }
executing command: SET until clause
Starting restore at 29-DEC-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 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 /opt/oracle/oradata/ge/system01.dbf
restoring datafile 00002 to /opt/oracle/oradata/ge/undotbs01.dbf
restoring datafile 00003 to /opt/oracle/oradata/ge/sysaux01.dbf
restoring datafile 00004 to /opt/oracle/oradata/ge/users01.dbf
channel ORA_DISK_1: reading from backup piece /opt/oracle/flash_recovery_area/GE/backupset/2008_12_24/o1_mf_nnndf_TAG20081224T191249_4o469mgq_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/opt/oracle/flash_recovery_area/GE/backupset/2008_12_24/o1_mf_nnndf_TAG20081224T191249_4o469mgq_.bkp tag=TAG20081224T191249
channel ORA_DISK_1: restore complete, elapsed time: 00:05:37
Finished restore at 29-DEC-08
Starting recover at 29-DEC-08
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 26 is already on disk as file /opt/oracle/flash_recovery_area/GE/archivelog/2008_12_24/o1_mf_1_26_4o4dd2km_.arc
archive log filename=/opt/oracle/flash_recovery_area/GE/archivelog/2008_12_24/o1_mf_1_26_4o4dd2km_.arc thread=1 sequence=26
media recovery complete, elapsed time: 00:00:12
Finished recover at 29-DEC-08
database opened


还原成功! 打开数据也成功,不过此时确实丢失了一些数据,在SCN>1040340的数据都会丢失。

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/daimin1983/archive/2008/12/29/3639458.aspx

你可能感兴趣的:(ORA-01152 file 1 was not restored from a sufficiently old backup解决过程)