On this scenario, we’ve been very bad guys and have no good controlfile backup from a recent archive backup, and also had lost some archivelog (let’s guess that the archivelogs lived on the FRA and all the diskgroups where corrupted). That means we have lost some data in time, but on some recovery scenarios, that means better than having nothing, for instance, on non production environments.
This database doesn’t fit on a tipical development environment, though, as it’s on archivelog mode. Anyway, it’s a perfectly valid example as the only valid database backup is an old full backup, and that’s definitely a damn development scenario. The SAN storage is quite old, did something weird and completely corrupted all development data, and all we have is an old last week’s full backup…WTH…
How we get to know this? After recovering the hardware outage, the database starts, but the rman validate command finds data corruption:
[oracle@rac2 ~]$ rman target / Recovery Manager: Release 11.2.0.1.0 - Production on Wed Dec 14 21:36:47 2011 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: RACORA (DBID=4104435745) RMAN> validate database; Starting validate at 14-DEC-11 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=53 instance=RACORA2 device type=DISK RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of validate command at 12/14/2011 21:37:21 ORA-01135: file 3 accessed for DML/query is offline ORA-01110: data file 3: '+DATA/racora/datafile/undotbs1.269.729858657' RMAN-06031: could not translate database keyword RMAN> Recovery Manager complete.
Good! Then, we’ll see what excatly means, as the database started and open with no erros…
[oracle@rac2 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 14 21:37:44 2011 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> select FILE_NAME,STATUS from DBA_DATA_FILES; FILE_NAME -------------------------------------------------------------------------------- STATUS --------- +DATA/racora/datafile/users.268.729858659 AVAILABLE +DATA/racora/datafile/undotbs1.269.729858657 AVAILABLE +DATA/racora/datafile/sysaux.261.729858653 AVAILABLE FILE_NAME -------------------------------------------------------------------------------- STATUS --------- +DATA/racora/datafile/system.260.729858643 AVAILABLE +DATA/racora/datafile/example.263.729858985 AVAILABLE +DATA/racora/datafile/undotbs2.262.729859525 AVAILABLE 6 rows selected.
The DBA_DATAF_FILES table reports that all datafiles are online and available… what’s going on here?
SQL> select * from V$DATAFILE; select * from V$DATAFILE * ERROR at line 1: ORA-01135: file 3 accessed for DML/query is offline ORA-01110: data file 3: '+DATA/racora/datafile/undotbs1.269.729858657'
Now we see some light (or to day better, darkness). We had some data corruption on the SAN storage outage…
We try to restore only that datafile with RMAN:
SQL> alter database datafile 3 OFFLINE; Database altered. SQL> recover datafile 3; ORA-00283: recovery session canceled due to errors ORA-01110: data file 3: '+DATA/racora/datafile/undotbs1.269.729858657' ORA-01122: database file 3 failed verification check ORA-01110: data file 3: '+DATA/racora/datafile/undotbs1.269.729858657' ORA-01210: data file header is media corrupt
Ouch! OK, this is a controlled error, we can bypass it by removing the datafile manually and then performing the restore:
[oracle@rac2 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 14 21:42:01 2011 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> shutdown immediatE; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount; ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance ORACLE instance started. Total System Global Area 521936896 bytes Fixed Size 2214936 bytes Variable Size 289407976 bytes Database Buffers 226492416 bytes Redo Buffers 3821568 bytes Database mounted. [oracle@rac2 ~]$ export ORACLE_SID=+ASM2 [oracle@rac2 ~]$ export ORACLE_HOME="/u01/app/11.2.0/grid" [oracle@rac2 ~]$ asmcmd rm '+DATA/racora/datafile/undotbs1.269.729858657'
And we’re ready to keep on the restore and recovery procedure:
[oracle@rac2 ~]$ rman target / Recovery Manager: Release 11.2.0.1.0 - Production on Wed Dec 14 22:15:55 2011 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: RACORA (DBID=4104435745, not open) RMAN> restore database; Starting restore at 14-DEC-11 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=35 instance=RACORA2 device type=DISK channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00001 to +DATA/racora/datafile/system.260.729858643 channel ORA_DISK_1: restoring datafile 00002 to +DATA/racora/datafile/sysaux.261.729858653 channel ORA_DISK_1: restoring datafile 00003 to +DATA/racora/datafile/undotbs1.269.729858657 channel ORA_DISK_1: restoring datafile 00004 to +DATA/racora/datafile/users.268.729858659 channel ORA_DISK_1: restoring datafile 00005 to +DATA/racora/datafile/example.263.729858985 channel ORA_DISK_1: restoring datafile 00006 to +DATA/racora/datafile/undotbs2.262.729859525 channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backups/datafiles/RACORA_20110708_s4_s1 channel ORA_DISK_1: piece handle=/u01/app/oracle/backups/datafiles/RACORA_20110708_s4_s1 tag=TAG20110708T164017 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:57:31 Finished restore at 14-DEC-11 RMAN> recover database; Starting recover at 15-DEC-11 using channel ORA_DISK_1 starting media recovery archived log for thread 1 with sequence 45 is already on disk as file +DATA/racora/archivelog/1_45_729858920.dbf archived log for thread 1 with sequence 46 is already on disk as file +DATA/racora/archivelog/1_46_729858920.dbf archived log for thread 1 with sequence 47 is already on disk as file +DATA/racora/archivelog/1_47_729858920.dbf archived log for thread 1 with sequence 48 is already on disk as file +DATA/racora/archivelog/1_48_729858920.dbf archived log for thread 1 with sequence 49 is already on disk as file +DATA/racora/archivelog/1_49_729858920.dbf archived log for thread 1 with sequence 50 is already on disk as file +DATA/racora/archivelog/1_50_729858920.dbf archived log for thread 1 with sequence 51 is already on disk as file +DATA/racora/archivelog/1_51_729858920.dbf archived log for thread 1 with sequence 52 is already on disk as file +DATA/racora/archivelog/1_52_729858920.dbf archived log for thread 1 with sequence 53 is already on disk as file +DATA/racora/archivelog/1_53_729858920.dbf archived log for thread 1 with sequence 54 is already on disk as file +DATA/racora/archivelog/1_54_729858920.dbf archived log for thread 1 with sequence 55 is already on disk as file +DATA/racora/archivelog/1_55_729858920.dbf archived log for thread 1 with sequence 56 is already on disk as file +DATA/racora/archivelog/1_56_729858920.dbf archived log for thread 1 with sequence 57 is already on disk as file +DATA/racora/archivelog/1_57_729858920.dbf archived log for thread 1 with sequence 58 is already on disk as file +DATA/racora/archivelog/1_58_729858920.dbf archived log for thread 1 with sequence 59 is already on disk as file +DATA/racora/archivelog/1_59_729858920.dbf archived log for thread 1 with sequence 60 is already on disk as file +DATA/racora/archivelog/1_60_729858920.dbf archived log for thread 1 with sequence 61 is already on disk as file +DATA/racora/archivelog/1_61_729858920.dbf archived log for thread 1 with sequence 62 is already on disk as file +DATA/racora/archivelog/1_62_729858920.dbf archived log for thread 1 with sequence 63 is already on disk as file +DATA/racora/archivelog/1_63_729858920.dbf archived log for thread 1 with sequence 64 is already on disk as file +DATA/racora/archivelog/1_64_729858920.dbf archived log for thread 1 with sequence 65 is already on disk as file +DATA/racora/archivelog/1_65_729858920.dbf archived log for thread 1 with sequence 66 is already on disk as file +DATA/racora/archivelog/1_66_729858920.dbf archived log for thread 1 with sequence 67 is already on disk as file +DATA/racora/archivelog/1_67_729858920.dbf archived log for thread 1 with sequence 68 is already on disk as file +DATA/racora/archivelog/1_68_729858920.dbf archived log for thread 1 with sequence 69 is already on disk as file +DATA/racora/archivelog/1_69_729858920.dbf archived log for thread 2 with sequence 24 is already on disk as file +DATA/racora/archivelog/2_24_729858920.dbf archived log for thread 2 with sequence 25 is already on disk as file +DATA/racora/archivelog/2_25_729858920.dbf archived log for thread 2 with sequence 26 is already on disk as file +DATA/racora/archivelog/2_26_729858920.dbf archived log for thread 2 with sequence 27 is already on disk as file +DATA/racora/archivelog/2_27_729858920.dbf archived log for thread 2 with sequence 28 is already on disk as file +DATA/racora/archivelog/2_28_729858920.dbf archived log for thread 2 with sequence 29 is already on disk as file +DATA/racora/archivelog/2_29_729858920.dbf archived log for thread 2 with sequence 30 is already on disk as file +DATA/racora/archivelog/2_30_729858920.dbf archived log for thread 2 with sequence 31 is already on disk as file +DATA/racora/archivelog/2_31_729858920.dbf archived log for thread 2 with sequence 32 is already on disk as file +DATA/racora/archivelog/2_32_729858920.dbf archived log for thread 2 with sequence 33 is already on disk as file +DATA/racora/archivelog/2_33_729858920.dbf archived log for thread 2 with sequence 34 is already on disk as file +DATA/racora/archivelog/2_34_729858920.dbf archived log for thread 2 with sequence 35 is already on disk as file +DATA/racora/archivelog/2_35_729858920.dbf archived log for thread 2 with sequence 36 is already on disk as file +DATA/racora/archivelog/2_36_729858920.dbf archived log for thread 2 with sequence 37 is already on disk as file +DATA/racora/archivelog/2_37_729858920.dbf archived log for thread 2 with sequence 38 is already on disk as file +DATA/racora/archivelog/2_38_729858920.dbf archived log for thread 2 with sequence 39 is already on disk as file +DATA/racora/archivelog/2_39_729858920.dbf archived log for thread 2 with sequence 40 is already on disk as file +DATA/racora/archivelog/2_40_729858920.dbf archived log for thread 2 with sequence 41 is already on disk as file +DATA/racora/archivelog/2_41_729858920.dbf archived log for thread 2 with sequence 42 is already on disk as file +DATA/racora/archivelog/2_42_729858920.dbf archived log for thread 2 with sequence 43 is already on disk as file +DATA/racora/archivelog/2_43_729858920.dbf archived log for thread 2 with sequence 44 is already on disk as file +DATA/racora/archivelog/2_44_729858920.dbf archived log for thread 2 with sequence 45 is already on disk as file /u02/oradata/ORASTB/archivelogs/2_45_729858920.dbf archived log for thread 2 with sequence 46 is already on disk as file +DATA/racora/archivelog/2_46_729858920.dbf channel ORA_DISK_1: starting archived log restore to default destination channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=32 channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backups/datafiles/RACORA_20110708_s5_s1 channel ORA_DISK_1: piece handle=/u01/app/oracle/backups/datafiles/RACORA_20110708_s5_s1 tag=TAG20110708T164226 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 archived log file name=/u02/oradata/ORASTB/archivelogs/1_32_729858920.dbf thread=1 sequence=32
If after all of this, your database still doesn’t opens, saying that datafile 1 (System tablespace datafile) needs recovery, then we’ll have to dismiss all data from last controlfile backup.
As we said, all we have is a full backup including controlfile. We’ll restore the controlfile from that backup and recover the database to that controlfile’s SCN.
First of all, we recover the controlfile with the database started in “nomount” mode:
[oracle@rac1 ~]$ ls -l /u01/app/oracle/backups/controlspfile/ total 54424 -rw-r----- 1 oracle oinstall 18579456 jul 8 16:37 c-4104435745-20110708-00 -rw-r----- 1 oracle oinstall 18579456 jul 8 16:42 c-4104435745-20110708-01 -rw-r----- 1 oracle oinstall 18497536 jul 8 16:42 snapcf_RACORA1.f [oracle@rac1 ~]$ rman target / Recovery Manager: Release 11.2.0.1.0 - Production on Sun Dec 18 13:26:05 2011 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: RACORA (not mounted) RMAN> restore controlfile from '/u01/app/oracle/backups/controlspfile/c-4104435745-20110708-01'; Starting restore at 18-DEC-11 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=1 instance=RACORA1 device type=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:07 output file name=+DATA/racora/controlfile/current.267.729858913 Finished restore at 18-DEC-11
Then, we restore and recover the database:
RMAN> mount database; database mounted released channel: ORA_DISK_1 RMAN> restore database; Starting restore at 18-DEC-11 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=1 instance=RACORA1 device type=DISK channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00001 to +DATA/racora/datafile/system.260.729858643 channel ORA_DISK_1: restoring datafile 00002 to +DATA/racora/datafile/sysaux.261.729858653 channel ORA_DISK_1: restoring datafile 00003 to +DATA/racora/datafile/undotbs1.269.729858657 channel ORA_DISK_1: restoring datafile 00004 to +DATA/racora/datafile/users.268.729858659 channel ORA_DISK_1: restoring datafile 00005 to +DATA/racora/datafile/example.263.729858985 channel ORA_DISK_1: restoring datafile 00006 to +DATA/racora/datafile/undotbs2.262.729859525 channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backups/datafiles/RACORA_20110708_s4_s1 channel ORA_DISK_1: piece handle=/u01/app/oracle/backups/datafiles/RACORA_20110708_s4_s1 tag=TAG20110708T164017 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:04:46 Finished restore at 18-DEC-11 RMAN> Recovery Manager complete. [oracle@rac1 ~]$ rman target / Recovery Manager: Release 11.2.0.1.0 - Production on Sun Dec 18 13:39:26 2011 Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved. connected to target database: RACORA (DBID=4104435745, not open) RMAN> recover database; Starting recover at 18-DEC-11 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=32 instance=RACORA1 device type=DISK starting media recovery archived log for thread 1 with sequence 32 is already on disk as file +DATA/racora/archivelog/1_32_729858920.dbf archived log for thread 1 with sequence 68 is already on disk as file +DATA/racora/onlinelog/group_2.265.729858931 archived log for thread 1 with sequence 69 is already on disk as file +DATA/racora/onlinelog/group_1.266.729858921 archived log for thread 2 with sequence 46 is already on disk as file +DATA/racora/onlinelog/group_4.258.729859647 archived log for thread 2 with sequence 47 is already on disk as file +DATA/racora/onlinelog/group_3.259.729859639 archived log file name=+DATA/racora/archivelog/1_32_729858920.dbf thread=1 sequence=32 archived log file name=+DATA/racora/archivelog/1_33_729858920.dbf thread=1 sequence=33 archived log file name=+DATA/racora/archivelog/1_34_729858920.dbf thread=1 sequence=34 archived log file name=+DATA/racora/archivelog/2_14_729858920.dbf thread=2 sequence=14 archived log file name=+DATA/racora/archivelog/2_15_729858920.dbf thread=2 sequence=15 archived log file name=+DATA/racora/archivelog/1_35_729858920.dbf thread=1 sequence=35 archived log file name=+DATA/racora/archivelog/2_16_729858920.dbf thread=2 sequence=16 archived log file name=+DATA/racora/archivelog/2_17_729858920.dbf thread=2 sequence=17 archived log file name=+DATA/racora/archivelog/1_36_729858920.dbf thread=1 sequence=36 archived log file name=+DATA/racora/archivelog/2_18_729858920.dbf thread=2 sequence=18 archived log file name=+DATA/racora/archivelog/1_37_729858920.dbf thread=1 sequence=37 archived log file name=+DATA/racora/archivelog/2_19_729858920.dbf thread=2 sequence=19 archived log file name=+DATA/racora/archivelog/2_20_729858920.dbf thread=2 sequence=20 archived log file name=+DATA/racora/archivelog/1_38_729858920.dbf thread=1 sequence=38 archived log file name=+DATA/racora/archivelog/2_21_729858920.dbf thread=2 sequence=21 archived log file name=+DATA/racora/archivelog/1_39_729858920.dbf thread=1 sequence=39 archived log file name=+DATA/racora/archivelog/1_40_729858920.dbf thread=1 sequence=40 archived log file name=+DATA/racora/archivelog/2_22_729858920.dbf thread=2 sequence=22 archived log file name=+DATA/racora/archivelog/2_23_729858920.dbf thread=2 sequence=23 archived log file name=+DATA/racora/archivelog/1_41_729858920.dbf thread=1 sequence=41 archived log file name=+DATA/racora/archivelog/1_42_729858920.dbf thread=1 sequence=42 archived log file name=+DATA/racora/archivelog/1_43_729858920.dbf thread=1 sequence=43 archived log file name=+DATA/racora/archivelog/1_44_729858920.dbf thread=1 sequence=44 archived log file name=+DATA/racora/archivelog/2_24_729858920.dbf thread=2 sequence=24 archived log file name=+DATA/racora/archivelog/1_45_729858920.dbf thread=1 sequence=45 archived log file name=+DATA/racora/archivelog/2_25_729858920.dbf thread=2 sequence=25 archived log file name=+DATA/racora/archivelog/1_46_729858920.dbf thread=1 sequence=46 archived log file name=+DATA/racora/archivelog/2_26_729858920.dbf thread=2 sequence=26 archived log file name=+DATA/racora/archivelog/1_47_729858920.dbf thread=1 sequence=47 archived log file name=+DATA/racora/archivelog/2_27_729858920.dbf thread=2 sequence=27 archived log file name=+DATA/racora/archivelog/1_48_729858920.dbf thread=1 sequence=48 archived log file name=+DATA/racora/archivelog/1_49_729858920.dbf thread=1 sequence=49 archived log file name=+DATA/racora/archivelog/2_28_729858920.dbf thread=2 sequence=28 archived log file name=+DATA/racora/archivelog/1_50_729858920.dbf thread=1 sequence=50 archived log file name=+DATA/racora/archivelog/2_29_729858920.dbf thread=2 sequence=29 archived log file name=+DATA/racora/archivelog/1_51_729858920.dbf thread=1 sequence=51 archived log file name=+DATA/racora/archivelog/2_30_729858920.dbf thread=2 sequence=30 archived log file name=+DATA/racora/archivelog/1_52_729858920.dbf thread=1 sequence=52 archived log file name=+DATA/racora/archivelog/2_31_729858920.dbf thread=2 sequence=31 archived log file name=+DATA/racora/archivelog/2_32_729858920.dbf thread=2 sequence=32 archived log file name=+DATA/racora/archivelog/1_53_729858920.dbf thread=1 sequence=53 archived log file name=+DATA/racora/archivelog/2_33_729858920.dbf thread=2 sequence=33 archived log file name=+DATA/racora/archivelog/1_54_729858920.dbf thread=1 sequence=54 archived log file name=+DATA/racora/archivelog/2_34_729858920.dbf thread=2 sequence=34 archived log file name=+DATA/racora/archivelog/1_55_729858920.dbf thread=1 sequence=55 archived log file name=+DATA/racora/archivelog/2_35_729858920.dbf thread=2 sequence=35 archived log file name=+DATA/racora/archivelog/1_56_729858920.dbf thread=1 sequence=56 archived log file name=+DATA/racora/archivelog/1_57_729858920.dbf thread=1 sequence=57 archived log file name=+DATA/racora/archivelog/2_36_729858920.dbf thread=2 sequence=36 archived log file name=+DATA/racora/archivelog/2_37_729858920.dbf thread=2 sequence=37 archived log file name=+DATA/racora/archivelog/1_58_729858920.dbf thread=1 sequence=58 archived log file name=+DATA/racora/archivelog/2_38_729858920.dbf thread=2 sequence=38 archived log file name=+DATA/racora/archivelog/2_39_729858920.dbf thread=2 sequence=39 archived log file name=+DATA/racora/archivelog/1_59_729858920.dbf thread=1 sequence=59 archived log file name=+DATA/racora/archivelog/1_60_729858920.dbf thread=1 sequence=60 archived log file name=+DATA/racora/archivelog/2_40_729858920.dbf thread=2 sequence=40 archived log file name=+DATA/racora/archivelog/1_61_729858920.dbf thread=1 sequence=61 archived log file name=+DATA/racora/archivelog/1_62_729858920.dbf thread=1 sequence=62 archived log file name=+DATA/racora/archivelog/2_41_729858920.dbf thread=2 sequence=41 archived log file name=+DATA/racora/archivelog/1_63_729858920.dbf thread=1 sequence=63 archived log file name=+DATA/racora/archivelog/2_42_729858920.dbf thread=2 sequence=42 archived log file name=+DATA/racora/archivelog/2_43_729858920.dbf thread=2 sequence=43 archived log file name=+DATA/racora/archivelog/1_64_729858920.dbf thread=1 sequence=64 archived log file name=+DATA/racora/archivelog/1_65_729858920.dbf thread=1 sequence=65 archived log file name=+DATA/racora/archivelog/1_66_729858920.dbf thread=1 sequence=66 archived log file name=+DATA/racora/archivelog/2_44_729858920.dbf thread=2 sequence=44 archived log file name=+DATA/racora/archivelog/2_45_729858920.dbf thread=2 sequence=45 archived log file name=+DATA/racora/archivelog/1_67_729858920.dbf thread=1 sequence=67 archived log file name=+DATA/racora/onlinelog/group_2.265.729858931 thread=1 sequence=68 archived log file name=+DATA/racora/onlinelog/group_4.258.729859647 thread=2 sequence=46 archived log file name=+DATA/racora/onlinelog/group_1.266.729858921 thread=1 sequence=69 archived log file name=+DATA/racora/onlinelog/group_3.259.729859639 thread=2 sequence=47 media recovery complete, elapsed time: 00:07:31 Finished recover at 18-DEC-11 RMAN>
And now we open the database with the resetlogs option:
[oracle@rac1 ~]$ sqlplus '/as sysdba' SQL*Plus: Release 11.2.0.1.0 Production on Sun Dec 18 13:48:17 2011 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> alter database open resetlogs; Database altered.