16 September, 2011

RMAN Tips -- 1

Restoring ArchiveLogs to an alternate location


RMAN> list archivelog all;

specification does not match any archived log in the repository

RMAN> sql 'alter system switch logfile';

sql statement: alter system switch logfile

RMAN> list archivelog all;

List of Archived Log Copies for database with db_unique_name ORCL
=====================================================================

Key Thrd Seq S Low Time
------- ---- ------- - ---------
806 1 237 A 11-SEP-11
Name: /addtl/oracle/flash_recovery_area/ORCL/archivelog/2011_09_16/o1_mf_1_237_776rnnow_.arc


RMAN>
RMAN> backup archivelog all;

Starting backup at 16-SEP-11
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
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=237 RECID=806 STAMP=762043927
channel ORA_DISK_1: starting piece 1 at 16-SEP-11
channel ORA_DISK_2: starting archived log backup set
channel ORA_DISK_2: specifying archived log(s) in backup set
input archived log thread=1 sequence=238 RECID=807 STAMP=762043998
channel ORA_DISK_2: starting piece 1 at 16-SEP-11
channel ORA_DISK_1: finished piece 1 at 16-SEP-11
piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp tag=TAG20110916T225318 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_2: finished piece 1 at 16-SEP-11
piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp tag=TAG20110916T225318 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:02
Finished backup at 16-SEP-11

Starting Control File and SPFILE Autobackup at 16-SEP-11
piece handle=/addtl/oracle/flash_recovery_area/ORCL/autobackup/2011_09_16/o1_mf_s_762044001_776rq1r5_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 16-SEP-11

RMAN>


So, I have two ArchiveLogs (SEQUENCE# 237 and 238) backed up to two BackupSets in /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/

I now delete the two ArchiveLogs :

RMAN> exit


Recovery Manager complete.
[oracle@localhost ~]$ cd /addtl/oracle/flash_recovery_area/ORCL/archivelog/2011_09_16/
[oracle@localhost 2011_09_16]$ ls -l
total 21604
-rw-rw---- 1 oracle oracle 22071296 Sep 16 22:52 o1_mf_1_237_776rnnow_.arc
-rw-rw---- 1 oracle oracle 17920 Sep 16 22:53 o1_mf_1_238_776rpyof_.arc
[oracle@localhost 2011_09_16]$
[oracle@localhost 2011_09_16]$ rm *.arc
[oracle@localhost 2011_09_16]$ ls -l
total 0
[oracle@localhost 2011_09_16]$


If I were to restore the ArchiveLogs to an alternate / test server, where I have copied the BackpSets to /tmp and want to restore the ArchiveLogs to /tmp as well, I must first begin with CATALOGing the BackupSets :

[oracle@localhost2 2011_09_16]$ ls -l /tmp/*bkp
-rw-rw---- 1 oracle oracle 22072832 Sep 16 22:57 /tmp/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp
-rw-rw---- 1 oracle oracle 19456 Sep 16 22:57 /tmp/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp
[oracle@localhost2 2011_09_16]$
[oracle@localhost2 2011_09_16]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Sep 16 22:58:59 2011

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

connected to target database: ORCL (DBID=1229390655)

RMAN> catalog start with '/tmp/';

using target database control file instead of recovery catalog
searching for all files that match the pattern /tmp/

List of Files Unknown to the Database
=====================================
File Name: /tmp/hsperfdata_oracle/2469
File Name: /tmp/.X0-lock
File Name: /tmp/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp
File Name: /tmp/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp

Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /tmp/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp
File Name: /tmp/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp

List of Files Which Where Not Cataloged
=======================================
File Name: /tmp/hsperfdata_oracle/2469
RMAN-07517: Reason: The file header is corrupted
File Name: /tmp/.X0-lock
RMAN-07517: Reason: The file header is corrupted

RMAN>

I can now restore the ArchiveLogs to /tmp (Note : The SET ARCHIVELOG DESTINATION command must be in a Run Block. It cannot be an independent command like a SET UNTIL) :

RMAN> list archivelog all;

specification does not match any archived log in the repository

RMAN> run
2> {
3> set ARCHIVELOG DESTINATION TO '/tmp';
4> restore archivelog sequence between 237 and 238;
5> }

executing command: SET ARCHIVELOG DESTINATION

Starting restore at 16-SEP-11
using channel ORA_DISK_1
using channel ORA_DISK_2

channel ORA_DISK_1: starting archived log restore to user-specified destination
archived log destination=/tmp
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=237
channel ORA_DISK_1: reading from backup piece /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp
channel ORA_DISK_2: starting archived log restore to user-specified destination
archived log destination=/tmp
channel ORA_DISK_2: restoring archived log
archived log thread=1 sequence=238
channel ORA_DISK_2: reading from backup piece /addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp
channel ORA_DISK_2: piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzx5_.bkp tag=TAG20110916T225318
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: piece handle=/addtl/oracle/flash_recovery_area/ORCL/backupset/2011_09_16/o1_mf_annnn_TAG20110916T225318_776rpzf6_.bkp tag=TAG20110916T225318
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 16-SEP-11

RMAN>
RMAN> list archivelog all;

List of Archived Log Copies for database with db_unique_name ORCL
=====================================================================

Key Thrd Seq S Low Time
------- ---- ------- - ---------
811 1 237 A 11-SEP-11
Name: /tmp/1_237_749171050.dbf

810 1 238 A 16-SEP-11
Name: /tmp/1_238_749171050.dbf


RMAN>


Why would I want to / need to restore ArchiveLogs to another location ?
a. On the alternate / test server I do not have the same mount point point for ArchiveLogs as the primary.
b. On the alternate / test server, the mount point is much smaller but I do have another mount point that has enough space to restore ArchiveLogs to.


Question : What other way(s) can be used to restore ArchiveLogs to another location ?

.
.
.

1 comment:

Hemant K Chitale said...

A comment received from Anonymous :

Probably You can set arch log dest parameter :).Regards GG