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.

Tuesday, September 29, 2009

Backup Plus Archivleog

Question :

RMAN will do backup of current redolog by moving the log to archivelog if we did 'backup database plus archivelog'. Do RMAN will backup the redolog if the backup command is without archivelog?

Answer :

Whenever you backup archivelog log ,log switch occur for the current log.
SQL> select group#,status
  2    from v$log
  3  /

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

RMAN> backup archivelog all;

Starting backup at 29-SEP-09
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=366 RECID=396 STAMP=698845462
channel ORA_DISK_1: starting piece 1 at 29-SEP-09
channel ORA_DISK_1: finished piece 1 at 29-SEP-09
piece handle=/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_29/o1_mf_annnn_TAG20090929T114422_5d3c69j7_.bkp tag=TAG20090929T114422 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-09

SQL> select group#,status
  2    from v$log
  3  /


    GROUP# STATUS
---------- ----------------
         1 CURRENT
         2 INACTIVE
         3 ACTIVE
You can see above that during archivelog backup process log switch occur.
SQL> select group#,status
  2    from v$log
  3  /

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

RMAN> backup database plus archivelog;


Starting backup at 29-SEP-09
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=367 RECID=398 STAMP=698845610
channel ORA_DISK_1: starting piece 1 at 29-SEP-09
channel ORA_DISK_1: finished piece 1 at 29-SEP-09
piece handle=/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_29/o1_mf_annnn_TAG20090929T114650_5d3cbxg3_.bkp tag=TAG20090929T114650 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-09

Starting backup at 29-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/undotbs03.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/mmi/users01.dbf
channel ORA_DISK_1: starting piece 1 at 29-SEP-09
channel ORA_DISK_1: finished piece 1 at 29-SEP-09
piece handle=/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_29/o1_mf_nnndf_TAG20090929T114654_5d3cc1yz_.bkp tag=TAG20090929T114654 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 29-SEP-09
channel ORA_DISK_1: finished piece 1 at 29-SEP-09
piece handle=/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_29/o1_mf_ncsnf_TAG20090929T114654_5d3cdm4z_.bkp tag=TAG20090929T114654 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-09

Starting backup at 29-SEP-09
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=368 RECID=400 STAMP=698845668
channel ORA_DISK_1: starting piece 1 at 29-SEP-09
channel ORA_DISK_1: finished piece 1 at 29-SEP-09
piece handle=/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_29/o1_mf_annnn_TAG20090929T114748_5d3cdqpv_.bkp tag=TAG20090929T114748 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-09

SQL> select group#,status
  2    from v$log
  3  /


    GROUP# STATUS
---------- ----------------
         1 INACTIVE
         2 ACTIVE
         3 CURRENT
As you can see "backup database plus archivelog" comes up with archivelog backup which inherit the log switch occurrence of archivelog backup.
SQL> select group#,status
  2    from v$log
  3  /

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


RMAN> backup database;

Starting backup at 29-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/undotbs03.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/mmi/users01.dbf
channel ORA_DISK_1: starting piece 1 at 29-SEP-09
channel ORA_DISK_1: finished piece 1 at 29-SEP-09
piece handle=/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_29/o1_mf_nnndf_TAG20090929T115013_5d3ck8jy_.bkp tag=TAG20090929T115013 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 29-SEP-09
channel ORA_DISK_1: finished piece 1 at 29-SEP-09
piece handle=/u01/app/oracle/flash_recovery_area/MMI/backupset/2009_09_29/o1_mf_ncsnf_TAG20090929T115013_5d3clstc_.bkp tag=TAG20090929T115013 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-SEP-09


SQL> select group#,status
  2    from v$log
  3  /

    GROUP# STATUS
---------- ----------------
         1 INACTIVE
         2 INACTIVE
         3 CURRENT
As you can only just backup database will not trigger a log switch. But keep in mind during online backup there may be some background process or some online users production activity cause massive redo which filled the redo within the span of backup process time and then trigger a log switch does not mean that "backup database" cause a log switch.

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.

Tuesday, September 15, 2009

coreletion between report need backup and retention policy

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_annnn_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_nnndf_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_annnn_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_697633458_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> 

Followers

About Me

My photo
Melbourne, Victoria, Australia