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 ?
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.
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
RMAN>
Database altered.
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;
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' ;
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';
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';
SQL> commit;
Commit complete.
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#;
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;
SQL>
SQL> spool off
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.
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;
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
RMAN>
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
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;
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
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.
Let me verify the database and also understand why I got the “CURRENT_SCN=0”
earlier.
SQL> startup;
ORACLE instance started.
Database altered.
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.
Recovery Manager10.2.0.1.0
RMAN>
connected to target database: OR10G2DB (not mounted)
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>
}
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.
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”.
SQL>
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>
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.
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.
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.
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.
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.
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.
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 .
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 :
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:
7) Now catalog the backup pieces that were shipped from NODE 1
8) Get to know the last sequence available in the archivelog backup using the following
command
9) Rename the Redologfiles,so that they can be created in new locations when opened the
database is opened in resetlogs
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.
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
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> ;
RMAN> run
2> {
3> RESTORE VALIDATE CHECK LOGICAL ARCHIVELOG from sequence 32;
4> }
Question :
after performing recovery, how can we know till what time the target database is being
recovered.
RMAN> exit
Recovery Manager complete.
database mounted
released channel: ORA_DISK_1
From another terminal come at SQL
[oracle@khurram ~]$ sqlplus / as sysdba
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
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;
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;
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>
CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------------------- ------------------
675815 675666
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.
CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------------------- ------------------
676283 676131
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.
CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------------------- ------------------
676623 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.
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
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
From one session i acquire the exclusive lock on resource (emp table)
Session a
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
i.e
From one session i acquire the share lock on resource (emp table)
Session c
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
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
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
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
These DML locks are always and only (exclusive) at row level but it can be shared as
well as exclusive at table level.
Here is an exceprt from SQL to verify that DML acquires lock at both row and table level
Session 1
1 row updated.
Session 2
hanged
Session 3
As we have already seen that there are two types of DML locks
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.
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:
1 row updated.
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 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.
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.
-------------------------------------------------------------------------------
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.
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.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
Table created.
Table created.
Table created.
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..
SQL> startup
ORACLE instance started.
C:\>rman
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
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.
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>
*.log_archive_start=FALSE
Database closed.
Database dismounted.
ORACLE instance shut down.
System altered.
*.log_archive_start=TRUE
System altered.
SQL>shutdown immediate
SQL>startup mount
SQL> alter database noarchivelog
2 /
Database altered.
Database 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.
NAME
---------
PROD
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.
Database altered.
Database altered.
SYSDATE
---------
19-APR-08
Table created.
Table created.
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
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: t1
allocated channel: t2
channel t2: sid=125 devtype=DISK
released channel: t2
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
---------------------------------------------------------------------
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
Table created.
Table created.
Table created.
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
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
----------------------------------------------------------------------------
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
C:\oracle\product\10.1.0\oradata\orcl1>
SQL> startup
ORACLE instance started.
C:\>rman
database opened
RMAN>
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> 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 :
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.
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.
SQL>
Table created.
Table created.
System altered.
C:\oracle\product\10.1.0\oradata>
SQL> startup
ORACLE instance started.
Table created.
System altered.
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
SQL> startup
ORACLE instance started.
C:\oracle\product\10.1.0\oradata>
SQL> startup
ORACLE instance started.
Database altered.
Question :
Answer :
TS# NAME
---------- ------------------------------
0 SYSTEM
1 UNDOTBS1
2 SYSAUX
4 USERS
3 TEMP
Tablespace created.
6 rows selected.
SQL>
SQL> select ts#,file#,substr(name,1,50) name,status,enabled
2 from v$datafile
3 /
User altered.
SQL> conn scott/tiger@uat
Connected.
SQL> create table v1 as select * from all_objects
2 /
Table created.
Table created.
System altered.
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
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
RMAN> startup
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
C:\oracle\product\10.1.0\oradata\uat>
RMAN>
no rows selected
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
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Database altered.
C:\>rman
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
Database dismounted.
ORACLE instance shut down.
GROUP# STATUS
---------- ----------------
1 INACTIVE
2 INACTIVE
3 CURRENT
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\REDO03.log<---------
------------------
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\REDO01.LOG<--------
-------------------
C:\ORACLE\PRODUCT\10.1.0\ORADATA\UAT\REDO02.LOG<--------
----------
Log applied.
Media recovery complete.
Database altered.
Database altered.
SQL>
C:\>dir *.bus
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B
Directory of C:\
C:\>dir *.arc
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B
Directory of 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> 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> }
RMAN>
C:\>dir *.bus
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B
Directory of C:\
C:\>dir *.arc
Volume in drive C is khurram
Volume Serial Number is F49D-FF2B
Directory of C:\
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> }
RMAN>
AS documentation says
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
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.
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
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
now i come to at SQL and make redo log file filled by creating 2 big
tables in order to get it
archived.
Table created.
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
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.
INSTANCE_NAME
----------------
orcl
7 rows selected.
Table created.
SQL>
==========================================
========================
Backup production database with archivelog
==========================================
========================
===================================
Add Listener in listener.ora file
===================================
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
==========================================
==========================================
=========================
File created.
INSTANCE_NAME
----------------
orcl1
==========================================
==========================================
=========================
Connect to target production database ORCL and mount the database
==========================================
==========================================
=========================
Database closed.
Database dismounted.
ORACLE instance shut down.
INSTANCE_NAME
----------------
orcl
==========================================
==========================================
=========================
Go to dos prompt
==========================================
==========================================
=========================
C:\>set oracle_sid=orcl
C:\>rman target / auxiliary sys/sys@orcl1
RMAN> run
2> {
3> allocate auxiliary channel aux1 device type disk;
4> duplicate target database to 'orcl1';
5> }
database dismounted
Oracle instance shut down
database opened
Finished Duplicate Db at 29-JAN-08
RMAN>
8 rows selected.