I am an IT professional with 10 years of professional experience,I have good proficiency on Oracle technologies, and at last 2 years of my career to study Real Application Clusters,data guard and participate actively on Oracle community ,If you want to hire me on Contract or to quote on project basis contact me at khurrampc@hotmail.com.

Wednesday, September 16, 2009

Recovered SCN

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_mf_1_1_5c19gzs5_.arc
File Name: /u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_16/o1_mf_1_2_5c19h2m0_.arc
File Name: /u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_16/o1_mf_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_mf_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_mf_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_mf_1_3_5c19h4tk_.arc
archived log file name=/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_16/o1_mf_1_1_5c19gzs5_.arc thread=1 sequence=1
archived log file name=/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_16/o1_mf_1_2_5c19h2m0_.arc thread=1 sequence=2
archived log file name=/u01/app/oracle/flash_recovery_area/MMI/archivelog/2009_09_16/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.

3 comments:

Scofield said...

Dear Khurram;
First of all, I would like to thank you for helping me with my rman questions.
To be honest, I really learned a lot from you.

I have one more question, that I`ve been thinking for the last couple of days.
I really appreciate if you clear my doubts.


I have a production database(orcl) and a copy of production database(orcl2) which is refreshed every night.
Everyday we take hot backup with (alter tablespace begin backup) and perform flash copy of the
datafiles to orcl2 and open resetlogs.

Yesterday, this operation failed and I even couldnt manage to open orcl2.
The thing is even the flash copy failed, I couldnt even open the database normally.(old version)

When I try to recover with latest controlfile it just says:

SQL> recover database using backup controlfile;
ORA-00283: recovery session canceled due to errors
ORA-01190: controlfile or data file 1 is from before the last RESETLOGS
ORA-01110: data file 1: '...'



When I recreate the controlfile from controltrace, and perform recovery in the alertlog it says:

WARNING! Recovering data file ... from a fuzzy file. If not the current file
it might be an online backup taken without entering the begin backup command

Also it is requesting archivelog sequence _0000000010_1.arc which was generated in April?
However my current log seq is _0000019202_1.arc
I dont understand why it requests very very very old archivelog... It doesnt make sense



When I check datafile headers:

I see:

ERROR FUZ
----------------------------------------------------------------- ---
WRONG RESETLOGS YES


SQL> select CHECKPOINT_CHANGE# from v$datafile where rownum<3;

CHECKPOINT_CHANGE#
------------------
4446922742
4446922742

SQL> select CHECKPOINT_CHANGE# from v$datafile_header where rownum<3;

CHECKPOINT_CHANGE#
------------------
4443857329
4443857329




and in orcl

SQL> select RESETLOGS_CHANGE# from v$datafile_header where rownum<2;

RESETLOGS_CHANGE#
-----------------
3250834775

Flash copy one:

SQL> select RESETLOGS_CHANGE# from v$datafile_header where rownum<2;

RESETLOGS_CHANGE#
-----------------
4443659941



I think this shows that flash copy didnt happen, but why I cant open the database?
As I showed you above, I have also trace to recreate controlfile from trace

Khurram Siddiqui said...

I am really sorry scofield , i was too sick and got a bed rest , i was not following anything regarding my blog as well oracle's stuff , i am back now and will continue my effort to share all of you about my findings.

Khurram

xanthelaneve said...

Best Casino & Hotel Deals in Maricopa, AZ - Mapyro
Save up to 70% with MapYRO® 창원 출장샵 Resort and Casino® Resort® Hotel Deals 영천 출장마사지 on your 울산광역 출장안마 trip to 여수 출장마사지 Maricopa, 부산광역 출장안마 AZ.

Followers

About Me

My photo
Melbourne, Victoria, Australia