15 November, 2010

"SET TIME ON" in RMAN

"SET TIME ON" in SQLPlus is a SQLPlus client command. It displays the system time from the SQLPlus client program.

If you want RMAN to display "time" you can use NLS_DATE_FORMAT as below :

[oracle@localhost ~]$ env |grep NLS
[oracle@localhost ~]$ NLS_DATE_FORMAT=DD_MON_YYYY_HH24:MI:SS;export NLS_DATE_FORMAT
[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Nov 15 06:45:50 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORCL (DBID=1229390655)

RMAN> backup database;

Starting backup at 15_NOV_2010_06:45:55
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=54 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=47 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/addtl/oracle/oradata/orcl/users01.dbf
input datafile file number=00002 name=/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00001 name=/home/oracle/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00003 name=/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/home/oracle/app/oracle/oradata/orcl/example01.dbf
input datafile file number=00006 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1046101119510758.dbf
input datafile file number=00007 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1146416395631714.dbf
input datafile file number=00008 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1170420963682633.dbf
channel ORA_DISK_1: starting piece 1 at 15_NOV_2010_06:45:58
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00014 name=/addtl/oracle/oradata/orcl/hemant01.dbf
input datafile file number=00015 name=/addtl/oracle/oradata/orcl/hemant02.dbf
input datafile file number=00016 name=/addtl/oracle/oradata/orcl/hemant03.dbf
input datafile file number=00009 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1194425963955800.dbf
input datafile file number=00010 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1218408858999342.dbf
input datafile file number=00011 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1242310449730067.dbf
input datafile file number=00012 name=/home/oracle/app/oracle/oradata/orcl/FLOW_1266412439758696.dbf
input datafile file number=00013 name=/home/oracle/app/oracle/oradata/orcl/APEX_1295922881855015.dbf
channel ORA_DISK_2: starting piece 1 at 15_NOV_2010_06:45:58
channel ORA_DISK_2: finished piece 1 at 15_NOV_2010_06:46:01
piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2010_11_15/o1_mf_nnndf_TAG20101115T064557_6g2kx70g_.bkp tag=TAG20101115T064557 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_2: starting piece 1 at 15_NOV_2010_06:46:03
channel ORA_DISK_2: finished piece 1 at 15_NOV_2010_06:46:06
piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2010_11_15/o1_mf_ncnnf_TAG20101115T064557_6g2kxcc6_.bkp tag=TAG20101115T064557 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_2: starting piece 1 at 15_NOV_2010_06:46:07
channel ORA_DISK_2: finished piece 1 at 15_NOV_2010_06:46:08
piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2010_11_15/o1_mf_nnsnf_TAG20101115T064557_6g2kxh4q_.bkp tag=TAG20101115T064557 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:02
...



Notice how the RMAN output shows the Tmestamp in DD_MON_YYYY_HH24:MI:SS format. You could specify an alternate format as well.

[oracle@localhost ~]$ NLS_DATE_FORMAT=DD/MM/YYYY_HH24_MI_SS;export NLS_DATE_FORMAT
[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Nov 15 06:50:47 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORCL (DBID=1229390655)

RMAN> backup datafile 1 ;

Starting backup at 15/11/2010_06_50_53
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=47 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=49 device type=DISK
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=/home/oracle/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: starting piece 1 at 15/11/2010_06_50_56
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_2: starting piece 1 at 15/11/2010_06_51_00
channel ORA_DISK_2: finished piece 1 at 15/11/2010_06_51_16
piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2010_11_15/o1_mf_ncnnf_TAG20101115T065055_6g2l6obt_.bkp tag=TAG20101115T065055 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:16
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_2: starting piece 1 at 15/11/2010_06_51_17
channel ORA_DISK_1: finished piece 1 at 15/11/2010_06_51_32
piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2010_11_15/o1_mf_nnndf_TAG20101115T065055_6g2l6jdx_.bkp tag=TAG20101115T065055 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36
channel ORA_DISK_2: finished piece 1 at 15/11/2010_06_51_32
piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2010_11_15/o1_mf_nnsnf_TAG20101115T065055_6g2l763s_.bkp tag=TAG20101115T065055 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:15
Finished backup at 15/11/2010_06_51_32

RMAN>


Thus, I can change the format of the time display with NLS_DATE_FORMAT.

I can also display backup timestamps etc in the desired format :

[oracle@localhost ~]$ NLS_DATE_FORMAT=DD_MON_RR_HH24_MI_SS
[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Nov 15 06:54:15 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORCL (DBID=1229390655)

RMAN> list backup of datafile 1;

using target database control file instead of recovery catalog

List of Backup Sets
===================


BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ------------------
21 Full 666.52M DISK 00:00:48 26_OCT_10_07_17_31
BP Key: 21 Status: AVAILABLE Compressed: NO Tag: TAG20101026T071642
Piece Name: /addtl/oracle/flash_recovery_area/ORCL/backupset/2010_10_26/o1_mf_nnndf_TAG20101026T071642_6dfrpcdn_.bkp
List of Datafiles in backup set 21
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------ ----
1 Full 5323127 26_OCT_10_07_16_43 /home/oracle/app/oracle/oradata/orcl/system01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ------------------
27 Full 953.77M DISK 00:04:42 26_OCT_10_07_23_15
BP Key: 27 Status: AVAILABLE Compressed: YES Tag: TAG20101026T071833
Piece Name: /addtl/oracle/flash_recovery_area/ORCL/backupset/2010_10_26/o1_mf_nnndf_TAG20101026T071833_6dfrst78_.bkp
List of Datafiles in backup set 27
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------ ----
1 Full 5323217 26_OCT_10_07_18_33 /home/oracle/app/oracle/oradata/orcl/system01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ------------------
34 Full 668.63M DISK 00:00:34 15_NOV_10_06_51_30
BP Key: 34 Status: AVAILABLE Compressed: NO Tag: TAG20101115T065055
Piece Name: /addtl/oracle/flash_recovery_area/ORCL/backupset/2010_11_15/o1_mf_nnndf_TAG20101115T065055_6g2l6jdx_.bkp
List of Datafiles in backup set 34
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ------------------ ----
1 Full 5442510 15_NOV_10_06_50_56 /home/oracle/app/oracle/oradata/orcl/system01.dbf

RMAN>


This is useful when you are looking for backups within a particular time range and yo uhave had multiple backups done on the same day. The format can be modified to show Hours_Minutes_Seconds as well.
.
.
.

8 comments:

Quaresma said...

Hi Hemant,

Suppose, I have a full rman backup of a database called "orcl" in the tape.
Can I restore this backupset to another host with database and instance name "test" ?
I will first restore controlfile and datafiles respectively.

In other words, is it necessary to have same database name and instance name if I want to do restore ?

Hemant K Chitale said...

Quaresma,
Your question doesn't actually relate to this blog post.
The DB_NAME is specified in the parameter file (initSID.ora) and the controlfile and the datafile headers.
If you recreate the controlfile to SET the database name, you need to re-CATALOG all the backupsets.

Hemant K Chitale

Quaresma said...

Hi Hemant,

Thanks for your response.

Suppose I have a database called "orcl".
In other host I have a database called "test".

If shutdown "test" database, can I restore the rman backup of orcl database ? (first controlfile, then datafiles)
I am gonna put the rman backup files to same location.

Hemant K Chitale said...

Quaresma,
Please do not persist in submitting questions that don't relate to the blog post. Else, I'll soon become "free Oracle Support" answering your questions.

If "test" is shutdown, "orcl" can be copied in as "test". However, both "test" databases cannot be running at the same time. The new "test" has to be renamed (e.g. to "test2") before re-starting the old "test".

Hemant K Chitale

Quaresma said...

Thanks Hemant,

Suppose I dont want to use "duplicate database" command, can I still restore the backups of orcl to test with standard rman restore? (Note that instance name is different and db_name parameter in the pfile will be different)

Hemant K Chitale said...

Quaresma,
Yes you can use RMAN to RESTORE backups without having to use DUPLICATE.

I cannot allow further conversation on this topic as it is not relevant to this blog post.

Hemant K Chitale

John said...

Hello

In a disaster situation, the following rman command is advised to restore database

{code}
Collect the last SCN
SELECT archivelog_change#-1 FROM v$database;

RMAN> run{
set until scn number from above sql;
restore database;
recover database;
alter database open resetlogs;
}
{code}

My question is,

1-) Why do I need to use archivelog_change#-1 ? why not archivelog_change# or CHECKPOINT_CHANGE# or CURRENT_SCN ?

2-) What is the benefit of using "set until scn" clause ?, If I dont use it, wouldnt rman restore and recover the database as far as it can ?





Thanks in advance

Hemant K Chitale said...

John,
You'd have to refer to the note that provided you these commands. There would be context.

Hemant