You are on page 1of 119

Incomplete Recovery with a BACKUP CONTROLFIE :

RollForward through “future” ArchiveLogs :

Every once in a while we come across questions about Database Recovery posed by new
DBAs. Furthermore, DBAs “experienced” with RMAN only might wonder how Oracle
can apply ArchiveLogs which are not included in RMAN BackupSets (eg created since
the last RMAN backup but yet available on disk) to continue a database recovery as far as
possible.

How does the RECOVER command know which ArchiveLog , which SCN generated at
which time is required to be applied when rolling forward using a Backup Controlfile ?
Knowledge of ArchiveLogs would be available if you are using a current controlfile or an
RMAN Repository (the RMAN Repository still doesn’t know the ArchiveLogs generated
after the last backup which updated the repository). What if you have neither ?

The Backup Controlfile could be either of :


a. A binary backup controlfile that was older then the ArchiveLogs, so information
about the ArchiveLogs generated after the backup is not available in the
controlfile
b. A trace backup from which I run a CREATE CONTROLFILE. This would have
no information whatsoever about ArchiveLogs – even of those generated before
the trace backup was executed.

There are 3 components to the manner in which the RECOVER command prompts us for
the Archive Log files :
1. Log_Archive_Dest
2. Log_Archive_Format
3. Log Sequence Numbers, SCNs, Timestamps

For example, if I restore to another server and use a different directory for the
Log_Archive_Dest in the initora/spfileora when I STARTUP MOUNT, the RECOVER
command would use this new path to prompt me for the ArchiveLogs to be applied. If
my Log_Archive_Format is different, it uses this new format to construct the file names.
What about the Sequence,SCN,Timestamp ? We’ll come back to these later.

Here’s how I build my “proof” that the RECOVER command can work without prior
knowledge of ArchiveLogs.

{Note : In the RMAN listings the date/timestamp appears in the format


“09_FEB_08_23_21_50” because I explicitly set NLS_DATE_FORMAT in the environment
when I run RMAN commands}.

SCENARIO A : With a Binary Backup Controlfile

Step 1: I take a backup of the database, using RMAN’s “BACKUP DATABASE”.


This goes, by default, to my db_recovery_file_dest (the FlashRecoveryArea), configured
in 10gR2.
Spooling started in log file: RMAN_Backup_of_DB.Log

Recovery Manager10.2.0.1.0

RMAN>
connected to target database: OR10G2DB (DBID=138573118)

RMAN>
Starting backup at 09_FEB_08_23_21_46
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=60 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=C:\OR10G2DB\SYSTEM01.DBF
input datafile fno=00003 name=C:\OR10G2DB\SYSAUX01.DBF
input datafile fno=00002 name=C:\OR10G2DB\UNDOTBS01.DBF
input datafile fno=00004 name=C:\OR10G2DB\USERS01.DBF
input datafile fno=00005 name=C:\OR10G2DB\EXAMPLE01.DBF
channel ORA_DISK_1: starting piece 1 at 09_FEB_08_23_21_50
channel ORA_DISK_1: finished piece 1 at 09_FEB_08_23_24_15
piece
handle=C:\OR10G2DB_FLASH\OR10G2DB\BACKUPSET\2008_02_09\O1_MF_NNNDF_TAG20080209T232148_3TV
K8HRF_.BKP tag=TAG20080209T232148 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:26
Finished backup at 09_FEB_08_23_24_15

Starting Control File and SPFILE Autobackup at 09_FEB_08_23_24_16


piece
handle=C:\OR10G2DB_FLASH\OR10G2DB\AUTOBACKUP\2008_02_09\O1_MF_S_646269856_3TVKF1SW_.BKP
comment=NONE
Finished Control File and SPFILE Autobackup at 09_FEB_08_23_24_19

RMAN>

Recovery Manager complete.

I also take a separate binary backup of the controlfile.


SQL> set echo on
SQL> alter database backup controlfile to 'C:\ORACLE_EXERCISES\cntrlfile_bak.dbf';

Database altered.

SQL> spool off

Step 2: I run some transactions on the database to ensure that a number of log switches
and SCN changes occur.
SQL> set linesize 130
SQL> set pages60
SQL>
SQL> col name format a45
SQL> col First_Time format a19
SQL>
SQL> select to_char(sysdate,'DD-MON-RR HH24:MI') from dual;

TO_CHAR(SYSDATE
---------------
09-FEB-08 23:32

SQL>
SQL> select group#, sequence#, first_change#, status from v$log order by sequence#;
GROUP# SEQUENCE# FIRST_CHANGE# STATUS
---------- ---------- ------------- ----------------
3 7 1540484 INACTIVE
1 8 1540669 INACTIVE
2 9 1540888 CURRENT

SQL>
SQL> select recid, name, sequence#, to_char(first_time,'DD-MON-RR HH24:MI') First_Time,
first_change#
2 from v$archived_log
3 where first_time > trunc(sysdate)
4 order by first_time;

no rows selected

 At this point, there are NO archivelogs of today. The CURRENT Online Redo Log is
Sequence#9. [Note : If you are confused as to why the SCN difference between the
Logfiles is so low (ie very few SCNs are incremented from one Sequence# to the next
Sequence#, it is because I had, in the past, issued a few ALTER SYSTEM SWITCH
LOGFILE commands with very few transactions in each LogFile].
SQL>
SQL> select dbid, name, checkpoint_change#, current_scn from v$database;

DBID NAME CHECKPOINT_CHANGE# CURRENT_SCN


---------- --------------------------------------------- ------------------ -----------
138573118 OR10G2DB 1543675 1544669
 My current SCN and the SCN as of the last checkpoint
SQL>
SQL> REM Begin Transactions here ========================================================
SQL>
SQL>
SQL> drop table hemant.test_txn_table ;

Table dropped.

SQL>
SQL> create table hemant.test_txn_table as
2 select * from dba_objects
3 union
4 select * from dba_objects
5 /

Table created.

SQL>
SQL> update hemant.test_txn_table
2 set object_id=object_id+1, owner=substr(owner,1,3)||'_HKC' ;

51582 rows updated.

SQL> commit;

Commit complete.

SQL>
SQL> create index hemant.test_txn_tbl_ndx on hemant.test_txn_table(owner);

Index created.

SQL>
SQL> delete hemant.test_txn_table
2 where owner = 'SYS_HKC';

24692 rows deleted.

SQL> rollback;
Rollback complete.

SQL>
SQL> update hemant.test_txn_table
2 set object_id=object_id+1, owner=substr(owner,1,3)||'_HKC2'
3 where owner = 'SYS_HKC';

24692 rows updated.

SQL> commit;

Commit complete.

SQL> alter system switch logfile;

System altered.

SQL>
SQL> select group#, status from v$log order by status;

GROUP# STATUS
---------- ----------------
2 ACTIVE
3 ACTIVE
1 CURRENT

SQL>
SQL> select recid, name, sequence#, to_char(first_time,'DD-MON-RR HH24:MI') First_Time
,first_change#
2 from v$archived_log
3 where first_time > trunc(sysdate)
4 order by sequence#;

RECID NAME SEQUENCE# FIRST_TIME FIRST_CHANGE#


---------- --------------------------------------------- ---------- ------------------- -------------
569 C:\OR10G2DB\ARCH\MY_ARC_10_645627350_1.BAK 10 09-FEB-08 23:32 1544764
570 C:\OR10G2DB\ARCH\MY_ARC_11_645627350_1.BAK 11 09-FEB-08 23:32 1545127
571 C:\OR10G2DB\ARCH\MY_ARC_12_645627350_1.BAK 12 09-FEB-08 23:32 1545530
572 C:\OR10G2DB\ARCH\MY_ARC_13_645627350_1.BAK 13 09-FEB-08 23:32 1545558
573 C:\OR10G2DB\ARCH\MY_ARC_14_645627350_1.BAK 14 09-FEB-08 23:32 1545567

 Note that the above list does not show me Sequence#9 because the FIRST_TIME for
this file is before trunc(sysdate). This file was actually the CURRENT Online RedoLog
at the time that I began this testing and did get archived out as
MY_ARC_9_645627350_1.BAK.
SQL>
SQL> select dbid, name, checkpoint_change#, current_scn from v$database;

DBID NAME CHECKPOINT_CHANGE# CURRENT_SCN


---------- --------------------------------------------- ------------------ -----------
138573118 OR10G2DB 1545818 1546226

SQL>
SQL> spool off

 I have generated Log Sequences 10 to 14 and significantly incremented the SCNs


from 1544669 to 1546226.

Step 3: I crash the database, remove the Database and Online Redo Logs.
Step 4: I restore the controlfile alone from my binary backup (manually copying it
backup as CONTROL0[1-3].CTL) and verify it’s contents.
SQL> set pages600
SQL> set linesize 132
SQL> set echo on
SQL> startup mount
ORACLE instance started.

Total System Global Area 268435456 bytes


Fixed Size 1248504 bytes
Variable Size 171967240 bytes
Database Buffers 92274688 bytes
Redo Buffers 2945024 bytes
Database mounted.
SQL>
SQL> select group#, status from v$log order by status;

GROUP# STATUS
---------- ----------------
2 CURRENT
1 INACTIVE
3 INACTIVE

SQL>
SQL> select recid, name, sequence#, to_char(first_time,'DD-MON-RR HH24:MI') First_Time,
first_change#
2 from v$archived_log
3 where first_time > trunc(sysdate)
4 order by first_time;

no rows selected

SQL>
SQL> select dbid, name, checkpoint_change#, current_scn from v$database;

DBID NAME CHECKPOINT_CHANGE# CURRENT_SCN


---------- --------- ------------------ -----------
138573118 OR10G2DB 1543675 0

SQL> spool off

 I can see that this controlfile only knows the last checkpoint (SCN 1543675) before I
began transactions. It does not know of any archivelogs generated today. {Why is
CURRENT_SCN=0 ? Interesting. We’ll see it again later}.

Step 5: I restore the database. I use the RMAN Restore database command.
Spooling started in log file: RMAN_Restore_DB.Log

Recovery Manager10.2.0.1.0

RMAN>
connected to target database: OR10G2DB (DBID=138573118, not open)

RMAN>
Starting restore at 09_FEB_08_23_46_15
Starting implicit crosscheck backup at 09_FEB_08_23_46_15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=57 devtype=DISK
Crosschecked 7 objects
Finished implicit crosscheck backup at 09_FEB_08_23_46_18
Starting implicit crosscheck copy at 09_FEB_08_23_46_18
using channel ORA_DISK_1
Finished implicit crosscheck copy at 09_FEB_08_23_46_18

searching for all files in the recovery area


cataloging files...
no files cataloged

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 C:\OR10G2DB\SYSTEM01.DBF
restoring datafile 00002 to C:\OR10G2DB\UNDOTBS01.DBF
restoring datafile 00003 to C:\OR10G2DB\SYSAUX01.DBF
restoring datafile 00004 to C:\OR10G2DB\USERS01.DBF
restoring datafile 00005 to C:\OR10G2DB\EXAMPLE01.DBF
channel ORA_DISK_1: reading from backup piece
C:\OR10G2DB_FLASH\OR10G2DB\BACKUPSET\2008_02_09\O1_MF_NNNDF_TAG20080209T232148_3TVK8HRF_.
BKP
channel ORA_DISK_1: restored backup piece 1
piece
handle=C:\OR10G2DB_FLASH\OR10G2DB\BACKUPSET\2008_02_09\O1_MF_NNNDF_TAG20080209T232148_3TV
K8HRF_.BKP tag=TAG20080209T232148
channel ORA_DISK_1: restore complete, elapsed time: 00:02:16
Finished restore at 09_FEB_08_23_48_37

RMAN>

Recovery Manager complete.

 Note that I have only issued the RESTORE command. Not the RECOVER command
yet. However, I’ve also re-run the recovery with RMAN which we’ll see later. Why I
prefer SQL is obvious when you see the range of queries and commands available in
SQL.

Step 6: I go back to my SQLPlus command line and issue the RECOVER command.
Before that, to test my contention about how it “constructs” the ArchiveLog file name, I
even change the Log_Archive_Format.
SQL> show parameter log_Archive_format

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
log_archive_format string MY_ARC_%s_%r_%t.BAK
SQL> show parameter log_archive_dest_1

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
log_archive_dest_1 string LOCATION=C:\OR10G2DB\ARCH
log_archive_dest_10 string
SQL> alter system set log_archive_format='OR10G2DB_%s_%r_%t.ARC' scope=SPFILE;

System altered.

SQL> shutdown
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 268435456 bytes
Fixed Size 1248504 bytes
Variable Size 171967240 bytes
Database Buffers 92274688 bytes
Redo Buffers 2945024 bytes
Database mounted.
SQL> show parameter log_archive_format;

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
log_archive_format string OR10G2DB_%s_%r_%t.ARC
SQL> select dbid, name, checkpoint_change#, current_scn from v$database;

DBID NAME CHECKPOINT_CHANGE# CURRENT_SCN


---------- --------- ------------------ -----------
138573118 OR10G2DB 1543675 0

 Still verifying the last known Checkpoint SCN.


Also, note that the Log_Archive_Format is now different.
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 1544306 generated at 02/09/2008 23:21:50 needed for thread 1
ORA-00289: suggestion : C:\OR10G2DB\ARCH\OR10G2DB_9_645627350_1.ARC
ORA-00280: change 1544306 for thread 1 is in sequence #9

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}


 Interesting. It picked up the new Log_Archive_Format. It also knew about
change#1544306 that was later then the last checkpointed one in the controlfile.
And it also knew the ArchiveLog Sequence# [9].

I have copied in the original ArchiveLogs using the new filename format, so I proceed
with the Recovery.
ORA-00279: change 1544764 generated at 02/09/2008 23:32:31 needed for thread 1
ORA-00289: suggestion : C:\OR10G2DB\ARCH\OR10G2DB_10_645627350_1.ARC
ORA-00280: change 1544764 for thread 1 is in sequence #10
ORA-00278: log file 'C:\OR10G2DB\ARCH\OR10G2DB_9_645627350_1.ARC' no longer
needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

ORA-00279: change 1545127 generated at 02/09/2008 23:32:35 needed for thread 1


ORA-00289: suggestion : C:\OR10G2DB\ARCH\OR10G2DB_11_645627350_1.ARC
ORA-00280: change 1545127 for thread 1 is in sequence #11
ORA-00278: log file 'C:\OR10G2DB\ARCH\OR10G2DB_10_645627350_1.ARC' no longer
needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

ORA-00279: change 1545530 generated at 02/09/2008 23:32:39 needed for thread 1


ORA-00289: suggestion : C:\OR10G2DB\ARCH\OR10G2DB_12_645627350_1.ARC
ORA-00280: change 1545530 for thread 1 is in sequence #12
ORA-00278: log file 'C:\OR10G2DB\ARCH\OR10G2DB_11_645627350_1.ARC' no longer
needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}


CANCEL
Media recovery cancelled.

 What have I done ? I actually had transactions going upto Log Sequence 14 and
Checkpoint Change#1545818 but I’ve stopped at Sequence# 11 and Change#1545529 !
As long as all the Datafiles are consistent, I will be allowed to open the database. This is
an Incomplete Recovery, after all.
SQL> alter database open resetlogs;

Database altered.

SQL> select dbid, name, checkpoint_change#, current_scn from v$database;

DBID NAME CHECKPOINT_CHANGE# CURRENT_SCN


---------- --------- ------------------ -----------
138573118 OR10G2DB 1545532 1545853

SQL> shutdown abort;


ORACLE instance shut down.

 Don’t worry about the Shutdown Abort here.

Let me verify the database and also understand why I got the “CURRENT_SCN=0”
earlier.
SQL> startup;
ORACLE instance started.

Total System Global Area 268435456 bytes


Fixed Size 1248504 bytes
Variable Size 171967240 bytes
Database Buffers 92274688 bytes
Redo Buffers 2945024 bytes
Database mounted.
Database opened.
SQL> select dbid, name, checkpoint_change#, current_scn from v$database;

DBID NAME CHECKPOINT_CHANGE# CURRENT_SCN


---------- --------- ------------------ -----------
138573118 OR10G2DB 1565850 1565974

SQL> shutdown abort


ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 268435456 bytes


Fixed Size 1248504 bytes
Variable Size 171967240 bytes
Database Buffers 92274688 bytes
Redo Buffers 2945024 bytes
Database mounted.
SQL> select dbid, name, checkpoint_change#, current_scn from v$database;

DBID NAME CHECKPOINT_CHANGE# CURRENT_SCN


---------- --------- ------------------ -----------
138573118 OR10G2DB 1565850 0

SQL> alter database open;

Database altered.

SQL> select dbid, name, checkpoint_change#, current_scn from v$database;

DBID NAME CHECKPOINT_CHANGE# CURRENT_SCN


---------- --------- ------------------ -----------
138573118 OR10G2DB 1586058 1586148

SQL>
 So, if a database is Mounted but not Open, the CURRENT_SCN is shown as 0.
Note how Oracle has significantly “bumped” up the SCNs now ! Instance Recovery and
Startup increment the SCN. You will also notice that a Checkpoint is also issued
automatically by Oracle.

Alternate RESTORE and RECOVER using RMAN only :


I could also have used the RMAN RESTORE CONTROLFILE FROM AUTOBACKUP
command as I have enabled Autobackups. Since this is a 10g database, I am using
db_recovery_file_dest=C:\OR10G2DB_FLASH (with a
db_recovery_file_dest_size=7812M limit). This is my FRA – FlashRecoveryArea.
Note two advantages with this :
a) Oracle can automatically search for backupsets
b) Oracle can identify the Controlfile using the DB_NAME even though I do not have
the DBID. {Only 1 database has backups in the FRA).
After having restored the Controlfile, I issue the RESTORE DATABASE and then
RECOVER DATABASE commands. Note how the RESTORE requires the Database to
be mounted – RESTORE needs access to the Controlfiles which is available in the
MOUNT stage.
Spooling started in log file: RMAN_Restore_CntrlFile.LOG

Recovery Manager10.2.0.1.0

RMAN>
connected to target database: OR10G2DB (not mounted)

RMAN> [command : RESTORE CONTROLFILE]


Starting restore at 10_FEB_08_00_39_13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=60 devtype=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 02/10/2008 00:39:14
RMAN-06563: control file or SPFILE must be restored using FROM AUTOBACKUP

RMAN> [command : RESTORE CONTROLFILE FROM AUTOBACKUP]


Starting restore at 10_FEB_08_00_39_20
using channel ORA_DISK_1

recovery area destination: \OR10G2DB_FLASH


database name (or database unique name) used for search: OR10G2DB
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found:
C:\OR10G2DB_FLASH\OR10G2DB\AUTOBACKUP\2008_02_09\O1_MF_S_646269856_3TVKF1SW_.BKP
channel ORA_DISK_1: control file restore from autobackup complete
output filename=C:\OR10G2DB\CONTROL01.CTL
output filename=C:\OR10G2DB\CONTROL02.CTL
output filename=C:\OR10G2DB\CONTROL03.CTL
Finished restore at 10_FEB_08_00_39_23

RMAN> [command : RESTORE DATABASE]


Starting restore at 10_FEB_08_00_39_39
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 02/10/2008 00:39:40
ORA-01507: database not mounted

RMAN> [command : ALTER DATABASE MOUNT, which is an SQL command]


sql statement: alter database mount
released channel: ORA_DISK_1

RMAN> [command : RESTORE DATABASE]


Starting restore at 10_FEB_08_00_40_06
Starting implicit crosscheck backup at 10_FEB_08_00_40_06
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=57 devtype=DISK
Crosschecked 6 objects
Finished implicit crosscheck backup at 10_FEB_08_00_40_08

Starting implicit crosscheck copy at 10_FEB_08_00_40_08


using channel ORA_DISK_1
Finished implicit crosscheck copy at 10_FEB_08_00_40_08

searching for all files in the recovery area


cataloging files...
cataloging done

List of Cataloged Files


=======================
File Name:
C:\OR10G2DB_FLASH\OR10G2DB\AUTOBACKUP\2008_02_09\O1_MF_S_646269856_3TVKF1SW_.BKP

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 C:\OR10G2DB\SYSTEM01.DBF
restoring datafile 00002 to C:\OR10G2DB\UNDOTBS01.DBF
restoring datafile 00003 to C:\OR10G2DB\SYSAUX01.DBF
restoring datafile 00004 to C:\OR10G2DB\USERS01.DBF
restoring datafile 00005 to C:\OR10G2DB\EXAMPLE01.DBF
channel ORA_DISK_1: reading from backup piece
C:\OR10G2DB_FLASH\OR10G2DB\BACKUPSET\2008_02_09\O1_MF_NNNDF_TAG20080209T232148_3TVK8HRF_.
BKP
channel ORA_DISK_1: restored backup piece 1
piece
handle=C:\OR10G2DB_FLASH\OR10G2DB\BACKUPSET\2008_02_09\O1_MF_NNNDF_TAG20080209T232148_3TV
K8HRF_.BKP tag=TAG20080209T232148
channel ORA_DISK_1: restore complete, elapsed time: 00:02:16
Finished restore at 10_FEB_08_00_42_27

RMAN> [command : RECOVER DATABASE]


Starting recover at 10_FEB_08_00_43_19
using channel ORA_DISK_1

starting media recovery

archive log filename=C:\OR10G2DB\ARCH\OR10G2DB_9_645627350_1.ARC thread=1 sequence=9


archive log filename=C:\OR10G2DB\ARCH\OR10G2DB_10_645627350_1.ARC thread=1 sequence=10
archive log filename=C:\OR10G2DB\ARCH\OR10G2DB_11_645627350_1.ARC thread=1 sequence=11
archive log filename=C:\OR10G2DB\ARCH\OR10G2DB_11_645627350_1.ARC thread=1 sequence=12
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/10/2008 00:43:29
RMAN-11003: failure during parse/execution of SQL statement: alter database recover
logfile 'C:\OR10G2DB\ARCH\OR10G2DB_11_645627350_1.ARC'
ORA-00310: archived log contains sequence 11; sequence 12 required
ORA-00334: archived log: 'C:\OR10G2DB\ARCH\OR10G2DB_11_645627350_1.ARC'

RMAN> [command : ALTER DATABASE OPEN RESETLOGS]


database opened

RMAN>
}
The RECOVER could not find the Sequence#12 file as I had not renamed it to the new
log_archive_format (file name format). Therefore, it re-read the Sequence#11 file
thinking it to be for Sequence#12 and errored on it.

Summary :
There we have it ! The Database is actually recovered to a consistent point in time. We
have not applied ALL the ArchiveLogs (Sequence#14) but still do have a consistent
database (as of Sequence#11). Obviously, this is an Incomplete Recovery as we have not
continued applying Logs till the last Online Log.

Could I have recovered right up to Change#1546226 {which was the CURRENT_SCN


when the database was crashed and deleted} ? No. The last few transactions were still in
the Online Redo Logs. I could have recovered upto the last SCN in the last available
ArchiveLog (Sequence #14).

Note how the “Current_SCN” is visible only after we OPEN the database.

Since we have done a RESETLOGS, the database has diverged. If we want to reapply
Sequence#12 to Sequence#14, we need to know the procedure for a “Recovery Through
ResetLogs”.

Getting the SCNs and Timestamps (and Sequence#s) :


But the question still arises : How did Oracle know the SCN and Timestamp with the
Sequence# of the next archivelog file yet to be applied ? If my controlfile is older than
the archivelogs and I do not use a Repository, where does Oracle get the information to
construct the message “change <number> generated at <timestamp> needed for thread 1” ?
The fact of the matter is that information this informaton is in the DataFiles and Log files
(remember : Online Redo or Archive – Log files have the same format) !

These are from the datafile headers :


SQL> select file#, checkpoint_change#, to_char(checkpoint_time,'DD/MM/YYYY HH24:MI:SS')
2 from v$datafile_header
3* order by file#
SQL> /

FILE# CHECKPOINT_CHANGE# TO_CHAR(CHECKPOINT_


---------- ------------------ -------------------
1 1544306 09/02/2008 23:21:50
2 1544306 09/02/2008 23:21:50
3 1544306 09/02/2008 23:21:50
4 1544306 09/02/2008 23:21:50
5 1544306 09/02/2008 23:21:50

SQL>

These are from a dump of the SYSTEM01.DBF datafile :


V10 STYLE FILE HEADER:
Compatibility Vsn = 169869568=0xa200100
Db ID=138573118=0x842753e, Db Name='OR10G2DB'
Activation ID=0=0x0
Control Seq=6451=0x1933, File size=71680=0x11800
File Number=1, Blksiz=8192, File Type=3 DATA
Tablespace #0 - SYSTEM rel_fn:1
Creation at scn: 0x0000.00000009 08/30/2005 13:50:22
Backup taken at scn: 0x0000.00000000 01/01/1988 00:00:00 thread:0
reset logs count:0x267b7dd6 scn: 0x0000.00177396 reset logs terminal rcv data:0x0 scn:
0x0000.00000000
prev reset logs count:0x267aaf08 scn: 0x0000.0016ff67 prev reset logs terminal rcv
data:0x0 scn: 0x0000.00000000
recovered at 02/11/2008 23:04:13
status:0x2000 root dba:0x00400179 chkpt cnt: 867 ctl cnt:866
begin-hot-backup file size: 0
Checkpointed at scn: 0x0000.00179072 02/09/2008 23:21:50
thread:1 rba:(0x9.15a9.10)

Thus, the Datafiles identify the SCN being the lowest to be recovered (0x 179072, which
is 1544306 in Decimal). That is the first change to be recovered. (Note : It is higher
than the Checkpoint_Change# of the ControlFile – meaning that there had been a
Checkpoint after the ControlFile was backed up). The active log sequence at the time
was 0x9. Therefore, Oracle identifies that it needs to recover from SCN 1544306 in Log
file Sequence#9.
{If you find it curious that the Checkpoint_Change# 1544306 in the V$DATAFILE_HEADER view is
actually higher than that 1543675 in the V$DATABASE listing obtained after the Datafiles backup, see the
section titled “Different Checkpoint_Change# values” further below}.

Here are some lines of the header from a dump of the archivelog
C:\OR10G2DB\ARCH\ OR10G2DB_9_645627350_1.ARC (which was the archived
copy of Redo Log Sequence#9) :
DUMP OF REDO FROM FILE 'C:\OR10G2DB\ARCH\OR10G2DB_9_645627350_1.ARC'
Opcodes *.*
RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
FILE HEADER:
Compatibility Vsn = 169869568=0xa200100
Db ID=138573118=0x842753e, Db Name='OR10G2DB'
Activation ID=195152594=0xba1cad2
Control Seq=6498=0x1962, File size=16384=0x4000
File Number=2, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000009, SCN 0x000000178318-0x00000017923c"
thread: 1 nab: 0x3ef2 seq: 0x00000009 hws: 0x5 eot: 0 dis: 0
<lines deleted>
Low scn: 0x0000.00178318 (1540888) 02/02/2008 15:12:40
Next scn: 0x0000.0017923c (1544764) 02/09/2008 23:32:31
<lines deleted>

And this is from a dump of archivelog


C:\OR10G2DB\ARCH\ OR10G2DB_10_645627350_1.ARC :
DUMP OF REDO FROM FILE 'C:\OR10G2DB\ARCH\OR10G2DB_10_645627350_1.ARC'
Opcodes *.*
RBAs: 0x000000.00000000.0000 thru 0xffffffff.ffffffff.ffff
SCNs: scn: 0x0000.00000000 thru scn: 0xffff.ffffffff
Times: creation thru eternity
FILE HEADER:
Compatibility Vsn = 169869568=0xa200100
Db ID=138573118=0x842753e, Db Name='OR10G2DB'
Activation ID=195152594=0xba1cad2
Control Seq=6501=0x1965, File size=16384=0x4000
File Number=3, Blksiz=512, File Type=2 LOG
descrip:"Thread 0001, Seq# 0000000010, SCN 0x00000017923c-0x0000001793a7"
thread: 1 nab: 0x3df5 seq: 0x0000000a hws: 0x2 eot: 0 dis: 0
<lines deleted>
Low scn: 0x0000.0017923c (1544764) 02/09/2008 23:32:31
Next scn: 0x0000.001793a7 (1545127) 02/09/2008 23:32:35
<lines deleted>

Thus, it becomes obvious that when Oracle does a Log Switch (eg from Sequence#9 to
Sequence#10), it increments the SCN and updates the header of the previous log file
(Sequence#9) with information about the new SCN (1544764) and it’s Timestamp and
uses the new SCN as the Low SCN of the next log file (Seq #10). Therefore, the
Sequence#9 log file effectively has a pointer to Sequence#10.

Generating the file name itself depends on the LOG_ARCHIVE_FORMAT – as I’ve


shown, if I change the LOG_ARCHIVE_FORMAT, Oracle prompts for a file name with
the new format.

Different Checkpoint Change# values :


Why is it that the datafiles backed up before the transaction show a Checkpoint_Change#
1544306 when the query on V$DATABASE when beginning the transactions after the
backup of the datafiles still shows a lower Checkpoint_Change# 1543675 ? The
CURRENT_SCN when beginning transactions was 1544669, which is higher then that in
the datafile backups.
Here’s an explanation when an RMAN Backup is running – note thatthis RMAN backup
was a different backup done much later so the Checkpoint_Change# values listed below
are much higher than those in the Recovery testing in this document. This listing below
only explains how V$DATABASE.CHECKPOINT_CHANGE# can be different from
V$DATAFILE.CHECKPOINT_CHANGE#
SQL> l
1 select d.checkpoint_change# DB_Chk_CN, f.checkpoint_change# SYS_Chk_CN, c.c
urrent_scn
2 from
3 (select checkpoint_change# from v$database) d,
4 (select checkpoint_change# from v$datafile_header where file#=1) f,
5* (select current_scn from v$database) c
SQL> /

DB_CHK_CN SYS_CHK_CN CURRENT_SCN


---------- ---------- -----------
1559033 1565355 1565370

SQL>
Apparently, when I issue a BACKUP DATABASE in RMAN, the Checkpoint_Change#
in the Datafile headers IS incremented, but that in the Controlfile (reflected in
V$DATABASE) does not get updated. RMAN apparently forces a Datafile checkpoint
when it “picks up” the datafile. It is only at the completion of the next database
checkpoint that the controlfile (V$DATABASE) is updated as well.

{“Incremental Checkpoints” is another complication which we could discuss later}.

SCENARIO B : With a Trace Backup of the Controlfile

Step 1: I take a Trace Backup of the Controlfile.


SQL> alter database backup controlfile to trace as
2 'C:\Oracle_Exercises\cntrlfile_Trace.sql';
alter database backup controlfile to trace as
*
ERROR at line 1:
ORA-01277: file 'C:\ORACLE_EXERCISES\CNTRLFILE_TRACE.SQL' already exists

SQL> alter database backup controlfile to trace as


2 'C:\Oracle_Exercises\cntrlfile_Trace.sql' reuse;

Database altered.

SQL>
 the above command also illustrates the fact that we get an error if the trace already
exists and we can use the “REUSE” keyword to overwrite an existing tracefile.

Step 2: I run some transactions on the database to ensure a number of log switches and
SCN changes occur.

Step 3: I crash the database, remove the datafiles.

Step 4: I use the Trace script to recreate the controlfiles.


Ooops ! I cannot run a CREATE CONTROLFILE if datafiles are not present. I cannot
RESTORE datafiles using RMAN if I do not have a Controlfile and MOUNT the
database. I am in a Catch-22 situation.

This makes it very important to have a Binary Backup Controlfile ! Yes, using an
RMAN Repository is the “protection”. But if the Repository database is on the same
server as the target database and is also “lost” at the same time as the target database,
then I have no recourse. I can use Tracefile Backups to create Controlfiles when I use
scripted (known as “User Managed”) database backups and can manually (ie without
RMAN) restore the database files first. However, if the database file backups are in
RMAN Backup Sets, I must have a Controlfile restored first.

In a “User Managed” scenario, I would restore the database files from my own backup
(whether on disk or on tape) using the native, OS or Tape Library commands, create the
controlfile and then issue the RECOVER command. The RECOVER would read the
starting SCN and Sequence# from the datafiles and every subsequent Sequence# from the
ArchiveLogs that it applies.

10g RMAN also allows me to CATALOG RECOVERY AREA and CATALOG


BACKUPPIECE. 9i RMAN cannot do so (although it can CATALOG
DATAFILECOPY). One more reason why I would want a Binary Controlfile backup.

For other RECOVER DATABASE scenarios see :


http://www.freelists.org/archives/oracle-l/05-2007/msg00440.html
http://hemantoracledba.blogspot.com/2007/05/recovery-in-cold-backup.html
http://hemantoracledba.blogspot.com/2007/05/rollforward-from-cold-backup.html
A> Let me know How Oracle SCN concept will work in above mentioned scenario ?
Oracle first check controlfile checkpoint SCN number ,if checkpoint SCN in the
datafile header earlier then controlfile checkpoint SCN then oracle need
redo,recovery is overall the process of applying redo to data files.In more depth
recovery will synchronize the checkpoint SCN in the data files header to
checkpoint SCN in control file Or in broader term we can say goal of recovery is
to make sure the CKPT SCN in each datafile header matches the CKPT SCN in
the control file.

B> How SCN Synronization will happen ?


When you shutdown database with the immediate/normal/transactional clause
then oralce trigger a checkpoint where oracle makes the control files and datafiles
consistent to the same checpoint SCN during a database checkpoint.

C> How Oracle Database will understand what file Needs Restoration and
Recovery ?
For restoration database file oracle ,at startup oracle probe controlfile (metadata)
of yours database ,if it does not find the database file physically where it knows
then it needs restoration of that concerned database file.Lets say you take online
backup,if yours database file which is not available then restoration comes into
play,yours restored file is some time back then now yours existence others
database file specifiaclly with control file,controlfile checkpoint SCN header will
be ahead with restored lost database file,oracle decide requires recovery.

D> What the meaning of SCN Synronization ? If Database synronize Control File
SCN number with DBF File SCN then how it will work when we loose Control
File.

Always restoration of controlfile require recovery why..

As i understand it does not apply the redo to data files but an appearance just like
to apply redo which is not actual (you can also check this appearance by restoring
controlfile and then make recovery at sql by recover database until cancel and
then dont apply redo at first attempt and apply cancel),it does like that cause old
control file which doesn't know where the redo chain ends ,it may comes into
situation where redo log ahead to old backup control file this appearance of
recovery make datafile and controlfile consistent by compeling/forcing open
resetlogs.

OR
restored control file which doesn't know where the redo chain ends ,it may comes
into situation where redo log ahead to old backup control file, after restoring
controlfile which does not know the current log sequence number of redo log ,the
existing current redo log sequence number does not match to restored controlfile
for current log sequence number ,the controlfile checkpoint scn # would be earlier
to datafile checkpoint scn #,this appearance of recovery make datafile and
controlfile consistent as well restored controlfile adopt the new resetting log
sequence number by compeling/forcing open resetlogs.

How to get SCN from database. Timestamp against SCN


In many cases we need to know SCN of database. Also we may need to know the
previous SCN of the database suppose before 10 minutes ago. I will try to write we can
can get these two and how is this correlated.

A)Determine current SCN of The database.


-----------------------------------------------------------------------
You can query from V$DATABASE or using GET_SYSTEM_CHANGE_NUMBER
procedure of DBMS_FLASHBACK package.

1)SQL> SELECT DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER()


FROM DUAL;
DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER()
-----------------------------------------
1053658

2)SQL> SELECT CURRENT_SCN FROM V$DATABASE;


CURRENT_SCN
-----------
1053668

B)Determine current timestamp value.


-------------------------------------------------------------------
SQL> SELECT SYSTIMESTAMP FROM DUAL;
SYSTIMESTAMP
---------------------------------------------------------------------------
14-MAY-08 11.00.08.374107 PM -04:00

C)Convert SCN to Timestamp.


-----------------------------------------------------
SQL> SELECT SCN_TO_TIMESTAMP(1053639) FROM DUAL;
SCN_TO_TIMESTAMP(1053639)
---------------------------------------------------------------------------
14-MAY-08 10.52.15.000000000 PM

D)Convert Timestamp to SCN


-------------------------------------------------------------
SQL> SELECT TIMESTAMP_TO_SCN('14-MAY-08 11.00.08.374107 PM')
FROM DUAL;
TIMESTAMP_TO_SCN('14-MAY-0811.00.08.374107PM')
----------------------------------------------
1054516

Complete script used for RMAN Duplicate Database explanation

Thanks for reply and your comments for me.I am taking in positive way.Anyway i got
the solution and performed the job also.For your info i am giving step by step details to
you. May be be you can understand what is my requirement.whatever solution you have
given that anybody can do easily as it is basic rman feature and you can easily recover
database, my requirement is that backup set will move to other location (different
directory structure) from actual backup location and then recovery of database neeed to
perform means you know once you move the backup set to other location but recovery
catalog will ask the backup file from same location only.May be you got my point
anyway thansk to everybody for their support and expecting in future also same support.

=============================

Applies to:
Oracle Server - Enterprise Edition - Version: 10.2.0.0.0
Information in this document applies to any platform.

Goal
Restoring a database using rman on a different node with different backup directory
structures and different database directory structures .

- You have a database backed up on NODE 1


- You need to restore the database on NODE 2
- The directory structure is different on NODE 2
- You need to put the backups in a new directory structure in NODE 2 unlike as they
were in NODE 1
- You need to restore the database files into a new directory structure in NODE 2 unlike
as they were in NODE 1
Solution
Below is the procedure with an example:

1) Connect to the target database using rman and backup the database ---> NODE 1
$ rman target /Recovery Manager: Release 10.2.0.1.0 - Production on Tue Feb 13
00:29:33
2007Copyright © 1982, 2005, Oracle. All rights reserved.connected to target database:
ORA10G (DBID=3932056136)RMAN>
backup database plus archivelog;Starting backup at 13-FEB-07current log archivedusing
channel ORA_DISK_1channel
ORA_DISK_1: starting archive log backupsetchannel ORA_DISK_1: specifying archive
log(s) in backup setinput archive log thread=1
sequence=143 recid=109 stamp=614392105channel ORA_DISK_1: starting piece 1 at
13-FEB-07channel ORA_DISK_1: finished piece
1 at 13-FEB-07piece
handle=/u01/oracle/product/oradata/ora10g/fra/ORA10G/backupset/2007_02_13/o1_mf_
annnn_TAG20070213T002825_2x21kbds_.bkp
tag=TAG20070213T002825 comment=NONEchannel ORA_DISK_1: backup set
complete, elapsed time: 00:00:02Finished backup at 13-FEB-07Starting
backup at 13-FEB-07using channel ORA_DISK_1channel ORA_DISK_1: starting full
datafile backupsetchannel ORA_DISK_1: specifying
datafile(s) in backupsetinput datafile fno=00003
name=/u01/oracle/product/oradata/ora10g/data/sysaux01.dbfinput datafile
fno=00001 name=/u01/oracle/product/oradata/ora10g/data/system01.dbfinput datafile
fno=00002 name=/u01/oracle/product/oradata/ora10g/data/undotbs01.dbfinput
datafile fno=00004 name=/u01/oracle/product/oradata/ora10g/data/users01.dbfinput
datafile fno=00005 name=/home/oracle/1.dbfinput
datafile fno=00006 name=/u01/oracle/product/oradata/ora10g/data/sysaux02.dbfinput
datafile fno=00007 name=/u01/oracle/product/oradata/ora10g/data/undotbs02.dbfchannel
ORA_DISK_1: starting piece 1 at 13-FEB-07channel ORA_DISK_1: finished piece 1 at
13-FEB-07piece
handle=/u01/oracle/product/oradata/ora10g/fra/ORA10G/backupset/2007_02_13/o1_mf_
nnndf_TAG20070213T002827_2x21kd12_.bkp
tag=TAG20070213T002827 comment=NONEchannel ORA_DISK_1: backup set
complete, elapsed time: 00:00:55Finished backup at 13-FEB-07Starting
backup at 13-FEB-07current log archivedusing channel ORA_DISK_1channel
ORA_DISK_1: starting archive log backupsetchannel
ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1
sequence=144 recid=110 stamp=614392165channel
ORA_DISK_1: starting piece 1 at 13-FEB-07channel ORA_DISK_1: finished piece 1 at
13-FEB-07piece
handle=/u01/oracle/product/oradata/ora10g/fra/ORA10G/backupset/2007_02_13/o1_mf_
annnn_TAG20070213T002925_2x21m6ty_.bkp
tag=TAG20070213T002925 comment=NONEchannel ORA_DISK_1: backup set
complete, elapsed time: 00:00:02Finished backup at 13-FEB-07Starting
Control File and SPFILE Autobackup at 13-FEB-07piece
handle=/u01/oracle/product/ora10g/dbs/c-3932056136-20070213-02
comment=NONEFinished Control File and SPFILE Autobackup at 13-FEB-07RMAN>
exit
2) Move the following files to the NODE 2 :

+ The database backup pieces


+ Controlfile backup piece
+ The parameter file i.e init.ora file

3) Edit the PFILE on NODE 2 to change the environment specific parameters like .

user_dump_dest =
background_dump_dest =
control_files =
4) Once the PFILE is suitably modified invoke Rman on the NODE 2 after setting the
Oracle environment variables and start the database in nomount mode:

[oracle@test-br test]$ export ORACLE_HOME=/u01/oracle/product/ora10g


[oracle@test-br test]$ export ORACLE_SID=ora10g
[oracle@test-br test]$ export PATH=$ORACLE_HOME/bin:$PATH
[oracle@test-br test]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Feb 13 00:36:55 2007
Copyright © 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup nomount
Oracle instance started
Total System Global Area 205520896 bytes
Fixed Size 1218508 bytes
Variable Size 75499572 bytes
Database Buffers 121634816 bytes
Redo Buffers 7168000 bytes

5) Restore the controlfile from the backup piece .


RMAN> restore controlfile from '/u01/oracle/product/ora10g/dbs/c-3932056136-
20070213-02';
Starting restore at 13-FEB-07
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:02
output filename=/u01/oracle/product/oradata/ora10g/cntrl/control01.ctl
Finished restore at 13-FEB-07

6) Mount the database

RMAN> alter database mount ;

7) Now catalog the backup pieces that were shipped from NODE 1

RMAN> catalog backuppiece


'/home/oracle/test/backup/o1_mf_annnn_TAG20070213T002925_2x21m6ty_.bkp';Starti
ng
implicit crosscheck backup at 13-FEB-07allocated channel: ORA_DISK_1channel
ORA_DISK_1: sid=155 devtype=DISKCrosschecked
3 objectsFinished implicit crosscheck backup at 13-FEB-07Starting implicit crosscheck
copy at 13-FEB-07using channel
ORA_DISK_1Finished implicit crosscheck copy at 13-FEB-07searching for all files in
the recovery areacataloging files...no
files catalogedcataloged backuppiecebackup piece
handle=/home/oracle/test/backup/o1_mf_annnn_TAG20070213T002925_2x21m6ty_.bk
p
recid=41 stamp=614393265RMAN> catalog backuppiece
'/home/oracle/test/backup/o1_mf_annnn_TAG20070213T002825_2x21kbds_.bkp';catalo
ged
backuppiecebackup piece
handle=/home/oracle/test/backup/o1_mf_annnn_TAG20070213T002825_2x21kbds_.bkp
recid=42 stamp=614393292RMAN>
catalog backuppiece
'/home/oracle/test/backup/o1_mf_nnndf_TAG20070213T002827_2x21kd12_.bkp';catalo
ged backuppiecebackup
piece
handle=/home/oracle/test/backup/o1_mf_nnndf_TAG20070213T002827_2x21kd12_.bkp
recid=43 stamp=614393310

8) Get to know the last sequence available in the archivelog backup using the following
command

RMAN > list backup of archivelog all;

9) Rename the Redologfiles,so that they can be created in new locations when opened the
database is opened in resetlogs

SQL> alter database rename file '/u01/oracle/product/oradata/ora10g/log/redo01.log' to


'/home/oracle/test/log/redo01.log';..................

10) Now restore the datafiles to new locations and recover

RMAN> run { set until sequence <seq_no> set newname for datafile 1 to
'/home/oracle/test/data/sys01.dbf';
set newname for datafile 2 to '/home/oracle/test/data/undotbs01.dbf'; set newname for
datafile 3 to '/home/oracle/test/data/sysaux01.dbf';
set newname for datafile 4 to '/home/oracle/test/data/users01.dbf'; set newname for
datafile 5 to '/home/oracle/test/data/1.dbf';
set newname for datafile 6 to '/home/oracle/test/data/sysaux02.dbf'; set newname for
datafile 7 to '/home/oracle/test/data/undotbs02.dbf';
restore database; switch datafile all; recover database; alter database open resetlogs; }

run a crosscheck first to update your controlfiles. Doing so will make sure that the
RMAN is only looking for nonexpired files.

change archivelog all crosscheck;


crosscheck backup of database;
RMAN-06025: no backup of log thread 1 seq
RMAN> run
2> {
3> RESTORE VALIDATE CHECK LOGICAL ARCHIVELOG ALL;
4> }

Starting restore at 08-OCT-08


using channel ORA_DISK_1

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 10/08/2008 11:40:16
RMAN-06026: some targets not found - aborting restore
RMAN-06025: no backup of log thread 1 seq 31 lowscn 374582 found to
restore
RMAN-06025: no backup of log thread 1 seq 30 lowscn 374398 found to
restore
RMAN-06025: no backup of log thread 1 seq 29 lowscn 374337 found to
restore
RMAN-06025: no backup of log thread 1 seq 28 lowscn 374159 found to
restore
RMAN-06025: no backup of log thread 1 seq 27 lowscn 374073 found to
restore
RMAN-06025: no backup of log thread 1 seq 26 lowscn 373814 found to
restore
RMAN-06025: no backup of log thread 1 seq 25 lowscn 373756 found to
restore
RMAN-06025: no backup of log thread 1 seq 24 lowscn 373318 found to
restore
RMAN-06025: no backup of log thread 1 seq 23 lowscn 373184 found to
restore
RMAN-06025: no backup of log thread 1 seq 22 lowscn 373004 found to
restore
RMAN-06025: no backup of log thread 1 seq 21 lowscn 372946 found to
restore
RMAN-06025: no backup of log thread 1 seq 20 lowscn 371604 found to
restore
RMAN-06025: no backup of log thread 1 seq 19 lowscn 371598 found to
restore
RMAN-06025: no backup of log thread 1 seq 18 lowscn 371198 found to
restore
RMAN-06025: no backup of log thread 1 seq 17 lowscn 351033 found to
restore
RMAN-06025: no backup of log thread 1 seq 16 lowscn 330912 found to
restore
RMAN-06025: no backup of log thread 1 seq 15 lowscn 330901 found to
restore
RMAN-06025: no backup of log thread 1 seq 14 lowscn 330754 found to
restore
RMAN-06025: no backup of log thread 1 seq 13 lowscn 330749 found to
restore
RMAN-06025: no backup of log thread 1 seq 12 lowscn 330449 found to
restore
RMAN-06025: no backup of log thread 1 seq 11 lowscn 330444 found to
restore
RMAN-06025: no backup of log thread 1 seq 10 lowscn 330119 found to
restore
RMAN-06025: no backup of log thread 1 seq 9 lowscn 330114 found to
restore
RMAN-06025: no backup of log thread 1 seq 8 lowscn 330052 found to
restore
RMAN-06025: no backup of log thread 1 seq 7 lowscn 330046 found to
restore
RMAN-06025: no backup of log thread 1 seq 6 lowscn 329222 found to
restore

SQL> select sequence# from v$archived_log


2 /

SEQUENCE# S
---------- -
6 D
7 D
8 D
9 D
10 D
11 D
12 D
13 D
14 D
15 D
16 D
17 D
18 D
19 D
20 D
21 D
22 D
23 D
24 D
25 D
26 D
27 D
28 D
29 D
30 D
31 D
32 A
33 A
34 A
35 A

30 rows selected.
As you can see log sequence 6 to 31 either deleted by RMAN or deleted by OS and then
crosschecked or these logs never backed up but deleted by OS and then
crosschecked.Restore archivelog all will try to restore all archivelogs that are within
repository (i.e controlfile). As you never backed up log sequence 6 to 31 but RMAN will
try to restore those log sequence.
Workaround 1
RMAN> list archivelog all
2> ;

List of Archived Log Copies


Key Thrd Seq S Low Time Name
------- ---- ------- - --------- ----
27 1 32 A 07-OCT-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\POP\ARCHIVELOG\2008_10_07\
O1_MF_1_32_4GQB1ZSD_.ARC
28 1 33 A 07-OCT-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\POP\ARCHIVELOG\2008_10_07\
O1_MF_1_33_4GQB51GN_.ARC
29 1 34 A 07-OCT-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\POP\ARCHIVELOG\2008_10_08\
O1_MF_1_34_4GRCZ11G_.ARC
30 1 35 A 08-OCT-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\POP\ARCHIVELOG\2008_10_08\
O1_MF_1_35_4GRM3Y0Z_.ARC

RMAN> run
2> {
3> RESTORE VALIDATE CHECK LOGICAL ARCHIVELOG from sequence 32;
4> }

Starting restore at 08-OCT-08


using channel ORA_DISK_1

channel ORA_DISK_1: scanning archive log


C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\POP\ARCHIVELOG\2008_10_07\
O1_MF_1_32_4GQB1ZSD_.ARC
channel ORA_DISK_1: scanning archive log
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\POP\ARCHIVELOG\2008_10_07\
O1_MF_1_33_4GQB51GN_.ARC
channel ORA_DISK_1: scanning archive log
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\POP\ARCHIVELOG\2008_10_08\
O1_MF_1_34_4GRCZ11G_.ARC
channel ORA_DISK_1: scanning archive log
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\POP\ARCHIVELOG\2008_10_08\
O1_MF_1_35_4GRM3Y0Z_.ARC
Finished restore at 08-OCT-08
Workaround 2
You can go with recvoery catalog for detail see metalink note 235973.1

Question :
after performing recovery, how can we know till what time the target database is being
recovered.

RMAN> backup database;

Starting backup at 16-SEP-09


using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001
name=/u01/app/oracle/oradata/mmi/system01.dbf
input datafile file number=00002
name=/u01/app/oracle/oradata/mmi/sysaux01.dbf
input datafile file number=00003
name=/u01/app/oracle/oradata/mmi/undotbs01.dbf
input datafile file number=00005
name=/u01/app/oracle/oradata/mmi/mydatafile.dbf
input datafile file number=00004
name=/u01/app/oracle/oradata/mmi/users01.dbf
channel ORA_DISK_1: starting piece 1 at 16-SEP-09
channel ORA_DISK_1: finished piece 1 at 16-SEP-09
piece
handle=/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_
16/o1_mf_nnndf_TAG20090916T134511_5c19dv9q_.bkp
tag=TAG20090916T134511 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 16-SEP-09

Starting Control File and SPFILE Autobackup at 16-SEP-09


piece
handle=/u01/app/oracle/flash_recovery_area/MMI/autobackup/2009_09
_16/o1_mf_s_697729560_5c19gcmc_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 16-SEP-09

RMAN> sql 'alter system archive log current';

sql statement: alter system archive log current

RMAN> sql 'alter system archive log current';

sql statement: alter system archive log current

RMAN> sql 'alter system archive log current';

sql statement: alter system archive log current

RMAN> shutdown abort

Oracle instance shut down

RMAN> exit
Recovery Manager complete.

[oracle@khurram ~]$ rm -rf /u01/app/oracle/oradata/mmi/*


[oracle@khurram ~]$ rman target /

Recovery Manager: Release 11.1.0.6.0 - Production on Wed Sep 16


13:47:35 2009

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

connected to target database (not started)

RMAN> startup nomount

Oracle instance started

Total System Global Area 1620115456 bytes

Fixed Size 2144864 bytes


Variable Size 721421728 bytes
Database Buffers 889192448 bytes
Redo Buffers 7356416 bytes

RMAN> restore controlfile from autobackup;

Starting restore at 16-SEP-09


using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=153 device type=DISK

recovery area destination: /u01/app/oracle/flash_recovery_area


database name (or database unique name) used for search: MMI
channel ORA_DISK_1: AUTOBACKUP
/u01/app/oracle/flash_recovery_area/MMI/autobackup/2009_09_16/o1_
mf_s_697729560_5c19gcmc_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID
was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP
/u01/app/oracle/flash_recovery_area/MMI/autobackup/2009_09_16/o1_
mf_s_697729560_5c19gcmc_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/app/oracle/oradata/mmi/control01.ctl
output file name=/u01/app/oracle/oradata/mmi/control02.ctl
output file name=/u01/app/oracle/oradata/mmi/control03.ctl
Finished restore at 16-SEP-09
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1
From another terminal come at SQL
[oracle@khurram ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Wed Sep 16 13:49:14


2009

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing
options

SQL> set linesize 1000


SQL> select substr(name,1,50)
fname,checkpoint_change#,last_change#,status
2 from v$datafile;

FNAME CHECKPOINT_CHANGE#
LAST_CHANGE# STATUS
-------------------------------------------------- ------------------ ------------ -------
/u01/app/oracle/oradata/mmi/system01.dbf 1350307
SYSTEM
/u01/app/oracle/oradata/mmi/sysaux01.dbf 1350307
ONLINE
/u01/app/oracle/oradata/mmi/undotbs01.dbf 1350307
ONLINE
/u01/app/oracle/oradata/mmi/users01.dbf 1350307
ONLINE
/u01/app/oracle/oradata/mmi/mydatafile.dbf 1350307
ONLINE
here you can see that within control file repository the data files START SCN
(CHECKPOINT_SCHANGE#) is 1350307,whenever checkpoints occur, Oracle writes a
START SCN to the data file headers as well it writes the START SCN within controlfile
for each datafile.The control file also maintains another SCN value for each data file with
START SCN is the STOP SCN, this STOP SCN is usually null (infinity) when yours
database status is open and datafile status is online , the null status shows that recovery
will start from START SCN and will goes to the end of redo thread.The STO SCN here is
LAST_CHANGE#
RMAN> restore database;

Starting restore at 16-SEP-09


Starting implicit crosscheck backup at 16-SEP-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=152 device type=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 16-SEP-09

Starting implicit crosscheck copy at 16-SEP-09


using channel ORA_DISK_1
Finished implicit crosscheck copy at 16-SEP-09

searching for all files in the recovery area


cataloging files...
cataloging done

List of Cataloged Files


=======================
File Name:
/u01/app/oracle/flash_recovery_area/MMI/autobackup/2009_09_16/o1_
mf_s_697729560_5c19gcmc_.bkp
File Name:
/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_16/o1_m
f_1_1_5c19gzs5_.arc
File Name:
/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_16/o1_m
f_1_2_5c19h2m0_.arc
File Name:
/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_16/o1_m
f_1_3_5c19h4tk_.arc

using channel ORA_DISK_1

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
/u01/app/oracle/oradata/mmi/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to
/u01/app/oracle/oradata/mmi/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to
/u01/app/oracle/oradata/mmi/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to
/u01/app/oracle/oradata/mmi/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to
/u01/app/oracle/oradata/mmi/mydatafile.dbf
channel ORA_DISK_1: reading from backup piece
/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_16/o1_mf
_nnndf_TAG20090916T134511_5c19dv9q_.bkp
channel ORA_DISK_1: piece
handle=/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_
16/o1_mf_nnndf_TAG20090916T134511_5c19dv9q_.bkp
tag=TAG20090916T134511
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 16-SEP-09

SQL> select substr(name,1,50)


fname,checkpoint_change#,last_change#,status
2 from v$datafile;

FNAME CHECKPOINT_CHANGE#
LAST_CHANGE# STATUS
-------------------------------------------------- ------------------ ------------ -------
/u01/app/oracle/oradata/mmi/system01.dbf 1350307
SYSTEM
/u01/app/oracle/oradata/mmi/sysaux01.dbf 1350307
ONLINE
/u01/app/oracle/oradata/mmi/undotbs01.dbf 1350307
ONLINE
/u01/app/oracle/oradata/mmi/users01.dbf 1350307
ONLINE
/u01/app/oracle/oradata/mmi/mydatafile.dbf 1350307
ONLINE
Now do recovery
RMAN> recover database;

Starting recover at 16-SEP-09


using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 1 is already on disk as file


/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_16/o1_m
f_1_1_5c19gzs5_.arc
archived log for thread 1 with sequence 2 is already on disk as file
/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_16/o1_m
f_1_2_5c19h2m0_.arc
archived log for thread 1 with sequence 3 is already on disk as file
/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_16/o1_m
f_1_3_5c19h4tk_.arc
archived log file
name=/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_1
6/o1_mf_1_1_5c19gzs5_.arc thread=1 sequence=1
archived log file
name=/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_1
6/o1_mf_1_2_5c19h2m0_.arc thread=1 sequence=2
archived log file
name=/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_1
6/o1_mf_1_3_5c19h4tk_.arc thread=1 sequence=3
unable to find archived log
archived log thread=1 sequence=4
RMAN-00571:
==========================================
=================
RMAN-00569: =============== ERROR MESSAGE STACK
FOLLOWS ===============
RMAN-00571:
==========================================
=================
RMAN-03002: failure of recover command at 09/16/2009 13:51:44
RMAN-06054: media recovery requesting unknown archived log for
thread 1 with sequence 4 and starting SCN of 1350423

SQL> select substr(name,1,50)


fname,checkpoint_change#,last_change#,status
2 from v$datafile;

FNAME CHECKPOINT_CHANGE#
LAST_CHANGE# STATUS
-------------------------------------------------- ------------------ ------------ -------
/u01/app/oracle/oradata/mmi/system01.dbf 1350423
SYSTEM
/u01/app/oracle/oradata/mmi/sysaux01.dbf 1350423
ONLINE
/u01/app/oracle/oradata/mmi/undotbs01.dbf 1350423
ONLINE
/u01/app/oracle/oradata/mmi/users01.dbf 1350423
ONLINE
/u01/app/oracle/oradata/mmi/mydatafile.dbf 1350423
ONLINE
Here you can see that within controlfile repositry there is datafile header START SCN
which was 1350307 after restore,when you started recovery now its SCN is 1350423
which shows that yours recovery process start from SCN 1350307 and ends at 1350423.
Question :

Daily i used take full backup using rman,after that when query report need backup it
showing all datafile list, i don't understand how come it showing all the datafile list
thought i take full backup please help me in this issues.

Answer :

It relates to yours retention policy if you would have retention policy to 2 and you have
one backupsets of USERS tablespace then it will require one more for tablespace users to
mature yours retention policy.

RMAN> list backup


2> ;

List of Backup Sets


===================

BS Key Size Device Type Elapsed Time Completion Time


------- ---------- ----------- ------------ ---------------
5 595.00K DISK 00:00:03 15-SEP-09
BP Key: 5 Status: AVAILABLE Compressed: NO Tag:
TAG20090915T110249
Piece Name:
/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_15/o1_mf_annn
n_TAG20090915T110249_5bycjdm6_.bkp

List of Archived Logs in backup set 5


Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 17 1320409 15-SEP-09 1320963 15-SEP-09

BS Key Type LV Size Device Type Elapsed Time Completion Time


------- ---- -- ---------- ----------- ------------ ---------------
6 Full 1005.51M DISK 00:01:14 15-SEP-09
BP Key: 6 Status: AVAILABLE Compressed: NO Tag:
TAG20090915T110253
Piece Name:
/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_15/o1_mf_nnnd
f_TAG20090915T110253_5bycjk2h_.bkp
List of Datafiles in backup set 6
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1320969 15-SEP-09
/u01/app/oracle/oradata/mmi/system01.dbf
2 Full 1320969 15-SEP-09
/u01/app/oracle/oradata/mmi/sysaux01.dbf
3 Full 1320969 15-SEP-09
/u01/app/oracle/oradata/mmi/undotbs01.dbf
4 Full 1320969 15-SEP-09
/u01/app/oracle/oradata/mmi/users01.dbf
5 Full 1320969 15-SEP-09
/u01/app/oracle/oradata/mmi/mydatafile.dbf

BS Key Size Device Type Elapsed Time Completion Time


------- ---------- ----------- ------------ ---------------
7 10.00K DISK 00:00:03 15-SEP-09
BP Key: 7 Status: AVAILABLE Compressed: NO Tag:
TAG20090915T110412
Piece Name:
/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_15/o1_mf_annn
n_TAG20090915T110412_5byclzbb_.bkp

List of Archived Logs in backup set 7


Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 18 1320963 15-SEP-09 1321005 15-SEP-09

BS Key Type LV Size Device Type Elapsed Time Completion Time


------- ---- -- ---------- ----------- ------------ ---------------
8 Full 9.39M DISK 00:00:00 15-SEP-09
BP Key: 8 Status: AVAILABLE Compressed: NO Tag:
TAG20090915T110416
Piece Name:
/u01/app/oracle/flash_recovery_area/MMI/autobackup/2009_09_15/o1_mf_s_6
97633458_5bycm3q8_.bkp
SPFILE Included: Modification time: 15-SEP-09
SPFILE db_unique_name: MMI
Control File Included: Ckp SCN: 1321012 Ckp time: 15-SEP-09

RMAN> show retention policy;

RMAN configuration parameters for database with db_unique_name MMI are:


CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

RMAN> report need backup;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
Report of files with less than 1 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------

RMAN> configure retention policy to redundancy 2


2> ;

new RMAN configuration parameters:


CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored
RMAN> report need backup
2> ;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 2
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
1 1 /u01/app/oracle/oradata/mmi/system01.dbf
2 1 /u01/app/oracle/oradata/mmi/sysaux01.dbf
3 1 /u01/app/oracle/oradata/mmi/undotbs01.dbf
4 1 /u01/app/oracle/oradata/mmi/users01.dbf
5 1 /u01/app/oracle/oradata/mmi/mydatafile.dbf

RMAN> configure retention policy to redundancy 1


2> ;

old RMAN configuration parameters:


CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters are successfully stored

RMAN> report need backup


2> ;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
Report of files with less than 1 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------

RMAN>

Media recovery start point


Media Recovery will always start from the most earliest restored datafile header CKPT
SCN.
SQL> select controlfile_change#,checkpoint_change#
2 from v$database
3 /

CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------------------- ------------------
675815 675666

SQL> select substr(name,1,51) fname,checkpoint_change#


2 from v$datafile_header
3 /

FNAME CHECKPOINT_CHANGE#
--------------------------------------------------- ------------------
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSTEM01.DBF
675666
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\UNDOTBS01.DBF
675666
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSAUX01.DBF
675666
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\USERS01.DBF
675666
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\USERS02.DBF
675666
Shutdown immediate the database and then make a cold copy of user01.dbf datafiles to
folder A
F:\oracle\product\10.1.0\oradata>cd prod

F:\oracle\product\10.1.0\oradata\prod>mkdir A

F:\oracle\product\10.1.0\oradata\prod>copy users01.dbf A
1 file(s) copied.
Start the database
SQL> startup
ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145750508 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.
Database opened.

SQL> select controlfile_change#,checkpoint_change#


2 from v$database
3 /

CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------------------- ------------------
676283 676131

SQL> select substr(name,1,51) fname,checkpoint_change#


2 from v$datafile_header
3 /

FNAME CHECKPOINT_CHANGE#
--------------------------------------------------- ------------------
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSTEM01.DBF
676131
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\UNDOTBS01.DBF
676131
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSAUX01.DBF
676131
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\USERS01.DBF
676131
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\USERS02.DBF
676131
shutdown immediate again the database and make copy of system01.dbf datafiles to
folder B,every shutdown immediate itself make a checkpoint and increment the CKPT
SCN at datafile header with controlfile.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

F:\oracle\product\10.1.0\oradata\prod>mkdir B

F:\oracle\product\10.1.0\oradata\prod>copy system01.dbf B
1 file(s) copied.
Start the database
SQL> startup
ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145750508 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.
Database opened.
SQL> select controlfile_change#,checkpoint_change#
2 from v$database
3 /

CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------------------- ------------------
676623 676473

SQL> select substr(name,1,51) fname,checkpoint_change#


2 from v$datafile_header
3 /
FNAME CHECKPOINT_CHANGE#
--------------------------------------------------- ------------------
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSTEM01.DBF
676473
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\UNDOTBS01.DBF
676473
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSAUX01.DBF
676473
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\USERS01.DBF
676473
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\USERS02.DBF
676473

Shutdown immediate the database again and then make a cold copy of user02.dbf
datafiles to folder C.
F:\oracle\product\10.1.0\oradata\prod>mkdir C

F:\oracle\product\10.1.0\oradata\prod>copy users02.dbf C
1 file(s) copied.

F:\oracle\product\10.1.0\oradata\prod>
Dont startup the database let it be remain shutdown,copy users01.dbf from folder
A,system01 from folder B and users02 from folder C to the folder
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD respectivley. After copying those
file to prod folder from A,B and C startup the database
==========================================
================================
Copy user01.dbf from folder A
(F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\A)
to folder PROD (F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD)
==========================================
================================

F:\oracle\product\10.1.0\oradata\prod>copy
F:\oracle\product\10.1.0\oradata\prod\A\users01.dbf
F:\oracle\product\10.1.0\oradata\prod\
Overwrite F:\oracle\product\10.1.0\oradata\prod\USERS01.DBF?
(Yes/No/All): yes
1 file(s) copied.

==========================================
=================================
Copy system01.dbf from folder B
(F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\B)
to folder PROD (F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD)
==========================================
=================================

F:\oracle\product\10.1.0\oradata\prod>copy
F:\oracle\product\10.1.0\oradata\prod
\B\system01.dbf F:\oracle\product\10.1.0\oradata\prod\
Overwrite F:\oracle\product\10.1.0\oradata\prod\SYSTEM01.DBF?
(Yes/No/All): yes
1 file(s) copied.

==========================================
=================================
Copy users02.dbf from folder C
(F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\C)
to folder PROD (F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD)
==========================================
=================================

F:\oracle\product\10.1.0\oradata\prod>copy
F:\oracle\product\10.1.0\oradata\prod
\C\users02.dbf F:\oracle\product\10.1.0\oradata\prod\
Overwrite F:\oracle\product\10.1.0\oradata\prod\USERS02.DBF?
(Yes/No/All): yes
1 file(s) copied.
SQL> startup
ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145750508 bytes
Database Buffers 25165824 bytes
Redo Buffers 262144 bytes
Database mounted.
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1:
'F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSTEM01.DBF'

SQL> select controlfile_change#,checkpoint_change#


2 from v$database
3 /

CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------------------- ------------------
678259 678859
SQL> select substr(name,1,51) fname,checkpoint_change#
2 from v$datafile_header
3 /

FNAME CHECKPOINT_CHANGE#
--------------------------------------------------- ------------------
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSTEM01.DBF
676472
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\UNDOTBS01.DBF
678859
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSAUX01.DBF
678859
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\USERS01.DBF
676130
F:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\USERS02.DBF
678859
See above you will find that 676130 of users01.dbf is the earliest/oldest CKPT SCN with
others datafile system01.dbf 676472 and users02.dbf 678859 recovery will start from that
point 676130 which is earliest and oldest within restored datafiles.
SQL> recover database until cancel
ORA-00279: change 676130 generated at 04/11/2009 04:02:23
needed for thread 1
ORA-00289: suggestion :
F:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\PROD\ARCHIVEL
OG\2009_04_11\O1_MF_1_
1_%U_.ARC
ORA-00280: change 676130 for thread 1 is in sequence #1

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

Oracle Locks
User must request a resource (i.e row,table,index etc) before using it and must release
that resource after using it.
Without following above approach there would be collision among user requests which
result data to be in inconsistent.To avoid data inconsistency a lock mechanisim adopted
within different database,Every database has its own locking mechanism.
Oracle uses two modes in a multiuser database either its on table or row

Exclusive lock mode


Exclusive lock mode never allowed the associates resource from being shared.This lock
mode is obtained to modify data.Only one exclusive lock can be placed on a resource
(such as a row or a table).
i.e

From one session i acquire the exclusive lock on resource (emp table)
Session a

SQL> lock table emp in exclusive mode nowait


2 /

Table(s) Locked.
Note : The optional keyword NOWAIT tells Oracle not to wait for a table if it has been
locked by another user.

From another session i try to acquire the exclusive lock on same resource (emp table) as
"session a" above already acquired.
Session b

SQL> lock table emp in exclusive mode nowait


2 /
lock table emp in exclusive mode nowait
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified
Even you cannot get shared lock over that table which has already exclusive mode lock
SQL> lock table emp in row share mode nowait
2 /
lock table emp in row share mode nowait
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified
Exclusive lock can be acquired at table level as well at row level.But oralce automatically
acquire exclusive lock at row level which is the beauty of oracle to create data consistent
as well maintain concurrency.

Share lock mode


Share lock mode allows the associated resource to be shared subject to cirumstances.

i.e

From one session i acquire the share lock on resource (emp table)
Session c

SQL> lock table emp in row share mode nowait


2 /

Table(s) Locked.
From another session i try to acquire the same resource exclusive lock on same resoruces
(emp table) which has already above taken by "session c".
Session d

SQL> lock table emp in row share mode nowait


2 /

Table(s) Locked.
Share locks dont allow to acquire exclusive lock over the associates resource.

i.e

From one session i acquire the share lock on resource (emp table)
Session e

SQL> lock table emp in row share mode nowait


2 /

Table(s) Locked.
From another session i try to acquire the same exclusive lock on same resoruces (emp
table) which has already taken by above "session e".
Session f

SQL> lock table emp in exclusive mode nowait


2 /
lock table emp in exclusive mode nowait
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified
Now you are aware about locking mode.

Locks Types

DML locks
DML locks are locks which are acquired automatically by Oracle to protect data in tables
and indexes Whenever you issue a DML statement to modify data i.e SELECT..FOR
UPDATE,INSERT, UPDATE, MERGE, and DELETE statments.DML locks prevent
destructive interference of simultaneous conflicting DML or DDL operations. DML
statments automatically acquire lock on two levels

i) Row-Level Locks (TX)


ii)Table Level Locks(TM)

These DML locks are always and only (exclusive) at row level but it can be shared as
well as exclusive at table level.

Here TX specify lock at row level while TM is at table level.


i) Row Level Locks (TX)
Row-level locks are primarily used to prevent two transactions from modifying the same
row. When a transaction needs to modify a row, a row lock is acquired.Any INSERT,
DELETE, UPDATE, or SELECT FOR UPDATE statements will automatically issue an
exclusive lock on the rows affected by the transaction. This exclusive lock at row means
that other transactions can’t modify the affected rows until the original transaction
commits or rolls back, thereby releasing the exclusive locks.
ii) Table Level Lock (TM)
Whenever you acquire any row level lock there is ultimately a table level is also acquired
to prvent others session to alter, drop this table whose rows are being modified.TM Per
table locks are acquired during the execution of a transaction when referencing a table
with a DML statement so that the object is not dropped or altered during the execution of
the transaction.

Here is an exceprt from SQL to verify that DML acquires lock at both row and table level
Session 1

SQL> update emp


2 set sal=sal+1
3 where empno=7566
4 /

1 row updated.

Session 2

SQL> update emp


2 set sal=sal+1
3 where empno=7566
4 /
.
.

hanged

Session 3

SQL> drop table emp


2 /
drop table emp
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified
Above excerpt from SQL gives now a little fog but uptil now you might be clear that
DML acquires lock at both row and table level ,to be more clear about this statment that
"DML acquires lock at both row and table level" we need to explore oracle dynamic view
v$lock.
SQL> conn sys/sys@prod as sysdba
Connected.
SQL> desc v$lock
Name Null? Type
---------- -------- ----------------------------
ADDR RAW(4)
KADDR RAW(4)
SID NUMBER
TYPE VARCHAR2(2)
ID1 NUMBER
ID2 NUMBER
LMODE NUMBER
REQUEST NUMBER
CTIME NUMBER
BLOCK NUMBER
From this view you just need to understand the columns TYPE (Lock type),LMODE
(Lock mode) and REQUEST

As we have already seen that there are two types of DML locks

Row Level (TX)


Table Level (TM)
Type will show you the locks type either its (TX or TM)

Lock Mode (LMODE)

Lock mode tell you strength of lock ,oracle placed numbered for each lock mode (0 to 6)
according to its strength.The higher the number the more its stronger.Remember follows
lock mode can be at row as well table level.
6 - Exclusive (X)
5 - Shared Row Exclusive (SRX)
4 - Share (S)
3 - Row Exclusive (RX)
2 - Row Share (RS)
1 - null (NULL)
0 - none
Lets explore only 6 and 3 right now for eliminating little fog that "DML acquires lock at
both row and table level",After that we will explore others in next blog.
6 - Exclusive (X) The most restrictive locking mode; permits queries on the locked table
but prohibits any DML by any other users. Above statment says that you cannot acquire
that lock on that same resource (Table,Rows) which is already acquired by another
session. Like if you have table level exclusive lock then no other session can get any lock
on that table,same if you have exclusive lock on rows then no other session can acquire
lock on that rows ,yes you can get any other lock other then that rows which have already
exclusive lock. This mode is automatically obtained when using the DROP TABLE
statement.
3 - Row Exclusive (RX) A row exclusive table lock generally indicates that the transaction
holding the lock has made one or more updates to rows in the table. A row exclusive
table lock is acquired automatically for a table modified by the following types of
statements.

INSERT INTO table ... ;

UPDATE table ... ;

DELETE FROM table ... ;

LOCK TABLE table IN ROW EXCLUSIVE MODE;

Permitted Operations : A row exclusive table lock held by a transaction allows other
transactions to query, insert, update,delete, or lock rows concurrently in the same table.
Therefore, row exclusive table locks allow multiple transactions to obtain simultaneous
row exclusive and row share table locks for the same table. Prohibited Operations : A row
exclusive table lock held by a transaction prevents other transactions from manually
locking the table for exclusive reading or writing. Therefore, other transactions cannot
concurrently lock the table using the following statements:

LOCK TABLE table IN SHARE MODE;

LOCK TABLE table IN SHARE EXCLUSIVE MODE;

LOCK TABLE table IN EXCLUSIVE MODE;

Here is an excerpt from SQL to see both lock mode


SQL> update emp
2 set sal=sal+1
3 where empno=7566
4 /

1 row updated.

SQL> show user


USER is "SYS"

SQL> select username


2 ,v$lock.sid
3 ,v$lock.type "lock type"
4 ,lmode "lock mode"
5 from v$lock,v$session
6 where v$lock.sid = v$session.sid
7 and v$session.username='SCOTT'
8 order by v$lock.sid
9 /

USERNAME SID lo lock mode


------------------------------ ---------- -- ----------
SCOTT 161 TX 6
SCOTT 161 TM 3
As you can see DML locks within session for an update statment acquired TX (Row
Level) lock with lock mode 6 which is an exclusive (the most restrictive/aggresive
lock).You are also seeing that this DML lock also acquire TM (Table Level) with lock
mode 3 which is row exclusive this lock will prevent other session to drop that table. I
will post with others mode in next blog
Posted by Khurram Siddiqui at 2:46 AM

How oracle makes media recovery


Oracle Instance shutdown with command
SQL > Shutdown immediate

Oracle Instance shutdown with command


SQL > SHUTDOWN ABORT

Let me know How Oracle SCN concept will work in above mentioned
scenario ?

Oracle first check controlfile checkpoint SCN number ,if checkpoint SCN
in the
datafile header earlier then controlfile checkpoint SCN then oracle
need
redo,recovery is overall the process of applying redo to data files.In
more
depth recovery will synchronize the checkpoint SCN in the data files
header to
checkpoint SCN in control file header Or in broader term we can say
goal of
recovery is to make sure the CKPT SCN in each datafile header
matches the CKPT
SCN in the control file.

How SCN Synronization will happen ?

When you shutdown database with the


immediate/normal/transactional clause then
oralce trigger a checkpoint where oracle makes the control files and
datafiles
consistent to the same checpoint SCN during a database checkpoint.

How Oracle Database will understand what file Needs Restoration and
Recovery ?

For restoration database file oracle ,at startup oracle probe controlfile
(metadata) of yours database ,if it does not find the database file
physically
where it knows then it needs restoration of that concerned database
file.Lets
say you take online backup,if yours database file which is not available
then
restoration comes into play,yours restored file is some time back then
now
yours existence others database file specifiaclly with control
file,controlfile
checkpoint SCN header will be ahead with restored lost database
file,oracle
decide requires recovery.

What the meaning of SCN Synronization,If Database synronize Control


File SCN
number with DBF File SCN then how it will work when we loose Control
File?

Always restoration of controlfile require recovery why..

As i understand it does not apply the redo to data files but an


appearance just
like to apply redo which is not actual (you can also check this
appearance by
restoring controlfile and then make recovery at sql by recover
database until
cancel and then dont apply redo at first attempt and apply cancel),it
does like
that cause old control file which doesn't know where the redo chain
ends ,it
may comes into situation where redo log ahead to old backup control
file this
appearance of recovery make datafile and controlfile consistent by
compeling/forcing open resetlogs.

OR
restored control file which doesn't know where the redo chain ends ,it
may
comes into situation where redo log ahead to old backup control file,
after
restoring controlfile which does not know the current log sequence
number of
redo log ,the existing current redo log sequence number does not
match to
restored controlfile for current log sequence number ,the controlfile
checkpoint scn # would be earlier to datafile checkpoint scn #,this
appearance
of recovery make datafile and controlfile consistent as well restored
controlfile adopt the new resetting log sequence number by
compeling/forcing
open resetlogs.
-------------------------------------------------------------------------------

I can’t understand yet why online backup is inconsistent? I know only a


restored Backup which has
data files SCN header (i.e. CKPT SCN) does not match to control files
SCN header (i.e. CKPT SCN)
considered to be inconsistent backup?

You are right but more or less a backup in which some of the files in
the backup contain changes
that were made after the files were check pointed. This type of backup
needs recovery before it
can be made consistent.

Inconsistent backups are usually created by taking online database


backups; that is the database
is open while the files are being backed up.

RMAN backup at blocks level ,whenever backup start a checkpoint also


triggered say in time "x"
at the same time "x" RMAN started to take blocks backup e.g.
b1,b2,b3.

Say block b1 SCN would be 100 and CKPT SCN at the time "x" of
backup started is 500, there is no
guarantee that block b1 SCN would be same throught the backup
completion. It may be change and at
every change block b1 SCN will be incremented, and at some time
block b1 SCN may go
beyond/greater then CKPT SCN 500, if that’s the case then yours block
b1 backup would be
inconsistent.

Here see a demo

RMAN> backup database


2> ;

Meanwhile backup is going on the other hand i am doing some


actitivity

SQL*Plus: Release 10.1.0.2.0 - Production on Wed Jul 16 14:56:53 2008

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

Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> create table v as select * from all_objects


2 /

Table created.

SQL> create table v1 as select * from all_objects


2 /

Table created.

SQL> create table v2 as select * from all_objects


2 /

Table created.

SQL> create table v3 as select * from all_objects


2 /

Table created.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

Delete alls datafiles here except redo log and control files after
shutting down database..

After that start up database

SQL> startup
ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1:
'C:\ORACLE\PRODUCT\10.1.0\ORADATA\SDS\SYSTEM01.DBF'

What i will do i will restore database files from inconsistent/online/hot


backup.

C:\>rman

Recovery Manager: Release 10.1.0.2.0 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

RMAN> connect target sys/sys@sds

connected to target database: SDS (DBID=2656018210)

RMAN> restore database


2> ;

Starting restore at 16-JUL-08


.
.
.
Finished restore at 16-JUL-08
After restore check yours inconsistent backup would have fuzzy block

SQL> select
checkpoint_change#,absolute_fuzzy_change#,recovery_fuzzy_change
#
2 from v$datafile_copy
3 /

CHECKPOINT_CHANGE# ABSOLUTE_FUZZY_CHANGE#
RECOVERY_FUZZY_CHANGE#
------------------ ---------------------- ----------------------
682999 0 0
682999 0 0
682999 0 0
682999 0 0
684218 0 0
684218 0 0
684218 0 0
684218 0 0
684218 0 0
684218 0 0
684218 0 0

CHECKPOINT_CHANGE# ABSOLUTE_FUZZY_CHANGE#
RECOVERY_FUZZY_CHANGE#
------------------ ---------------------- ----------------------
684218 0 0
816371 0 0
816371 0 0
816371 0 0
816371 816527 0
16 rows selected.

SQL>

If yours any block during backup get higher SCN then checkpoint SCN
it would be considered fuzzy
block which make yours whole database backup inconsistent, oracle
always requires recovery (redo)
in this situation to make inconsistent restored backup to consistent.

As far as concern about yours question that you didn’t do any activity
so there would not be any
absolute fuzzy change number (block SCN > CKTP SCN), you are right
but Oracle will always require
recovery

How it is easy to enable archivelog in 10g

log_archive_start parameter is for enabling automatic archiving in 9i


and "alter
database archivelog" for changing database log mode to archive
mode.

both log_archive_start parameter to TRUE within parameter file and


"alter database
archivelog" command should be executed within 9i box for turning on
the archiving
properly.But in 10g its two in one you can enable archivelog when
yours database in
mount state by executing "alter database archivelog" only.

Here i try to find out how easy to enable archivelog in 10g rather in
9i.First i
will show you how to enable archivelog mode in 9i then i will show you
how easy it
is in 10g.

SQL> select banner from v$version


2 /

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
PL/SQL Release 9.2.0.1.0 - Production
CORE 9.2.0.1.0 Production
TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production

SQL>

SQL> archive log list

Database log mode Archive Mode


Automatic archival Enabled
Archive destination c:\sdsarchive
Oldest online log sequence 18
Next log sequence to archive 20
Current log sequence 20

SQL> show parameter log_archive_start

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
log_archive_start boolean TRUE

The parameter log_archive_start is true within init parameter


file now make it
false and then start database from this parameter file.

*.log_archive_start=FALSE

SQL> shutdown immediate

Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup pfile=c:\initSDS.ora


ORACLE instance started.

Total System Global Area 135338868 bytes


Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.

SQL> archive log list

Database log mode Archive Mode


Automatic archival Disabled
Archive destination c:\sdsarchive
Oldest online log sequence 18
Next log sequence to archive 20
Current log sequence 20
SQL> show parameter log_archive_start

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
log_archive_start boolean FALSE
SQL>

SQL> alter system switch logfile


2 /

System altered.

though "Database log mode" is in "Archive mode" but its "Automatic


archival" is
disabled due to this upon log switching redo log is not getting archived
within
archive destination at c:\sdsarchive ,this automatic archival is enabled
by
log_archive_start parameter to TRUE.

Now change log_archive_start parameter from FALSE to TRUE in the


parameter file and
start database with this parameter file.

SQL> shutdown immediate


Database closed.
Database dismounted.
ORACLE instance shut down.

*.log_archive_start=TRUE

SQL> startup pfile=c:\initSDS.ora


ORACLE instance started.

Total System Global Area 135338868 bytes


Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.

SQL> archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination c:\sdsarchive
Oldest online log sequence 20
Next log sequence to archive 22
Current log sequence 22

SQL> show parameter log_archive_start

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
log_archive_start boolean TRUE

SQL> alter system switch logfile


2 /

System altered.

Now redo log get archived within destination c:\sdsarchive ,

SQL>shutdown immediate
SQL>startup mount
SQL> alter database noarchivelog
2 /

Database altered.

SQL> alter database open


2 /

Database altered.

SQL> archive log list

Database log mode No Archive Mode


Automatic archival Enabled
Archive destination c:\sdsarchive
Oldest online log sequence 21
Current log sequence 23

SQL> alter system switch logfile


2 /
System altered.

SQL> /

System altered.

You will not see any archive file within floder c:\sdsarchive with no
archive mode
but enabling automatic archival by using parameter log_archive_start
to TRUE, either
one of them database log mode to noarchivelog or log_archive_start
set to false will
not let archived the redo logs,both are necessary for enabling the
archive mode
properly in 9i.

But the case is different within 10g ,in 10g log_archive_start is


deprecated if you
set this parameter TRUE within parameter file then at startup you will
get error ORA-
32006.

SQL> conn sys/sys as sysdba


Connected.
SQL> select name from v$database
2 /

NAME
---------
PROD

SQL> select banner from v$version


2 /

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Prod
PL/SQL Release 10.1.0.2.0 - Production
CORE 10.1.0.2.0 Production
TNS for 32-bit Windows: Version 10.1.0.2.0 - Production
NLSRTL Version 10.1.0.2.0 - Production

SQL> startup
pfile=C:\oracle\product\10.1.0\admin\PROD\pfile\init.ora.41220081753
3
ORA-32006: LOG_ARCHIVE_START initialization parameter has
been deprecated
ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.
Database opened.

SQL> archive log list

Database log mode Archive Mode


Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 4
Next log sequence to archive 6
Current log sequence 6
SQL>

log_archive_start has no effect in 10g either you set it TRUE or


FALSE.In 10g you
can turn on archive log mode and automatic archival enabled only with
a single
command in mount mode is "alter database archivelog"

SQL> shutdown immediate


Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount


ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.

SQL> archive log list

Database log mode Archive Mode


Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 14
Next log sequence to archive 16
Current log sequence 16

SQL> alter database noarchivelog


2 /

Database altered.

SQL> archive log list

Database log mode No Archive Mode


Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 14
Current log sequence 16

SQL> alter database archivelog


2 /

Database altered.

SQL> archive log list

Database log mode Archive Mode


Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 14
Next log sequence to archive 16
Current log sequence 16
SQL>

Recovery with an old controlfile/recover database using


backup controlfile
Question :
I have a full backup wıth control file and archıvelogs which is taken by rman
yesterday.Today my db ıs crashed at the evenıng and control fıle ıs corrupted. When I
restore yesterdays controlfıle from backupset,and restore all yesterday's datafiles,can I
apply todays archivelogs and apply to these datafiles? Do I lose any data in this
scenerio?
Answer :
When you take online/hot backup then yours backup is inconsistent , upon recovery
oracle makes inconsistent backups consistent by applying all archived and online redo
logs ,oracle makes recovery by reading the earliest/oldest SCN in any of the datafile
headers and apply the changes from the logs back into the datafile. yes indeed controlfile
has repositry about alls backup stuff like database backup as well archivelog backup.If
you take backup of archivelog then it goes to control file entry ,upon restoration activity
oracle reads the controlfile to ask where archivelog exist to be restored.If yours todays
archivelogs are on disk not in controlfile repositry then oracle will apply these todays
archivelog regardless controlfile knows or not,If the RMAN repository or controlfile
indicates that no copies of a needed log sequence number exist on disk, then RMAN
looks in backups and restores archived redo logs as needed to perform the media
recovery,there is no concern controlfile for applying archivelogs at all,if you have todays
archivelogs exist then you will lose data only which is in current redo log thats why
multiplexing redo log came into ours dbackup plan.
Question :
but control file is older it doesnt store the info of new archivelogs.How can I add?
Answer :
Contorolfile older issue raise when you have controlfile for yesterday and datafile for
today,if you restore yesterdays controlfle and restore the datafile from this yesterday
controlfile and then started recovery to this yesterday controlfile then there would be no
any issue to recover the database till before crash using todays archivelogs.Here you have
to remember one thing you will lose only data for current redo log ,if you have redo log
keep intact by multiplexing then you can recover this multiplexed current redo log data
also. If yesterdays controlfile dont know todays database physical activity i.e adding
datafile then archivelog data for this todays datafile applying will raise the error during
recovery. Here i am going to prove that yesterdays controlfile will not be an issue for
tracking the todays archivelog during recovery process and it will apply safely.
SQL> select sysdate from dual
2 /

SYSDATE
---------
19-APR-08

SQL> create table a as select * from all_objects


2 /

Table created.

SQL> create table b as select * from all_objects


2 /

Table created.

SQL> create table c as select * from all_objects


2 /
Table created.

SQL> create table d as select * from all_objects


2 /

Table created.

C:\oracle\product\10.1.0\flash_recovery_area\ORCL1\ARCHIVELOG\200
8_04_19>dir
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of
C:\oracle\product\10.1.0\flash_recovery_area\ORCL1\ARCHIVELOG\200
8
_04_19

04/19/2008 02:37 PM <DIR> .


04/19/2008 02:37 PM <DIR> ..
04/19/2008 02:36 PM 9,754,112 O1_MF_1_7_40MH8FC9_.ARC
04/19/2008 02:37 PM 9,753,088 O1_MF_1_8_40MHCDZ4_.ARC
2 File(s) 19,507,200 bytes
2 Dir(s) 58,626,342,912 bytes free

RMAN> run
2> {
3> allocate channel t1 type disk;
4> backup database;
5> release channel t1;
6> allocate channel t2 type disk;
7> backup archivelog all;
8> release channel t2;
9> }

released channel: ORA_DISK_1


allocated channel: t1
channel t1: sid=125 devtype=DISK

Starting backup at 19-APR-08


channel t1: starting full datafile backupset
channel t1: specifying datafile(s) in backupset
input datafile fno=00001
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\SYSTEM01.DBF
input datafile fno=00003
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\SYSAUX01.DBF
input datafile fno=00004
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\USERS01.DBF
input datafile fno=00002
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\UNDOTBS01.DBF
channel t1: starting piece 1 at 19-APR-08
channel t1: finished piece 1 at 19-APR-08
piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\B
ACKUPSET\2008_04_19\O1_MF_NNNDF_TAG20080419T144156_40MHM
B71_.BKP comment=NONE
channel t1: backup set complete, elapsed time: 00:01:56
Finished backup at 19-APR-08

Starting Control File and SPFILE Autobackup at 19-APR-08


piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\A
UTOBACKUP\2008_04_19\O1_MF_S_652459435_40MHPXCT_.BKP
comment=NONE
Finished Control File and SPFILE Autobackup at 19-APR-08

released channel: t1

allocated channel: t2
channel t2: sid=125 devtype=DISK

Starting backup at 19-APR-08


current log archived
channel t2: starting archive log backupset
channel t2: specifying archive log(s) in backup set
input archive log thread=1 sequence=7 recid=102 stamp=652458975
input archive log thread=1 sequence=8 recid=103 stamp=652459070
input archive log thread=1 sequence=9 recid=104 stamp=652459454
channel t2: starting piece 1 at 19-APR-08
channel t2: finished piece 1 at 19-APR-08
piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\B
ACKUPSET\2008_04_19\O1_MF_ANNNN_TAG20080419T144414_40MHQ
JNO_.BKP comment=NONE
channel t2: backup set complete, elapsed time: 00:00:08
Finished backup at 19-APR-08

Starting Control File and SPFILE Autobackup at 19-APR-08


piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\A
UTOBACKUP\2008_04_19\O1_MF_S_652459464_40MHQT1N_.BKP
comment=NONE
Finished Control File and SPFILE Autobackup at 19-APR-08

released channel: t2

SQL> conn sys/sys@orcl1 as sysdba


Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

C:\oracle\product\10.1.0\flash_recovery_area\ORCL1\ARCHIVELOG\200
8_04_19>dir
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of
C:\oracle\product\10.1.0\flash_recovery_area\ORCL1\ARCHIVELOG\200
8
_04_19

04/19/2008 02:44 PM <DIR> .


04/19/2008 02:44 PM <DIR> ..
04/19/2008 02:36 PM 9,754,112 O1_MF_1_7_40MH8FC9_.ARC
04/19/2008 02:37 PM 9,753,088 O1_MF_1_8_40MHCDZ4_.ARC
04/19/2008 02:44 PM 2,507,776 O1_MF_1_9_40MHQFYX_.ARC
3 File(s) 22,014,976 bytes
2 Dir(s) 58,033,848,320 bytes free

SQL> conn sys/sys@orcl1 as sysdba


Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

---------------------------------------------------------------------
change the server date from 19-APR-2008 to 20-APR-2008
---------------------------------------------------------------------

SQL> startup
ORACLE instance started.
Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.
Database opened.
SQL> select sysdate from dual
2 /

SYSDATE
---------
20-APR-08

SQL> conn scott/tiger@orcl1


Connected.
SQL> create table e as select * from all_objects
2 /

Table created.

SQL> create table f as select * from all_objects


2 /

Table created.

SQL> create table g as select * from all_objects


2 /

Table created.

SQL> create table h as select * from all_objects


2 /

Table created.

C:\oracle\product\10.1.0\flash_recovery_area\ORCL1\ARCHIVELOG\200
8_04_20>dir
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of
C:\oracle\product\10.1.0\flash_recovery_area\ORCL1\ARCHIVELOG\200
8
_04_20
04/20/2008 02:53 PM <DIR> .
04/20/2008 02:53 PM <DIR> ..
04/20/2008 02:51 PM 9,756,160 O1_MF_1_10_40P4KWQ8_.ARC
04/20/2008 02:52 PM 9,751,552 O1_MF_1_11_40P4MH79_.ARC
04/20/2008 02:53 PM 9,750,016 O1_MF_1_12_40P4NK9V_.ARC
3 File(s) 29,257,728 bytes
2 Dir(s) 57,978,466,304 bytes free

SQL> conn sys/sys@orcl1 as sysdba


Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

C:\oracle\product\10.1.0\oradata\orcl1>dir
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of C:\oracle\product\10.1.0\oradata\orcl1

04/18/2008 06:31 PM <DIR> .


04/18/2008 06:31 PM <DIR> ..
04/20/2008 02:55 PM 2,965,504 CONTROL01.CTL
04/20/2008 02:55 PM 2,965,504 CONTROL02.CTL
04/20/2008 02:55 PM 2,965,504 CONTROL03.CTL
04/20/2008 02:55 PM 10,486,272 REDO01.LOG
04/20/2008 02:55 PM 10,486,272 REDO02.LOG
04/20/2008 02:55 PM 10,486,272 REDO03.LOG
04/20/2008 02:55 PM 251,666,432 SYSAUX01.DBF
04/20/2008 02:55 PM 461,381,632 SYSTEM01.DBF
04/20/2008 02:55 PM 26,222,592 UNDOTBS01.DBF
04/20/2008 02:55 PM 53,747,712 USERS01.DBF
10 File(s) 833,373,696 bytes
2 Dir(s) 57,978,585,088 bytes free

----------------------------------------------------------------------------
Delete alls database files
----------------------------------------------------------------------------

C:\oracle\product\10.1.0\oradata\orcl1>del *.*
C:\oracle\product\10.1.0\oradata\orcl1\*.*, Are you sure (Y/N)? Y

C:\oracle\product\10.1.0\oradata\orcl1>dir
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of C:\oracle\product\10.1.0\oradata\orcl1

04/20/2008 02:56 PM <DIR> .


04/20/2008 02:56 PM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 58,811,949,056 bytes free

C:\oracle\product\10.1.0\oradata\orcl1>

SQL> startup
ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
ORA-00205: error in identifying controlfile, check alert log for more info

C:\>rman

Recovery Manager: Release 10.1.0.2.0 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

RMAN> connect target sys/sys@orcl1

connected to target database: orcl1 (not mounted)

RMAN> restore controlfile from autobackup


2> ;

Starting restore at 20-APR-08


using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK

recovery area destination:


C:\oracle\product\10.1.0\flash_recovery_area
database name (or lock name space) used for search: ORCL1
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found:
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\AUTOBAC
KUP\2008_04_19\O1_MF_S_652459464_40MHQT1N_.BKP
channel ORA_DISK_1: controlfile restore from autobackup complete
output
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\CONTROL01.C
TL
output
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\CONTROL02.C
TL
output
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\CONTROL03.C
TL
Finished restore at 20-APR-08

RMAN> startup mount

database is already started


database mounted

RMAN> restore database


2> ;

ORACLE error from target database:


ORA-19922: there is no parent row with id 0 and level 0
ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 5038
ORA-06512: at line 1

RMAN-06900: WARNING: unable to generate V$RMAN_STATUS or


V$RMAN_OUTPUT row
RMAN-06901: WARNING: disabling update of the V$RMAN_STATUS and
V$RMAN_OUTPUT rows
Starting restore at 20-APR-08
Starting implicit crosscheck backup at 20-APR-08
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 20-APR-08

Starting implicit crosscheck copy at 20-APR-08


using channel ORA_DISK_1
Finished implicit crosscheck copy at 20-APR-08

searching for all files in the recovery area


cataloging files...
cataloging done

List of Cataloged Files


=======================
File Name:
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\ARCHIVEL
OG\2008_04_20\O1_MF_1_10_40P4KWQ8_.ARC
File Name:
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\ARCHIVEL
OG\2008_04_20\O1_MF_1_11_40P4MH79_.ARC
File Name:
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\ARCHIVEL
OG\2008_04_20\O1_MF_1_12_40P4NK9V_.ARC
File Name:
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\AUTOBAC
KUP\2008_04_19\O1_MF_S_652459464_40MHQT1N_.BKP

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
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\SYSTEM01.DBF
restoring datafile 00002 to
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\UNDOTBS01.DBF
restoring datafile 00003 to
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\SYSAUX01.DBF
restoring datafile 00004 to
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\USERS01.DBF
channel ORA_DISK_1: restored backup piece 1
piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\B
ACKUPSET\2008_04_19\O1_MF_NNNDF_TAG20080419T144156_40MHM
B71_.BKP tag=TAG20080419T144156
channel ORA_DISK_1: restore complete
Finished restore at 20-APR-08

RMAN> recover database


2> ;

Starting recover at 20-APR-08


using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 9 is already on disk as file


C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\ARCHIVEL
OG\2008_04_19\O1_MF_1_9_40MHQFYX_.ARC
archive log thread 1 sequence 10 is already on disk as file
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\ARCHIVEL
OG\2008_04_20\O1_MF_1_10_40P4KWQ8_.ARC
archive log thread 1 sequence 11 is already on disk as file
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\ARCHIVEL
OG\2008_04_20\O1_MF_1_11_40P4MH79_.ARC
archive log thread 1 sequence 12 is already on disk as file
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\ARCHIVEL
OG\2008_04_20\O1_MF_1_12_40P4NK9V_.ARC
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1
\ARCHIVELOG\2008_04_19\O1_MF_1_9_40MHQFYX_.ARC thread=1
sequence=9
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1
\ARCHIVELOG\2008_04_20\O1_MF_1_10_40P4KWQ8_.ARC thread=1
sequence=10
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1
\ARCHIVELOG\2008_04_20\O1_MF_1_11_40P4MH79_.ARC thread=1
sequence=11
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1
\ARCHIVELOG\2008_04_20\O1_MF_1_12_40P4NK9V_.ARC thread=1
sequence=12
unable to find archive log
archive log thread=1 sequence=13
RMAN-00571:
==========================================
=================
RMAN-00569: =============== ERROR MESSAGE STACK
FOLLOWS ===============
RMAN-00571:
==========================================
=================
RMAN-03002: failure of recover command at 04/20/2008 15:01:51
RMAN-06054: media recovery requesting unknown log: thread 1 seq 13
lowscn 698325

RMAN> report obsolete


2> ;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 142 19-APR-08
Backup Piece 142 19-APR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\AUTOBAC
KUP\2008_04_19\O1_MF_S_652459435_40MHPXCT_.BKP
Archive Log 102 19-APR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\ARCHIVEL
OG\2008_04_19\O1_MF_1_7_40MH8FC9_.ARC
Archive Log 103 19-APR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\ARCHIVEL
OG\2008_04_19\O1_MF_1_8_40MHCDZ4_.ARC

RMAN> alter database open resetlogs


2> ;

database opened

RMAN>

As you can see i have redundency 1 thats why at recovery these


archivelogs are not
getting applied,nevertheless these 19th April archivlogs are no more
required to
apply logs but as you can see 20th april logs are being applied.

when i connect to sql i got alls table a,b,c,d,e,f,g but not h cause h
data was in
redolog and was not archived before smoking alls database files.

SQL> conn scott/tiger@orcl1


Connected.
SQL> desc a
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)

SQL> desc b
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)

SQL> desc c
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)

SQL> desc d
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)

SQL> desc e
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)

SQL> desc f
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)

SQL> desc g
Name Null? Type
----------------------------------------- -------- ----------------------------
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)

SQL> desc h
ERROR:
ORA-04043: object h does not exist

You can see table a,b,c,d recoverd which is for 19th April data and e,f,g
recoverd
cause 20th April archivelogs applied to 19th April backupset with 19th
April
controlfile.

Question :

But as i have old controlfile then whats the use of recover


database using backup
controlfile as i know recover database using backup controlfile
is used when you
have old controlfile.

Answer :

Yes you are right but you are missing obvious that using old
controlfile recovery by
using recover database using backup controlfile command is
used when you have old
controlfile and datafiles are current.Lets see a scenario which
will depictyou a
clear picture when to use recover database using backup
controlfile.

Lets suppose i am taking cold backup daily ,my procedure is to


shutdown the database
and then copy alls database file to somewhere safe daily at
the end of day ,one day
i lost/corrupt the controlfile, i dont have current controlfile i
have only
controlfile backup which is backed up as cold last day.In this
case i have two
options either i create the controlfile by using the create
controlfile command then
perform recovery if required and start up the database.Other
option is to restore
the last cold backed up controlfile and recover database using
backup controlfile.

If you try to recover database without using backup controlfile


command then you
will get the error.

ORA-01122: database file 1 failed verification check


ORA-01110: data file 1:
'C:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSTEM01.DBF'
ORA-01207: file is more recent than controlfile - old controlfile

ORA-1122: database file 1 failed verification check

Cause: The information in this file (system01.dbf) is inconsistent with


information from the control file.

Action: Make sure that the db files and control files are the correct
files for this database.

ORA-1207 file is more recent than control file - old control file

Cause: The control file change sequence number in the data file is
greater than the number in the control file. This
implies that the wrong control file is being used. Note that
repeatedly causing this error can make it stop
happening without correcting the real problem. Every attempt
to open the database will advance the control
file change sequence number until it is great enough.

Action: Use the current control file or do backup controlfile recovery


to make the control file current. Be sure to
follow all restrictions on doing a backup controlfile recovery.

SQL> conn sys/sys as sysdba


Connected.

SQL> archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 4
Next log sequence to archive 6
Current log sequence 6

SQL> select group#,members,status


2 from v$log
3 /

GROUP# MEMBERS STATUS


---------- ---------- ----------------
1 1 CURRENT
2 1 UNUSED
3 1 UNUSED

SQL>

SQL> conn scott/tiger


Connected.
SQL> create table x1 as select * from all_objects
2 /

Table created.

SQL> create table x2 as select * from all_objects


2 /

Table created.

SQL> conn sys/sys as sysdba


Connected.

SQL> alter system switch logfile


2 /

System altered.

SQL> select group#,members,status


2 from v$log
3 /

GROUP# MEMBERS STATUS


---------- ---------- ----------------
1 1 ACTIVE
2 1 CURRENT
3 1 UNUSED

SQL> shutdown immediate


Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

Copy the database folder to somewhere safe place

C:\oracle\product\10.1.0\oradata>copy prod coldbackup


prod\CONTROL01.CTL
prod\CONTROL02.CTL
prod\CONTROL03.CTL
prod\REDO01.LOG
prod\REDO02.LOG
prod\REDO03.LOG
prod\SYSAUX01.DBF
prod\SYSTEM01.DBF
prod\TEMP01.DBF
prod\UNDOTBS01.DBF
prod\USERS01.DBF
11 file(s) copied.

C:\oracle\product\10.1.0\oradata>

Now startup the database.

SQL> startup
ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.
Database opened.

You have taken cold backup, now perform some activity

SQL> select group#,members,status


2 from v$log
3 /

GROUP# MEMBERS STATUS


---------- ---------- ----------------
1 1 INACTIVE
2 1 CURRENT
3 1 UNUSED

SQL> conn scott/tiger


Connected.
SQL>
SQL> create table x3 as select * from all_objects
2 /

Table created.

SQL> alter system switch logfile


2 /

System altered.

SQL> select group#,members,status


2 from v$log
3 /

GROUP# MEMBERS STATUS


---------- ---------- ----------------
1 1 INACTIVE
2 1 ACTIVE
3 1 CURRENT

Now delete or corrupt the controlfile ,i am deleting here alls


controlfile here

SQL> shutdown immediate


Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

C:\oracle\product\10.1.0\oradata\Prod>del *.ctl

C:\oracle\product\10.1.0\oradata\Prod>dir *.ctl
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of C:\oracle\product\10.1.0\oradata\Prod

File Not Found

Now startup the database

SQL> startup
ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
ORA-00205: error in identifying controlfile, check alert log for more info

SQL> shutdown abort


ORACLE instance shut down.
SQL>

Copy the controlfile from coldbackup to yours Prod database


file folder.
C:\oracle\product\10.1.0\oradata>copy
c:\oracle\product\10.1.0\oradata\coldbackup\*.ctl
C:\oracle\product\10.1.0\oradata\prod
c:\oracle\product\10.1.0\oradata\coldbackup\CONTROL01.CTL
c:\oracle\product\10.1.0\oradata\coldbackup\CONTROL02.CTL
c:\oracle\product\10.1.0\oradata\coldbackup\CONTROL03.CTL
3 file(s) copied.

C:\oracle\product\10.1.0\oradata>

Now the controlfiles from cold backup to prod folder copied


succesfully ,start the database

SQL> startup
ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1:
'C:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSTEM01.DBF'
ORA-01207: file is more recent than controlfile - old controlfile

SQL> recover database

ORA-00283: recovery session canceled due to errors


ORA-01122: database file 1 failed verification check
ORA-01110: data file 1:
'C:\ORACLE\PRODUCT\10.1.0\ORADATA\PROD\SYSTEM01.DBF'
ORA-01207: file is more recent than controlfile - old controlfile

SQL> recover database using backup controlfile until cancel

ORA-00279: change 333130 generated at 05/10/2008 16:42:05 needed


for thread 1
ORA-00289: suggestion :
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\PROD\ARCHIVEL
OG\2008_05_10\O1_MF_1_2_%U_.ARC
ORA-00280: change 333130 for thread 1 is in sequence #2

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

ORA-00279: change 334273 generated at 05/10/2008 16:48:51 needed


for thread 1
ORA-00289: suggestion :
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\PROD\ARCHIVEL
OG\2008_05_10\O1_MF_1_3_%U_.ARC
ORA-00280: change 334273 for thread 1 is in sequence #3
ORA-00278: log file
'C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\PROD\ARCHIVEL
OG\2008_05_10\O1_MF_1_2_42C2X57F_.ARC' no longer needed for this
recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}


C:\oracle\product\10.1.0\oradata\Prod\REDO03.log
Log applied.
Media recovery complete.

SQL> alter database open resetlogs


2 /

Database altered.

Question :

But You showed me up without any new added datafile with


old controlfile recovery
and yours scenario with cold backup ,my case is hot backup
and i have new datafile
but old controlfile backup ,i lost old control file but datafiles
exist on disk
presumably some data files are added in database file before
losing controlfile and
old controlfile does not know about it how will i make recovery
in this scenario

Answer :

The process would be the same in yours scenario as i


mentioned above, you will have
to make recovery with "recover database using backup
controlfile" when you have old
controlfile and new datafiles.Lets see here

Recovery Manager: Release 10.1.0.2.0 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

RMAN> connect target sys/sys@uat

connected to target database: UAT (DBID=2679299118)

RMAN> list backup of controlfile


2> ;

using target database controlfile instead of recovery catalog

List of Backup Sets


===================

BS Key Type LV Size Device Type Elapsed Time Completion Time


------- ---- -- ---------- ----------- ------------ ---------------
8 Full 2M DISK 00:00:03 16-MAY-08
BP Key: 8 Status: AVAILABLE Compressed: NO Tag:
TAG20080516T002026
Piece Name:
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\BACKUPSET\
2008_05_16\O1_MF_NCSNF_TAG20080516T002026_42S3B7SW_.BKP
Controlfile Included: Ckp SCN: 408253 Ckp time: 16-MAY-08

SQL> conn sys/sys@uat as sysdba


Connected.

SQL> select ts#,name


2 from v$tablespace
3 /

TS# NAME
---------- ------------------------------
0 SYSTEM
1 UNDOTBS1
2 SYSAUX
4 USERS
3 TEMP

SQL> select ts#,file#,substr(name,1,50) name,status,enabled


2 from v$datafile
3 /

TS# FILE# NAME STATUS


ENABLED
---------- ---------- -------------------------------------------------- ------- ----------
0 1
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSTEM01.DBF SYSTEM
READ WRITE
1 2
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\UNDOTBS01.DBF ONLINE
READ WRITE
2 3
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSAUX01.DBF ONLINE
READ WRITE
4 4
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\USERS01.DBF ONLINE
READ WRITE

SQL> create tablespace newtablespace datafile


'C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\newdatafile01.dbf' size
100M
2 /

Tablespace created.

make sure added tablespace datafile is online and enabled for


read and write.

SQL> select ts#,name


2 from v$tablespace
3 /
TS# NAME
---------- ------------------------------
0 SYSTEM
1 UNDOTBS1
2 SYSAUX
4 USERS
3 TEMP
6 NEWTABLESPACE

6 rows selected.

SQL>
SQL> select ts#,file#,substr(name,1,50) name,status,enabled
2 from v$datafile
3 /

TS# FILE# NAME STATUS


ENABLED
---------- ---------- -------------------------------------------------- ------- ----------
0 1
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSTEM01.DBF SYSTEM
READ WRITE
1 2
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\UNDOTBS01.DBF ONLINE
READ WRITE
2 3
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSAUX01.DBF ONLINE
READ WRITE
4 4
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\USERS01.DBF ONLINE
READ WRITE
6 5
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\NEWDATAFILE01 ONLINE
READ WRITE

make default this newtablespace for the user scott

SQL> alter user scott default tablespace newtablespace


2 /

User altered.
SQL> conn scott/tiger@uat
Connected.
SQL> create table v1 as select * from all_objects
2 /

Table created.

SQL> create table v2 as select * from all_objects


2 /

Table created.

SQL> conn sys/sys@uat as sysdba


Connected.
SQL> alter system switch logfile
2 /

System altered.

SQL> shutdown immediate


Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

Here i drop the controld files

C:\oracle\product\10.1.0\oradata\uat>dir *.ctl
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of C:\oracle\product\10.1.0\oradata\uat

05/26/2008 02:10 PM 2,899,968 CONTROL01.CTL


05/26/2008 02:10 PM 2,899,968 CONTROL02.CTL
05/26/2008 02:10 PM 2,899,968 CONTROL03.CTL
3 File(s) 8,699,904 bytes
0 Dir(s) 43,394,301,952 bytes free

C:\oracle\product\10.1.0\oradata\uat>del *.ctl

C:\oracle\product\10.1.0\oradata\uat>dir *.ctl
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of C:\oracle\product\10.1.0\oradata\uat
File Not Found

C:\>rman

Recovery Manager: Release 10.1.0.2.0 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

RMAN> connect target sys/sys@uat

connected to target database (not started)

RMAN> startup

Oracle instance started


RMAN-00571:
==========================================
=================
RMAN-00569: =============== ERROR MESSAGE STACK
FOLLOWS ===============
RMAN-00571:
==========================================
=================
RMAN-03002: failure of startup command at 05/26/2008 14:18:02
ORA-00205: error in identifying controlfile, check alert log for more info

RMAN> restore controlfile from


'C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT
\
BACKUPSET\2008_05_16\O1_MF_NCSNF_TAG20080516T002026_42S3B
7SW_.BKP'
2> ;

Starting restore at 26-MAY-08


using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=160 devtype=DISK

channel ORA_DISK_1: restoring controlfile


channel ORA_DISK_1: restore complete
output
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\CONTROL01.CTL
output
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\CONTROL02.CTL
output
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\CONTROL03.CTL
Finished restore at 26-MAY-08

RMAN>

you can see the controlfile restored for the date of 16th
May,2008 and datafile are
for today dated 26th May ,2008 and one of datafile named
newdatafile01.dbf has been
added today dated 26th MAy,2008,above restored controlfile
doesnt aware about new
added data file newdatafile01.dbf which exist on disk.

C:\oracle\product\10.1.0\oradata\uat>dir *.dbf
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of C:\oracle\product\10.1.0\oradata\uat

05/26/2008 02:10 PM 104,865,792 NEWDATAFILE01.DBF


05/26/2008 02:10 PM 262,152,192 SYSAUX01.DBF
05/26/2008 02:10 PM 461,381,632 SYSTEM01.DBF
05/25/2008 09:42 AM 20,979,712 TEMP01.DBF
05/26/2008 02:10 PM 26,222,592 UNDOTBS01.DBF
05/26/2008 02:10 PM 5,251,072 USERS01.DBF
6 File(s) 880,852,992 bytes
0 Dir(s) 43,392,053,248 bytes free

C:\oracle\product\10.1.0\oradata\uat>

RMAN> startup mount

database is already started


database mounted

RMAN>

SQL> select * from v$recover_file


2 /

no rows selected

now you have new old controlfile and new datafiles do


RMAN>recover database

RMAN-00571:
==========================================
=================
RMAN-00569: =============== ERROR MESSAGE STACK
FOLLOWS ===============
RMAN-00571:
==========================================
=================
RMAN-03002: failure of recover command at 05/26/2008 14:43:26
ORA-01119: error in creating database file
'C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT
\NEWDATAFILE01.DBF'
ORA-27038: created file already exists
OSD-04010: option specified, file already exists

SQL> recover database


ORA-01153: an incompatible media recovery is active

an incompatible media recovery is active cause


newdatafile01.dbf does not known by old controlfile.

SQL> shutdown immediate


ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.
SQL> recover database
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be
done
SQL> recover database using backup controlfile
ORA-00283: recovery session canceled due to errors
ORA-01111: name for data file 5 is unknown - rename to correct file
ORA-01110: data file 5: 'C:\WINDOWS\SYSTEM32\UNNAMED00005'
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01111: name for data file 5 is unknown - rename to correct file
ORA-01110: data file 5: 'C:\WINDOWS\SYSTEM32\UNNAMED00005'

SQL> conn sys/sys@uat as sysdba


Connected.
SQL> recover database
ORA-01153: an incompatible media recovery is active

SQL> shutdown immediate


ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.

SQL> recover database


ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be
done

SQL> recover database using backup controlfile


ORA-00283: recovery session canceled due to errors
ORA-01111: name for data file 5 is unknown - rename to correct file
ORA-01110: data file 5: 'C:\WINDOWS\SYSTEM32\UNNAMED00005'
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01111: name for data file 5 is unknown - rename to correct file
ORA-01110: data file 5: 'C:\WINDOWS\SYSTEM32\UNNAMED00005'
You can also check the name of datafile unnamed00005 from
alert log file

Mon May 26 14:43:23 2008


alter database recover logfile
'C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_71_43NXG29C_.ARC'
Media Recovery Log
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_71_43NXG29C_.ARC
File #5 added to control file as 'UNNAMED00005'. Originally created as:
'C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\NEWDATAFILE01.DBF'
Errors with log
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_71_43NXG29C_.ARC

SQL> select ts#,file#,substr(name,1,55) name,status,enabled


2 from v$datafile
3 /

TS# FILE# NAME STATUS ENABLED


---- ------ ------------------------------------------------- ------- ---------
0 1 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSTEM01.DBF
SYSTEM READ WRITE
1 2 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\UNDOTBS01.DBF
ONLINE READ WRITE
2 3 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSAUX01.DBF
ONLINE READ WRITE
4 4 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\USERS01.DBF
ONLINE READ WRITE
6 5
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\NEWDATAFILE01.DBF
RECOVER READ WRITE

SQL> alter database rename file


'C:\WINDOWS\SYSTEM32\UNNAMED00005'
to
'C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\NEWDATAFILE01.DBF'
2 /

Database altered.

SQL> select ts#,file#,substr(name,1,55) name,status,enabled


2 from v$datafile
3 /
TS# FILE# NAME STATUS ENABLED
--- ----- ------------------------------------------------------ ------ ---------
0 1 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSTEM01.DBF
SYSTEM READ WRITE
1 2 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\UNDOTBS01.DBF
ONLINE READ WRITE
2 3 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSAUX01.DBF
ONLINE READ WRITE
4 4 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\USERS01.DBF
ONLINE READ WRITE
6 5 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\NEWDATAFILE01.DBF
RECOVER READ WRITE

Try to recover the datafile at RMAN as well sqlplus

C:\>rman

Recovery Manager: Release 10.1.0.2.0 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

RMAN> connect target sys/sys@uat

connected to target database: UAT (DBID=2679299118)

RMAN> recover datafile 5


2> ;

Starting recover at 26-MAY-08


using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK

RMAN-00571:
==========================================
=================
RMAN-00569: =============== ERROR MESSAGE STACK
FOLLOWS ===============
RMAN-00571:
==========================================
=================
RMAN-03002: failure of recover command at 05/26/2008 15:12:30
RMAN-06067: RECOVER DATABASE required with a backup or created
controlfile

SQL> recover datafile 5


ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be
done

As you can see the recovery should be done by using recover


database using backup controlfile.

SQL> shutdown immediate


ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.

SQL> startup mount


ORACLE instance started.

Total System Global Area 171966464 bytes


Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.

SQL> select group#,status


2 from v$log
3 /

GROUP# STATUS
---------- ----------------
1 INACTIVE
2 INACTIVE
3 CURRENT

SQL> recover database using backup controlfile


ORA-00279: change 1011489 generated at 05/26/2008 12:51:02
needed for thread 1
ORA-00289: suggestion :
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_71_%U_.ARC
ORA-00280: change 1011489 for thread 1 is in sequence #71

Specify log: {=suggested | filename | AUTO | CANCEL}

ORA-00279: change 1014306 generated at 05/26/2008 13:33:06


needed for thread 1
ORA-00289: suggestion :
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_72_%U_.ARC
ORA-00280: change 1014306 for thread 1 is in sequence #72
ORA-00278: log file
'C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_71_43NXG29C_.ARC' no longer needed for this
recovery

Specify log: {=suggested | filename | AUTO | CANCEL}

ORA-00279: change 1016418 generated at 05/26/2008 14:00:33


needed for thread 1
ORA-00289: suggestion :
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_73_%U_.ARC
ORA-00280: change 1016418 for thread 1 is in sequence #73
ORA-00278: log file
'C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_72_43NZ1NQ7_.ARC' no longer needed for this
recovery

Specify log: {=suggested | filename | AUTO | CANCEL}

ORA-00279: change 1017543 generated at 05/26/2008 14:08:47


needed for thread 1
ORA-00289: suggestion :
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_74_%U_.ARC
ORA-00280: change 1017543 for thread 1 is in sequence #74
ORA-00278: log file
'C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_73_43NZJZG7_.ARC' no longer needed for this
recovery

Specify log: {=suggested | filename | AUTO | CANCEL}


ORA-00279: change 1017771 generated at 05/26/2008 14:09:55
needed for thread 1
ORA-00289: suggestion :
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_75_%U_.ARC
ORA-00280: change 1017771 for thread 1 is in sequence #75
ORA-00278: log file
'C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_74_43NZM4B6_.ARC' no longer needed for this
recovery

Specify log: {=suggested | filename | AUTO | CANCEL}

ORA-00308: cannot open archived log


'C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_75_%U_.ARC'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.

Do recovery again at this time dont specify to apply the log at


O1_MF_1_75_%U_.ARC ,only apply alls redo log file instead
applying O1_MF_1_75_%U_.ARC.

SQL> recover database using backup controlfile


ORA-00279: change 1017771 generated at 05/26/2008 14:09:55
needed for thread 1
ORA-00289: suggestion :
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_75_%U_.ARC
ORA-00280: change 1017771 for thread 1 is in sequence #75

Specify log: {=suggested | filename | AUTO | CANCEL}

C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\REDO03.log<---------
------------------

ORA-00310: archived log contains sequence 73; sequence 75 required


ORA-00334: archived log:
'C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\REDO03.LOG'
SQL> select ts#,file#,substr(name,1,55) name,status,enabled
2 from v$datafile
3 /

TS# FILE# NAME STATUS ENABLED


---- ----- -------------------------------------------------- ------- --------
0 1 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSTEM01.DBF
SYSTEM READ WRITE
1 2 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\UNDOTBS01.DBF
ONLINE READ WRITE
2 3 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSAUX01.DBF
ONLINE READ WRITE
4 4 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\USERS01.DBF
ONLINE READ WRITE
6 5
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\NEWDATAFILE01.DBF
RECOVER READ WRITE

now use redo01.log file

SQL> recover database using backup controlfile


ORA-00279: change 1017771 generated at 05/26/2008 14:09:55
needed for thread 1
ORA-00289: suggestion :
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_75_%U_.ARC
ORA-00280: change 1017771 for thread 1 is in sequence #75

Specify log: {=suggested | filename | AUTO | CANCEL}

C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\REDO01.LOG<--------
-------------------

ORA-00310: archived log contains sequence 74; sequence 75 required


ORA-00334: archived log:
'C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\REDO01.LOG'

SQL> select ts#,file#,substr(name,1,55) name,status,enabled


2 from v$datafile
3 /

TS# FILE# NAME STATUS ENABLED


--- ------ ------------------------------------------------------- ------- --------
0 1 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSTEM01.DBF
SYSTEM READ WRITE
1 2 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\UNDOTBS01.DBF
ONLINE READ WRITE
2 3 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSAUX01.DBF
ONLINE READ WRITE
4 4 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\USERS01.DBF
ONLINE READ WRITE
6 5
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\NEWDATAFILE01.DBF
RECOVER READ WRITE

now use redo02.log file

SQL> recover database using backup controlfile


ORA-00279: change 1017771 generated at 05/26/2008 14:09:55
needed for thread 1
ORA-00289: suggestion :
C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\UAT\ARCHIVELO
G\2008_05_26\O1_MF_1_75_%U_.ARC
ORA-00280: change 1017771 for thread 1 is in sequence #75

Specify log: {=suggested | filename | AUTO | CANCEL}

C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\REDO02.LOG<--------
----------

Log applied.
Media recovery complete.

SQL> select ts#,file#,substr(name,1,55) name,status,enabled


2 from v$datafile
3 /

TS# FILE# NAME STATUS ENABLED


--- ----- ---------------------------------------------------- ------- ----------
0 1 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSTEM01.DBF
SYSTEM READ WRITE
1 2 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\UNDOTBS01.DBF
ONLINE READ WRITE
2 3 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSAUX01.DBF
ONLINE READ WRITE
4 4 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\USERS01.DBF
ONLINE READ WRITE
6 5
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\NEWDATAFILE01.DBF
ONLINE READ WRITE

SQL> alter database open resetlogs


2 /

Database altered.

SQL> select ts#,file#,substr(name,1,55) name,status,enabled


2 from v$datafile
3 /

TS# FILE# NAME STATUS ENABLED


---- ----- ------------------------------------------------------- ------- ---------
0 1 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSTEM01.DBF
SYSTEM READ WRITE
1 2 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\UNDOTBS01.DBF
ONLINE READ WRITE
2 3 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSAUX01.DBF
ONLINE READ WRITE
4 4 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\USERS01.DBF
ONLINE READ WRITE
6 5
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\NEWDATAFILE01.DBF
ONLINE READ WRITE

SQL> alter database open resetlogs


2 /

Database altered.

SQL> select ts#,file#,substr(name,1,55) name,status,enabled


2 from v$datafile
3 /

TS# FILE# NAME STATUS ENABLED


--- ----- -------------------------------------------------- ------- ----------
0 1 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSTEM01.DBF
SYSTEM READ WRITE
1 2 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\UNDOTBS01.DBF
ONLINE READ WRITE
2 3 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\SYSAUX01.DBF
ONLINE READ WRITE
4 4 C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\USERS01.DBF
ONLINE READ WRITE
6 5
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\NEWDATAFILE01.DBF
ONLINE READ WRITE

SQL>

can i use the retention policy without using the Flash


Recovery area?
can i use the retention policy without using the Flash Recovery area? yes Lets see
here..
RMAN>list backup summary

C:\>dir *.bus
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of C:\

File Not Found

C:\>dir *.arc
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of C:\

File Not Found

RMAN> crosscheck backup


2> ;

using channel ORA_DISK_1

RMAN> list backup summary


2> ;

RMAN> show retention policy


2> ;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

RMAN> run {
2> allocate channel ch0 type disk;
3> backup as compressed backupset database format
4> 'c:\rman_%s_%d_%T.bus'
5> plus archivelog format 'c:\arch_%s_%d_%T.arc';
6> release channel ch0;
7> allocate channel ch1 device type disk format 'c:\arch_%s_%d_
%T.arc';
8> release channel ch1;
9> delete force noprompt obsolete;
10> allocate channel ch2 device type disk format 'c:\rman_%s_%d_
%T.bus';
11> release channel ch2;
12> delete force noprompt obsolete;
13> }

released channel: ORA_DISK_1


allocated channel: ch0
channel ch0: sid=146 devtype=DISK

Starting backup at 15-APR-08


current log archived
channel ch0: starting compressed archive log backupset
channel ch0: specifying archive log(s) in backup set
input archive log thread=1 sequence=24 recid=79 stamp=652108461
input archive log thread=1 sequence=25 recid=80 stamp=652112650
channel ch0: starting piece 1 at 15-APR-08
channel ch0: finished piece 1 at 15-APR-08
piece handle=C:\ARCH_130_ORCL1_20080415.ARC comment=NONE
channel ch0: backup set complete, elapsed time: 00:00:05
Finished backup at 15-APR-08

Starting backup at 15-APR-08


channel ch0: starting compressed full datafile backupset
channel ch0: specifying datafile(s) in backupset
input datafile fno=00001
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\SYSTEM01.DB
F
input datafile fno=00003
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\SYSAUX01.DB
F
input datafile fno=00004
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\USERS01.DBF

input datafile fno=00002


name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\UNDOTBS01.D
BF
channel ch0: starting piece 1 at 15-APR-08
channel ch0: finished piece 1 at 15-APR-08
piece handle=C:\RMAN_131_ORCL1_20080415.BUS comment=NONE
channel ch0: backup set complete, elapsed time: 00:00:45
Finished backup at 15-APR-08

Starting backup at 15-APR-08


current log archived
channel ch0: starting compressed archive log backupset
channel ch0: specifying archive log(s) in backup set
input archive log thread=1 sequence=26 recid=81 stamp=652112703
channel ch0: starting piece 1 at 15-APR-08
channel ch0: finished piece 1 at 15-APR-08
piece handle=C:\ARCH_132_ORCL1_20080415.ARC comment=NONE
channel ch0: backup set complete, elapsed time: 00:00:02
Finished backup at 15-APR-08

Starting Control File and SPFILE Autobackup at 15-APR-08


piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\A
UTOBACKUP\2008_
04_15\O1_MF_S_652112718_408X3ZVJ_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 15-APR-08

released channel: ch0

allocated channel: ch1


channel ch1: sid=146 devtype=DISK

released channel: ch1

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=146 devtype=DISK
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 128 15-APR-08
Backup Piece 128 15-APR-08
C:\ARCH_130_ORCL1_20080415.ARC
Archive Log 79 15-APR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RE
COVERY_AREA\ORCL1\ARCHIVELOG\2008_04_15\O1_MF_1_24_408RYX
DF_.ARC
Archive Log 80 15-APR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RE
COVERY_AREA\ORCL1\ARCHIVELOG\2008_04_15\O1_MF_1_25_408X1S
CR_.ARC
deleted backup piece
backup piece handle=C:\ARCH_130_ORCL1_20080415.ARC recid=128
stamp=652112652
deleted archive log
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1
\ARCHIVEL
OG\2008_04_15\O1_MF_1_24_408RYXDF_.ARC recid=79
stamp=652108461
deleted archive log
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1
\ARCHIVEL
OG\2008_04_15\O1_MF_1_25_408X1SCR_.ARC recid=80
stamp=652112650
Deleted 3 objects

released channel: ORA_DISK_1


allocated channel: ch2
channel ch2: sid=146 devtype=DISK

released channel: ch2

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=146 devtype=DISK
no obsolete backups found

RMAN>

C:\>dir *.bus
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B
Directory of C:\

04/15/2008 02:24 PM 96,813,056


RMAN_131_ORCL1_20080415.BUS
1 File(s) 96,813,056 bytes
0 Dir(s) 61,960,724,480 bytes free

C:\>dir *.arc
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of C:\

04/15/2008 02:25 PM 56,832 ARCH_132_ORCL1_20080415.ARC


1 File(s) 56,832 bytes
0 Dir(s) 61,960,724,480 bytes free

C:\>

RMAN> run {
2> allocate channel ch0 type disk;
3> backup as compressed backupset database format
4> 'c:\rman_%s_%d_%T.bus'
5> plus archivelog format 'c:\arch_%s_%d_%T.arc';
6> release channel ch0;
7> }

released channel: ORA_DISK_1


allocated channel: ch0
channel ch0: sid=146 devtype=DISK

Starting backup at 15-APR-08


current log archived
channel ch0: starting compressed archive log backupset
channel ch0: specifying archive log(s) in backup set
input archive log thread=1 sequence=26 recid=81 stamp=652112703
input archive log thread=1 sequence=27 recid=82 stamp=652112873
channel ch0: starting piece 1 at 15-APR-08
channel ch0: finished piece 1 at 15-APR-08
piece handle=C:\ARCH_134_ORCL1_20080415.ARC comment=NONE
channel ch0: backup set complete, elapsed time: 00:00:02
Finished backup at 15-APR-08

Starting backup at 15-APR-08


channel ch0: starting compressed full datafile backupset
channel ch0: specifying datafile(s) in backupset
input datafile fno=00001
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\SYSTEM01.DB
F
input datafile fno=00003
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\SYSAUX01.DB
F
input datafile fno=00004
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\USERS01.DBF

input datafile fno=00002


name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\UNDOTBS01.D
BF
channel ch0: starting piece 1 at 15-APR-08
channel ch0: finished piece 1 at 15-APR-08
piece handle=C:\RMAN_135_ORCL1_20080415.BUS comment=NONE
channel ch0: backup set complete, elapsed time: 00:00:45
Finished backup at 15-APR-08

Starting backup at 15-APR-08


current log archived
channel ch0: starting compressed archive log backupset
channel ch0: specifying archive log(s) in backup set
input archive log thread=1 sequence=28 recid=83 stamp=652112925
channel ch0: starting piece 1 at 15-APR-08
channel ch0: finished piece 1 at 15-APR-08
piece handle=C:\ARCH_136_ORCL1_20080415.ARC comment=NONE
channel ch0: backup set complete, elapsed time: 00:00:02
Finished backup at 15-APR-08

Starting Control File and SPFILE Autobackup at 15-APR-08


piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1\A
UTOBACKUP\2008_
04_15\O1_MF_S_652112928_408XBKCZ_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 15-APR-08

released channel: ch0

RMAN> report obsolete


2> ;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 129 15-APR-08
Backup Piece 129 15-APR-08
C:\RMAN_131_ORCL1_20080415.BUS
Backup Set 130 15-APR-08
Backup Piece 130 15-APR-08
C:\ARCH_132_ORCL1_20080415.ARC
Backup Set 131 15-APR-08
Backup Piece 131 15-APR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RE
COVERY_AREA\ORCL1\AUTOBACKUP\2008_04_15\O1_MF_S_652112718
_408X3ZVJ_.BKP
Backup Set 132 15-APR-08
Backup Piece 132 15-APR-08
C:\ARCH_134_ORCL1_20080415.ARC
Archive Log 81 15-APR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RE
COVERY_AREA\ORCL1\ARCHIVELOG\2008_04_15\O1_MF_1_26_408X3H
RP_.ARC
Archive Log 82 15-APR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RE
COVERY_AREA\ORCL1\ARCHIVELOG\2008_04_15\O1_MF_1_27_408X8R
XN_.ARC

RMAN>

i have archivelog which is at FRA ,it also apply there and as


well yours own defined backupsets path.

how retention policy affects archive log


RMAN> show retention policy
2> ;

RMAN configuration parameters are:


CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

RMAN> report obsolete


2> ;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 2
no obsolete backups found
RMAN> list backup
2> ;

AS documentation says

Besides affecting datafile and control file backups, the retention


policy affects archived logs and archived log backups.First,RMAN
decides which
datafile and control file backups are obsolete. Then, RMAN considers as
obsolete
all archived log backups that are older than the oldest datafile or
control file
backup that must be retained

Now i connect to SQL and create two big table for filling the redo log
file and then
get it archived.Please consider it here that i am getting archived before
any taking
backup i.e backup database in order to make archive older then the
oldest datafile.

C:\>dir
C:\oracle\product\10.1.0\flash_recovery_area\ORCL\ARCHIVELOG\2008_
03_17
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of
C:\oracle\product\10.1.0\flash_recovery_area\ORCL\ARCHIVELOG\2008_
03_17

03/17/2008 03:44 PM <DIR> .


03/17/2008 03:44 PM <DIR> ..
03/17/2008 03:44 PM 9,750,528 O1_MF_1_15_3XWLVK6T_.ARC
1 File(s) 9,750,528 bytes
2 Dir(s) 62,714,875,904 bytes free

Now i take backup

RMAN> backup database


2> ;

Starting backup at 17-MAR-08


using channel ORA_DISK_1
RMAN> report obsolete
2> ;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 2
no obsolete backups found

RMAN> backup database


2> ;

Starting backup at 17-MAR-08


using channel ORA_DISK_1

RMAN> report obsolete


2> ;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 2
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log 402 17-MAR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RE
COVERY_AREA\ORCL\ARCHIVELOG\2008_03_17\O1_MF_1_15_3XWLVK6
T_.ARC

You can see the obsolete archived files which is the older then the
oldest file
which has been obsolete.It also does'nt make sense to keep the
archived log files
which is older then the oldest file cause it will no longer be useful for
recovery
process.

now this time what i did i created the archived log files after first
backup in
order to not to make it older then the oldest datafile backup.

RMAN> delete obsolete


2> ;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 2
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log 402 17-MAR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RE
COVERY_AREA\ORCL\ARCHIVELOG\2008_03_17\O1_MF_1_15_3XWLVK6
T_.ARC

Do you really want to delete the above objects (enter YES or NO)? yes
deleted archive log
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\
ARCHIVELO
G\2008_03_17\O1_MF_1_15_3XWLVK6T_.ARC recid=402
stamp=649611842
Deleted 1 objects

RMAN> delete backup


2> ;

using channel ORA_DISK_1

RMAN> list backup


2> ;

C:\>dir
C:\oracle\product\10.1.0\flash_recovery_area\ORCL\ARCHIVELOG\2008_
03_17
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of
C:\oracle\product\10.1.0\flash_recovery_area\ORCL\ARCHIVELOG\2008_
03_17

03/17/2008 03:59 PM <DIR> .


03/17/2008 03:59 PM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 62,724,440,064 bytes free

RMAN> backup database


2> ;
Starting backup at 17-MAR-08
using channel ORA_DISK_1

RMAN> report obsolete


2> ;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 2
no obsolete backups found

now i come to at SQL and make redo log file filled by creating 2 big
tables in order to get it
archived.

SQL> create table a3 as select * from all_objects


2 /

Table created.

SQL> create table a4 as select * from all_objects


2 /

Table created.

C:\>dir
C:\oracle\product\10.1.0\flash_recovery_area\ORCL\ARCHIVELOG\2008_
03_17
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B

Directory of
C:\oracle\product\10.1.0\flash_recovery_area\ORCL\ARCHIVELOG\2008_
03_17

03/17/2008 04:09 PM <DIR> .


03/17/2008 04:09 PM <DIR> ..
03/17/2008 04:09 PM 9,751,552 O1_MF_1_16_3XWNCGRS_.ARC
1 File(s) 9,751,552 bytes
2 Dir(s) 62,563,205,120 bytes free

RMAN> backup database


2> ;

Starting backup at 17-MAR-08


using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset

RMAN> report obsolete


2> ;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 2
no obsolete backups found

You can see no archived logs get obsolete yet cause the archivelog
O1_MF_1_16_3
XWNCGRS_.ARC is not older then oldest datafile backup.

But this archivelog file will get obsolete if its beyond the retention
policy,lets
see how ,just take one more backup ,as i have already taken two time
backup and
the moment i go to take third backup it will cross ours retetnion policy
from the
period of 2.

RMAN> backup database


2> ;

RMAN> report obsolete


2> ;

RMAN retention policy will be applied to the command


RMAN retention policy is set to redundancy 2
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 240 17-MAR-08
Backup Piece 231 17-MAR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RE
COVERY_AREA\ORCL\BACKUPSET\2008_03_17\O1_MF_NNNDF_TAG2008
0317T160604_3XWN4WTB_.B
KP
Backup Set 241 17-MAR-08
Backup Piece 232 17-MAR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RE
COVERY_AREA\ORCL\BACKUPSET\2008_03_17\O1_MF_NCSNF_TAG2008
0317T160604_3XWN6Z95_.B
KP
Archive Log 403 17-MAR-08
C:\ORACLE\PRODUCT\10.1.0\FLASH_RE
COVERY_AREA\ORCL\ARCHIVELOG\2008_03_17\O1_MF_1_16_3XWNCG
RS_.ARC

How to clone database within same server


SQL> select instance_name from v$instance
2 /

INSTANCE_NAME
----------------
orcl

SQL> select * from tab


2 /

TNAME TABTYPE CLUSTERID


------------------------------ ------- ----------
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
TEST1 TABLE
TEST TABLE
TEST2 TABLE

7 rows selected.

SQL> create table primary_table as select * from all_objects


2 .
SQL> /

Table created.

SQL>

==========================================
========================
Backup production database with archivelog
==========================================
========================

Recovery Manager: Release 10.1.0.2.0 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.


RMAN> connect target sys/sys@orcl

connected to target database: ORCL (DBID=1171886541)

RMAN> backup database plus archivelog delete input


2> ;

Starting backup at 29-JAN-08


current log archived
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=151 devtype=DISK
channel ORA_DISK_1: starting compressed archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=25 recid=82 stamp=645234594
input archive log thread=1 sequence=26 recid=83 stamp=645234661
input archive log thread=1 sequence=27 recid=84 stamp=645234727
input archive log thread=1 sequence=28 recid=85 stamp=645274841
input archive log thread=1 sequence=29 recid=86 stamp=645274906
input archive log thread=1 sequence=30 recid=87 stamp=645284174
input archive log thread=1 sequence=31 recid=88 stamp=645284257
channel ORA_DISK_1: starting piece 1 at 29-JAN-08
channel ORA_DISK_1: finished piece 1 at 29-JAN-08
piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BA
CKUPSET\2008_01_29\O1_MF_ANNNN_TAG20080129T133739_3SXSGO
8V_.BKP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08
channel ORA_DISK_1: deleting archive log(s)
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\
ARCHIVELOG\2008_01_28\O1_MF_1_25_3SW8YJTC_.ARC recid=82
stamp=645234594
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\
ARCHIVELOG\2008_01_28\O1_MF_1_26_3SW90NPY_.ARC recid=83
stamp=645234661
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\
ARCHIVELOG\2008_01_28\O1_MF_1_27_3SW92Q8S_.ARC recid=84
stamp=645234727
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\
ARCHIVELOG\2008_01_29\O1_MF_1_28_3SXJ857Y_.ARC recid=85
stamp=645274841
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\
ARCHIVELOG\2008_01_29\O1_MF_1_29_3SXJB85Y_.ARC recid=86
stamp=645274906
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\
ARCHIVELOG\2008_01_29\O1_MF_1_30_3SXSCX8F_.ARC recid=87
stamp=645284174
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\
ARCHIVELOG\2008_01_29\O1_MF_1_31_3SXSGKNL_.ARC recid=88
stamp=645284257
Finished backup at 29-JAN-08

Starting backup at 29-JAN-08


using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\SYSTEM01.DBF
input datafile fno=00003
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\SYSAUX01.DBF
input datafile fno=00005
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\EXAMPLE01.DBF
input datafile fno=00002
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\UNDOTBS01.DBF
input datafile fno=00004
name=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 29-JAN-08
channel ORA_DISK_1: finished piece 1 at 29-JAN-08
piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BA
CKUPSET\2008_01_29\O1_MF_NNNDF_TAG20080129T133749_3SXSGY3
H_.BKP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 29-JAN-08
channel ORA_DISK_1: finished piece 1 at 29-JAN-08
piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BA
CKUPSET\2008_01_29\O1_MF_NCSNF_TAG20080129T133749_3SXSJPO
0_.BKP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:09
Finished backup at 29-JAN-08

Starting backup at 29-JAN-08


current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=32 recid=89 stamp=645284335
channel ORA_DISK_1: starting piece 1 at 29-JAN-08
channel ORA_DISK_1: finished piece 1 at 29-JAN-08
piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BA
CKUPSET\2008_01_29\O1_MF_ANNNN_TAG20080129T133855_3SXSK0L
2_.BKP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\
ARCHIVELOG\2008_01_29\O1_MF_1_32_3SXSJZ1Y_.ARC recid=89
stamp=645284335
Finished backup at 29-JAN-08

Create duplicate database hirarchy with DBCA as same file structure


with production database hirarchy

===================================
Add Listener in listener.ora file
===================================

# listener.ora Network Configuration File:


C:\oracle\product\10.1.0\Db_2\NETWORK\ADMIN\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ORCL)
(ORACLE_HOME = %ORACLE_HOME%)
(SID_NAME = ORCL)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl1)
(ORACLE_HOME = %oracle_home%)
(SID_NAME = ORCL1)
)
)

LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = pz-khurrams)(PORT =
1521))
)

==========================================
===============
Add tnames string in tnsnames.ora for duplicate database
==========================================
===============

ORCL1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = pz-khurrams)(PORT =
1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl1)
)
)

ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = pz-khurrams)(PORT =
1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)

==========================================
==========================================
=========================
Edit the pfile of duplicate database ORCL1 and make some changes
and after all changes just save not save as
==========================================
==========================================
=========================

DB_FILE_NAME_CONVERT=("C:\oracle\product\10.1.0\oradata\orcl\","C:
\oracle\product\10.1.0\oradata\orcl1\orcl1")
LOG_FILE_NAME_CONVERT=("c:\oracle\product\10.1.0\oradata\orcl","C:
\oracle\product\10.1.0\oradata\orcl1\orcl1")

==========================================
==========================================
=========================
Connect to duplicate database ORCL1 and create spfile from edited
pfile
==========================================
==========================================
=========================

SQL> shutdown immediate


Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> create spfile from


pfile='C:\oracle\product\10.1.0\admin\orcl1\pfile\init.ora.02920081452
43'
2 /

File created.

SQL> startup nomount

ORACLE instance started.


Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes

SQL> select instance_name from v$instance


2 /

INSTANCE_NAME
----------------
orcl1
==========================================
==========================================
=========================
Connect to target production database ORCL and mount the database
==========================================
==========================================
=========================

SQL> conn sys/sys@orcl as sysdba


Connected.

SQL> shutdown immediate

Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.


Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
Database mounted.

SQL> select instance_name from v$instance


2 /

INSTANCE_NAME
----------------
orcl

==========================================
==========================================
=========================
Go to dos prompt
==========================================
==========================================
=========================

C:\>set oracle_sid=orcl
C:\>rman target / auxiliary sys/sys@orcl1

Recovery Manager: Release 10.1.0.2.0 - Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1171886541)


connected to auxiliary database: orcl1 (not mounted)

RMAN> run
2> {
3> allocate auxiliary channel aux1 device type disk;
4> duplicate target database to 'orcl1';
5> }

using target database controlfile instead of recovery catalog


allocated channel: aux1
channel aux1: sid=160 devtype=DISK

Starting Duplicate Db at 29-JAN-08

contents of Memory Script:


{
set until scn 1104818;
set newname for datafile 1 to
"C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1SYSTEM01.DBF"
;
set newname for datafile 2 to
"C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1UNDOTBS01.DB
F";
set newname for datafile 3 to
"C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1SYSAUX01.DBF"
;
set newname for datafile 4 to
"C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1USERS01.DBF";
set newname for datafile 5 to
"C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1EXAMPLE01.DBF
";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 29-JAN-08

channel aux1: starting datafile backupset restore


channel aux1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1SYSTEM01.DBF
restoring datafile 00002 to
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1UNDOTBS01.DBF
restoring datafile 00003 to
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1SYSAUX01.DBF
restoring datafile 00004 to
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1USERS01.DBF
restoring datafile 00005 to
C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1EXAMPLE01.DBF
channel aux1: restored backup piece 1
piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BA
CKUPSET\2008_01_29\O1_MF_NNNDF_TAG20080129T133749_3SXSGY3
H_.BKP tag=TAG20080129T133749
channel aux1: restore complete
Finished restore at 29-JAN-08
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "orcl1"
RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 454
LOGFILE
GROUP 1
( 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1\REDO01.LOG' )
SIZE 10 M REUSE,
GROUP 2
( 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1\REDO02.LOG' )
SIZE 10 M REUSE,
GROUP 3
( 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1\REDO03.LOG' )
SIZE 10 M REUSE
DATAFILE
'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1SYSTEM01.DBF'
CHARACTER SET WE8MSWIN1252

contents of Memory Script:


{
switch clone datafile all;
}
executing Memory Script

datafile 2 switched to datafile copy


input datafilecopy recid=1 stamp=645290815
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1UNDOT
BS01.DBF
datafile 3 switched to datafile copy
input datafilecopy recid=2 stamp=645290815
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1SYSAU
X01.DBF
datafile 4 switched to datafile copy
input datafilecopy recid=3 stamp=645290815
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1USERS
01.DBF
datafile 5 switched to datafile copy
input datafilecopy recid=4 stamp=645290815
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1EXAMP
LE01.DBF

contents of Memory Script:


{
set until scn 1104818;
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause


Starting recover at 29-JAN-08

starting media recovery

channel aux1: starting archive log restore to default destination


channel aux1: restoring archive log
archive log thread=1 sequence=32
channel aux1: restored backup piece 1
piece
handle=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL\BA
CKUPSET\2008_01_29\O1_MF_ANNNN_TAG20080129T133855_3SXSK0L
2_.BKP tag=TAG20080129T133855
channel aux1: restore complete
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1
\ORCL1\ARCHIVELOG\2008_01_29\O1_MF_1_32_3SXZVRPT_.ARC
thread=1 sequence=32
channel clone_default: deleting archive log(s)
archive log
filename=C:\ORACLE\PRODUCT\10.1.0\FLASH_RECOVERY_AREA\ORCL1
\ORCL1\ARCHIVELOG\2008_01_29\O1_MF_1_32_3SXZVRPT_.ARC
recid=1 stamp=645290824
media recovery complete
Finished recover at 29-JAN-08

contents of Memory Script:


{
shutdown clone;
startup clone nomount ;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)


Oracle instance started

Total System Global Area 171966464 bytes

Fixed Size 787988 bytes


Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "orcl1"
RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 454
LOGFILE
GROUP 1
( 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1\REDO01.LOG' )
SIZE 10 M REUSE,
GROUP 2
( 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1\REDO02.LOG' )
SIZE 10 M REUSE,
GROUP 3
( 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1\REDO03.LOG' )
SIZE 10 M REUSE
DATAFILE
'C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1SYSTEM01.DBF'
CHARACTER SET WE8MSWIN1252

contents of Memory Script:


{
catalog clone datafilecopy
"C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1UNDOTBS01.DBF
";
catalog clone datafilecopy
"C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1SYSAUX01.DBF";
catalog clone datafilecopy
"C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1USERS01.DBF";
catalog clone datafilecopy
"C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1EXAMPLE01.DBF
";
switch clone datafile all;
}
executing Memory Script

cataloged datafile copy


datafile copy
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1UNDOT
BS01.DBF recid=1 stamp=645290915

cataloged datafile copy


datafile copy
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1SYSAU
X01.DBF recid=2 stamp=645290916
cataloged datafile copy
datafile copy
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1USERS
01.DBF recid=3 stamp=645290916

cataloged datafile copy


datafile copy
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1EXAMP
LE01.DBF recid=4 stamp=645290916

datafile 2 switched to datafile copy


input datafilecopy recid=1 stamp=645290915
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1UNDOT
BS01.DBF
datafile 3 switched to datafile copy
input datafilecopy recid=2 stamp=645290916
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1SYSAU
X01.DBF
datafile 4 switched to datafile copy
input datafilecopy recid=3 stamp=645290916
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1USERS
01.DBF
datafile 5 switched to datafile copy
input datafilecopy recid=4 stamp=645290916
filename=C:\ORACLE\PRODUCT\10.1.0\ORADATA\ORCL1\ORCL1EXAMP
LE01.DBF

contents of Memory Script:


{
Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 29-JAN-08

RMAN>

SQL> conn scott/tiger@orcl1


Connected.
SQL> select * from tab
2 /

TNAME TABTYPE CLUSTERID


------------------------------ ------- ----------
DEPT TABLE
EMP TABLE
BONUS TABLE
SALGRADE TABLE
TEST1 TABLE
TEST TABLE
TEST2 TABLE
PRIMARY_TABLE TABLE

8 rows selected.

You might also like