Wednesday, March 21, 2012

RMAN switch to copy

If a copy of datafile is available, the restore downtime can be minimized with SWITCH TO COPY


SQL> alter database datafile 7 offline;

Database altered.


RMAN> list copy;

specification does not match any control file copy in the repository
List of Datafile Copies
=======================

Key     File S Completion Time Ckp SCN    Ckp Time
------- ---- - --------------- ---------- ---------------
2       1    A 21-MAR-12       1961992    21-MAR-12
        Name: +FRA/oratest/datafile/system.284.778509743
        Tag: TAG20120321T124222

3       2    A 21-MAR-12       1962026    21-MAR-12
        Name: +FRA/oratest/datafile/sysaux.282.778509799
        Tag: TAG20120321T124222

5       3    A 21-MAR-12       1962058    21-MAR-12
        Name: +FRA/oratest/datafile/undotbs1.263.778509849
        Tag: TAG20120321T124222

7       4    A 21-MAR-12       1962065    21-MAR-12
        Name: +FRA/oratest/datafile/users.292.778509863
        Tag: TAG20120321T124222

4       5    A 21-MAR-12       1962052    21-MAR-12
        Name: +FRA/oratest/datafile/example.300.778509833
        Tag: TAG20120321T124222

6       6    A 21-MAR-12       1962061    21-MAR-12
        Name: +FRA/oratest/datafile/tab.291.778509855
        Tag: TAG20120321T124222

8       7    A 21-MAR-12       1962067    21-MAR-12
        Name: +FRA/oratest/datafile/drop_tbs.293.778509865
        Tag: TAG20120321T124222

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

Key     Thrd Seq     S Low Time
------- ---- ------- - ---------
21      1    34      A 19-MAR-12
        Name: +FRA/oratest/archivelog/2012_03_20/thread_1_seq_34.283.778415739

22      1    35      A 20-MAR-12
        Name: +FRA/oratest/archivelog/2012_03_20/thread_1_seq_35.279.778419185

23      1    36      A 20-MAR-12
        Name: +FRA/oratest/archivelog/2012_03_20/thread_1_seq_36.278.778419207

24      1    37      A 20-MAR-12
        Name: +FRA/oratest/archivelog/2012_03_20/thread_1_seq_37.275.778419953

25      1    38      A 20-MAR-12
        Name: +FRA/oratest/archivelog/2012_03_21/thread_1_seq_38.271.778501521

26      1    39      A 21-MAR-12
        Name: +FRA/oratest/archivelog/2012_03_21/thread_1_seq_39.270.778502477

27      1    40      A 21-MAR-12
        Name: +FRA/oratest/archivelog/2012_03_21/thread_1_seq_40.269.778506097

28      1    41      A 21-MAR-12
        Name: +FRA/oratest/archivelog/2012_03_21/thread_1_seq_41.268.778508691


RMAN> switch datafile 7 to copy;

datafile 7 switched to datafile copy "+FRA/oratest/datafile/drop_tbs.293.778509865"

RMAN> recover datafile 7;

Starting recover at 21-MAR-12
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 21-MAR-12

Move back the datafile in original path with datafile copy



RMAN> backup as copy datafile 7 format '+DATA';

Starting backup at 21-MAR-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=+FRA/oratest/datafile/drop_tbs.293.778509865
output file name=+DATA/oratest/datafile/drop_tbs.269.778510537 tag=TAG20120321T125535 RECID=9 STAMP=778510536
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 21-MAR-12

Starting Control File and SPFILE Autobackup at 21-MAR-12
piece handle=+FRA/oratest/autobackup/2012_03_21/s_778510537.298.778510539 comment=NONE
Finished Control File and SPFILE Autobackup at 21-MAR-12

RMAN> switch datafile 7 to copy;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of switch to copy command at 03/21/2012 12:55:50
RMAN-06572: database is open and datafile 7 is not offline

RMAN> sql 'alter database datafile 7 offline';

sql statement: alter database datafile 7 offline

RMAN> switch datafile 7 to copy;

datafile 7 switched to datafile copy "+DATA/oratest/datafile/drop_tbs.269.778510

RMAN> recover datafile 7;

Starting recover at 21-MAR-12
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 21-MAR-12

RMAN> sql 'alter database datafile 7 online';

sql statement: alter database datafile 7 online

RMAN> exit

No comments:

Post a Comment