11g R2 RAC : AUTOLOCATE BACKUPS

During a restore operation, RMAN automatically performs the autolocation of backups. A channel connected to a specific node only attempts to restore files that were backed up to the node. For example, assume that example tablespace is backed up to the drive attached to node1, while tablespace users is backed up to the drive attached to node2. If you then allocate channels that connect to each node, then the channel connected to node1 can restore example tablespace (but not users), and the channel connected to node2 can restore users tablespace (but not example).
Let’s demonstrate in the two node RAC setup I have:
Overview :
– Create folder for backups on both the nodes with appropriate permissions.
– Take backup of example and users tablespaces on node1 and node2 by allocating channels explicitly
– Take users and example tablespaces offline in immediate mode so that they will need media recovery to come online.
– Restore both tablespaces from backups on node1 and node2 by allocating channels explicitly to corresponding instances
– Note that RMAN automatically finds out that backup for example is stored on node1 and backup for users is stored on node2
   and restores them from respective nodes.
Implementation:
– Create folder for backups on both the nodes with appropriate permissions.
[oracle]$mkdir /u01/app/oracle/oradata/orcl/backup
-- Take backup of example and users tablespaces on node1 and node2 by allocating channels explicitly
– Note that backup of tablespace example is created on node1 using channel c1
   and backup of tablespace users is created on node1 using channel c2
RMAN>  run {
             allocate channel c1 device type disk 
              format ‘/u01/app/oracle/oradata/orcl/backup/orcl%U.bak’ connect=’sys/oracle@orcl1′;
    allocate channel c2 device type disk 
              format ‘/u01/app/oracle/oradata/orcl/backup/orcl%U.bak’ connect=’sys/oracle@orcl2′;
    backup tablespace users, example;
  }
allocated channel: c1
channel c1: SID=57 instance=orcl1 device type=DISK
allocated channel: c2
channel c2: SID=46 instance=orcl2 device type=DISK
channel c1: specifying datafile(s) in backup set
input datafile file number=00005 name=+DATA/orcl/datafile/example.264.799999785
channel c2: specifying datafile(s) in backup set
input datafile file number=00004 name=+DATA/orcl/datafile/users.259.799999587
channel c1: finished piece 1 at 30-NOV-12
piece handle=/u01/app/oracle/oradata/orcl/backup/orcl0snrivk1_1_1.bak tag=TAG20121130T044136
channel c2: finished piece 1 at 30-NOV-12
piece handle=/u01/app/oracle/oradata/orcl0tnrivk1_1_1.bak tag=TAG20121130T044136
-- Take users and example tablespaces offline in immediate mode so that they will need media recovery to come online.
SQL>alter tablespace users offline immediate;
    alter tablespace example offline immediate;
    alter system switch logfile;
    alter system switch logfile;
    alter system switch logfile;
    alter tablespace users online;
    alter tablespace example online;
ERROR at line 1:
ORA-01113: file 4 needs media recovery
ORA-01110: data file 4: ‘+DATA/orcl/datafile/users.259.799999587′
ERROR at line 1:
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: ‘+DATA/orcl/datafile/example.264.799999785′
– Restore both tablespaces from backups on node1 and node2 by allocating channels explicitly to corresponding instances
– Note that RMAN automatically finds out that backup for example is stored on node1 and backup for users is stored on node2
   and restores them from respective nodes.
RMAN>  run {
             allocate channel c1 device type disk 
               connect=’sys/oracle@orcl1′;
    allocate channel c2 device type disk 
              connect=’sys/oracle@orcl2′;
    restore tablespace users, example;
  }
allocated channel: c1
channel c1: SID=57 instance=orcl1 device type=DISK
allocated channel: c2
channel c2: SID=46 instance=orcl2 device type=DISK
channel c1: restoring datafile 00005 to +DATA/orcl/datafile/example.264.799999785
channel c1: reading from backup piece /u01/app/oracle/oradata/orcl/backup/orcl0snrivk1_1_1.bak
channel c2: restoring datafile 00004 to +DATA/orcl/datafile/users.259.799999587
channel c2: reading from backup piece /u01/app/oracle/oradata/orcl/backup/orcl0tnrivk1_1_1.bak
– Recover tablespaces and bring them online
RMAN>recover tablespace example, users;
SQL>  alter tablespace example online;

             alter tablespace users online;
I hope you found the article useful. Keep visiting the blog …
———————————————————————
Related links:

8 thoughts on “11g R2 RAC : AUTOLOCATE BACKUPS

  1. Hi,

    I have 3 node RAC and i have set archive log destination as their non shared local mount points (instead of a shared ASM disk group) to do some tests.

    Could you please look into my test case and let me know the reasons why it is failing at recovery though i have all the required backup pieces and archive logs.

    My test case:
    =============
    SQL> create tablespace TBS1 datafile ‘+DATA’ size 100m;

    Tablespace created.

    SQL> create table tbl1 tablespace TBS1 as select * from dba_objects;

    Table created.

    #I could able to take backup database/tablespaces including archive logs of all nodes( generated in their local mount points) from one node with the below command.

    rman target /

    RMAN> run {
    Allocate channel c1 device type disk FORMAT ‘/opt/oracle/BKP/%U’ connect=’sys/syspwd@RAC1′;
    Allocate channel c2 device type disk FORMAT ‘/opt/oracle/BKP/%U’ connect=’sys/syspwd@RAC2′;
    Allocate channel c3 device type disk FORMAT ‘/opt/oracle/BKP/%U’ connect=’sys/syspwd@RAC3′;
    Backup tablespace plus archivelog all;
    Release channel c1;
    Release channel c2;
    Release channel c3;
    }

    3 channels (c1,c2 and c3) were allocated to 3 nodes (RAC1,RCA2 and RAC3) respectively.

    C1 channel took the backup of thread 1 archive logs.
    C2 channel took the backup of thread 2 archive logs.
    C3 channel took the backup of thread 3 archive logs.
    tablespace backup also success.

    SQL> alter tablespace tbs1 offline immediate;

    Tablespace altered.

    SQL> alter system switch logfile; ## Executed this switch cmd from all nodes to generated few archive logs to see rman channels are able to read or not if necessary.

    System altered.

    SQL> /

    System altered.

    SQL> alter tablespace tbs1 online;
    alter tablespace tbs1 online
    *
    ERROR at line 1:
    ORA-01113: file 41 needs media recovery
    ORA-01110: data file 41: ‘+DATA/clrprd/datafile/tbs1.262.883670021′

    Now i tried restore of a tablespace with the below cmd and it is able to restore successfully.
    run {
    Allocate channel c1 device type disk FORMAT ‘/opt/oracle/BKP/%U’ connect=’sys/syspwd@RAC1′;
    Allocate channel c2 device type disk FORMAT ‘/opt/oracle/BKP/%U’ connect=’sys/syspwd@RAC2′;
    Allocate channel c3 device type disk FORMAT ‘/opt/oracle/BKP/%U’ connect=’sys/syspwd@RAC3′;
    resote tablespace TBS1;
    Release channel c1;
    Release channel c2;
    Release channel c3;
    }

    But when i am trying to do recovery from node1 (RCA1) with the below cmd , it is able to extract the required archive logs from the backup pieces of all nodes, FAILED to parse the archive log files of node2.

    run {
    Allocate channel c1 device type disk FORMAT ‘/opt/oracle/BKP/%U’ connect=’sys/syspwd@RAC1′;
    Allocate channel c2 device type disk FORMAT ‘/opt/oracle/BKP/%U’ connect=’sys/syspwd@RAC2′;
    Allocate channel c3 device type disk FORMAT ‘/opt/oracle/BKP/%U’ connect=’sys/syspwd@RAC3′;
    recover tablespace TBS1;
    Release channel c1;
    Release channel c2;
    Release channel c3;
    }

    Error messages:

    RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile ‘/opt/oracle/BKP/2_22253_861246577.arc’

  2. Thanks for the post. It means no need to catalog the backups, Were the backups identified automatically?

    Here i have one more question, Lets say i have backups of examples and users tablespaces of today and yesterday. Now i want to restore the tablespaces. Which backup Oracle will restore is it today’s or yesterday’s and how oracle identifies which backups need to restore.

    1. You still need to catalog the backups. The catalog does not contain the info regarding the node which stores the backup file. RMAN will automatically identify which node has which backup.

      By default RMAN will always restore the latest backup.

Leave a Reply to Anju Garg Cancel reply