ORA-01152: file 1 was not restored from a sufficiently old backup

利用rman备份集复制数据库过程中,因为忘记recover database导致错误:ORA-01152发生。

SQL> startup;
ORACLE instance started.

Total System Global Area  218103808 bytes
Fixed Size                  1218604 bytes
Variable Size              62916564 bytes
Database Buffers          150994944 bytes
Redo Buffers                2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info


SQL> startup nomount;
ORACLE instance started.

Total System Global Area  218103808 bytes
Fixed Size                  1218604 bytes
Variable Size              62916564 bytes
Database Buffers          150994944 bytes
Redo Buffers                2973696 bytes

[oracle@centos ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Apr 9 06:01:06 2013

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

connected to target database: orcl (not mounted)

RMAN> set dbid 1337758187

executing command: SET DBID

RMAN> restore controlfile from '/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2013_04_08/o1_mf_s_812177402_8p3pzv19_.bkp';

Starting restore at 09-APR-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output filename=/u01/app/oracle/oradata/orcl/control01.ctl
output filename=/u01/app/oracle/oradata/orcl/control02.ctl
output filename=/u01/app/oracle/oradata/orcl/control03.ctl
Finished restore at 09-APR-13

RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1

RMAN> restore database;

Starting restore at 09-APR-13
Starting implicit crosscheck backup at 09-APR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Crosschecked 7 objects
Finished implicit crosscheck backup at 09-APR-13

Starting implicit crosscheck copy at 09-APR-13
using channel ORA_DISK_1
Finished implicit crosscheck copy at 09-APR-13

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2013_04_08/o1_mf_s_812177402_8p3pzv19_.bkp
File Name: /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2013_04_09/o1_mf_1_13_8p6h3zwk_.arc

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/orcl/test01.dbf
restoring datafile 00006 to /u01/app/oracle/oradata/orcl/test02.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2      013_04_08/o1_mf_nnnd0_TAG20130408T044814_8p3pwhd1_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2013_04_08/o1_mf_nnnd0_TAG20130408T044814_8p3pwhd1_.bkp tag=TAG20130408T044814
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 09-APR-13

RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 04/09/2013 06:03:23
RMAN-11003: failure during parse/execution of SQL statement: alter database open resetlogs
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/system01.dbf'

因为从备份中还原的控制文件太旧,记录的scn比数据库文件头部中的scn要小,所以报错:ORA-01152 说数据文件不是从足够老的备份中恢复的。
 
有两种思路:

1、以old controlfile为准的,datafile上的scn比控制文件新,这样的话会丢失datafile上的部分数据;
2、就是以datafile上的scn为准,利用日志将controlfile恢复到与datafile scn一致。

找出匹配控制文件SCN到数据文件SCN的所有archivelog,用于下面的恢复:

RMAN> recover database;

Starting recover at 09-APR-13
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 14 is already on disk as file /u01/app/oracle/oradata/orcl/redo02.log
archive log filename=/u01/app/oracle/oradata/orcl/redo02.log thread=1 sequence=14
media recovery complete, elapsed time: 00:00:04
Finished recover at 09-APR-13

到这里控制文件和数据文件中的SCN就一致了,然后就可以做基于时间点的数据恢复了,将数据库恢复到有archivelog覆盖的任意时间点,最后以resetlogs方式打开数据库。

RMAN> run{
allocate channel d1 type disk;
allocate channel d2 type disk;
set until sequence 15 thread 1;
recover database;
release channel d1;
release channel d2;
}

released channel: ORA_DISK_1
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 09-APR-13

starting media recovery

archive log thread 1 sequence 14 is already on disk as file /u01/app/oracle/oradata/orcl/redo02.log
archive log filename=/u01/app/oracle/oradata/orcl/redo02.log thread=1 sequence=14
media recovery complete, elapsed time: 00:00:03
Finished recover at 09-APR-13

released channel: d1

released channel: d2

SQL> alter database open resetlogs;

Database altered.

SQL> select status from v$instance;

STATUS
------------
OPEN

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29924458/viewspace-1485183/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29924458/viewspace-1485183/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值