RMAN: RAC Backup and Recovery using RMAN [ID 243760.1] Metalink

"Checked for relevance on 21-Dec-2008"

 

RAC Backup and Recovery using RMAN

 

Objectives:

===========

 

1. Verify the database mode and archive destination.

2. Verify connectivity using sqlnet for target and catalog.

3. Determine your backup device

4. Understand how to create an RMAN persistent configuration for a RAC env.

5. Create backups to disk using

6. Backupset Maintenance using the configured retention policy

7. Restore and Recover

    a. complete

    b. incomplete

8. Review and understand the impact of resetlogs on the catalog.

9. RMAN Sample Commands

 

 

 

Configuration:

==============

 

This discussion is for a 2-node Oracle RAC Cluster.

The logs are being archived to their respective node.

We are allocating channels to each node to enable the autolocate feature

of RMAN in a RAC env.

 

 

1. Verify the databases are in archivelog mode and archive destination.

 

 a. NODE 1: thread 1

 

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u02/app/oracle/product/9.2.0/dbs/arch

Oldest online log sequence     20

Next log sequence to archive   21

Current log sequence           21

 

 b. NODE 2: thread 2

 

SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u02/app/oracle/product/9.2.0/dbs/arch

Oldest online log sequence     8

Next log sequence to archive   9

Current log sequence           9

 

 

2. Verify connectivity to the target nodes and catalog if used.

 

 a. % setenv TNS_ADMIN $ORACLE_HOME/network/admin

 b. % sqlplus /nolog

 c. SQL> connect sys/pwd@node1 as sysdba

 d. SQL> connect sys/pwd@node2 as sysdba

 e. SQL> connect rman/rman@rcat

 

3. Set your testing areas.

 

Testing HOME for logs:  /u02/home/usupport/rman

 

Backups HOME Location:  /rman/V920

 

 

4. Connect using RMAN to verify and set the controlfile persistent configuration.

   The controlfiles are shared between the instances so configuring the control-

   file on node 1 also sets it for all nodes in the RAC cluster.

 

 a. Alway note the target DBID

     connected to target database: V920 (DBID=228033884)

 

 b. Default Configuration

 

RMAN configuration parameters are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default

CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u02/app/oracle/product/9.2.0/dbs/snapcf_V9201.f'; # default

 

 

 c. Make changes to the default that fit your business requirements.

    Note the retention policy can be set "TO REDUNDANCY x" or it can

    be set "TO RECOVERY WINDOW OF x DAYS", this is new in Oracle9i.

 

    In this example, using PARALLELISM 2 as 2 nodes are used.

    The PARALLELISM will than automaticly start 2 channels and will

    use the related CONFIGURE CHANNEL for additional clauses.

 

CONFIGURE RETENTION POLICY TO REDUNDANCY 3;

CONFIGURE BACKUP OPTIMIZATION OFF;

CONFIGURE DEFAULT DEVICE TYPE TO DISK;

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/rman/V920/%F';

CONFIGURE DEVICE TYPE DISK PARALLELISM 2;

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;

CONFIGURE MAXSETSIZE TO UNLIMITED;

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/rman/V920/snapcf_V92321.f';

CONFIGURE CHANNEL 1 DEVICE TYPE DISK connect 'SYS/rac@node1';

CONFIGURE CHANNEL 2 DEVICE TYPE DISK connect 'SYS/rac@node2';

 

 

 d. Review/Verify your new configuration.

 

RMAN configuration parameters are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 3;

CONFIGURE BACKUP OPTIMIZATION OFF;

CONFIGURE DEFAULT DEVICE TYPE TO DISK;

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/rman/V920/%F';

CONFIGURE DEVICE TYPE DISK PARALLELISM 2;

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;

CONFIGURE CHANNEL 1 DEVICE TYPE DISK CONNECT  'SYS/rac@node1';

CONFIGURE CHANNEL 2 DEVICE TYPE DISK CONNECT  'SYS/rac@node2';

CONFIGURE MAXSETSIZE TO UNLIMITED;

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/rman/V920/snapcf_V92321.f';

 

 

5. Make a backup using the new persistent configuration parameters.

 

 a. Backup database with differential incremental 0 and then archived logs

    using the delete input option.

 

 

 backup incremental level 0

 format '/rman/V920/%d_LVL0_%T_%u_s%s_p%p'

 database;

 backup archivelog all format '/rman/V920/%d_AL_%T_%u_s%s_p%p'

 delete input;

 

 

 b. Backup again using differential inremental level 1

 

 

 backup incremental level 1

 format '/rman/V920/%d_LVL1_%T_%u_s%s_p%p'

 database;

 backup archivelog all format '/rman/V920/%d_AL_%T_%u_s%s_p%p'

 delete input;

 

 

 c. To simplify this in Oracle9i we can also use PLUS ARCHIVELOG

    Note: This uses a different alorithm then backup database and

    backup archivelog in separate commands.

 

 BACKUP incremental level 0

 format '/rman/V920/%d_LVL0_%T_%u_s%s_p%p'

 database PLUS ARCHIVELOG format '/rman/V920/%d_AL_%T_%u_s%s_p%p'

 delete input;

 

  Algorithm for PLUS ARCHIVELOG:

 

    1. Archive log current

    2. Backup archived logs

    3. Backup database level 0

    4. Archive log current

    5. Backup any remaining archived log created during backup

 

 

6. Backupset Maintenance using the configured retention policy

 

    RMAN> list backup summary;

          list backup by datafile;

          list backup of database;

          list backup of archivelog all;

          list backup of controlfile;

 

 Note: these above can be enhanced with the "until time" clause as well as

       the archivelog backups using "not backed up x times" to cut down on

       many copies of a log in several backupsets. Then continuing with SMR

       Server Managed Recovery use the change archivelog from...until...delete

       to remove old logs no longer needed on disk.

 

    RMAN> report obsolete;

 

    RMAN> delete obsolete;

          or

          delete noprompt obsolete;

 

    RMAN> report schema;

 

 

7. Restore and Recover

 

Complete Recovery

 

 a. With the database mounted on the node1 and nomount on node2 connect

    to the target and catalog using RMAN.

 

      rman target / catalog rman/rman@rcat

 

    This script will restore and recover the database completely and open.

    All previous backup will still be available for use because there was

    not RESETLOGS command given.

 

 run {

     restore database;

     recover database;

     alter database open;

     }

 

Incomplete Recovery

 

Note: If you are using instance registration the database must be mounted to

      register with the listener. This means you must use the current control

      file for restore and recovery or setup a dedicated listener if not

      already done. RMAN requires a dedicated server connection and does not

      work with using instance registration before mounting the controlfile.

      Using the autobackup controlfile feature requires the DBID of the

      TARGET database. It must be set when the database is not mounted and

      only the controlfile and spfile (in 9.2>) can be restored this way.

 

 

 a. shutdown node1 and node2

 

 b. startup nomount node2 and node1

 

 c. start rman

 

     > rman trace reco1.log

 

     RMAN> connect catalog rman/rman@rcat

 

     RMAN> set dbid=228033884;

 

     RMAN> connect target

 

 d. Restore the controlfile from autobackup

 

     % rman trace recocf.log

 

     RMAN> SET DBID=228033884;

 

     RMAN> CONNECT TARGET

 

 RUN

    {

     SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE disk TO '/rman/V920/%F';

      ALLOCATE CHANNEL d1 DEVICE TYPE disk;

       RESTORE CONTROLFILE FROM AUTOBACKUP

         MAXSEQ 5           # start at sequence 5 and count down (optional)

         MAXDAYS 5;         # start at UNTIL TIME and search back 5 days (optional)

     MOUNT DATABASE;

    }

 

 

 e. Verify what is available for incomplete recovery. We will recover to the

    highest scn log sequence and thread. We will use the log sequence in this

    case. Your options are "until time", "until scn", or "until sequence".

 

 

    SQL> select max(sequence#) from v$archived_log

      2  where thread#=1;

 

 MAX(SEQUENCE#)

 --------------

             25

 

    SQL> select max(sequence#) from v$archived_log

      2  where thread#=2;

 

 MAX(SEQUENCE#)

 --------------

             13

 

Note: In this case the scn is greater in thread 2 sequence# 13 then in

      sequence 25 from thread 1. So we will set the seqeunce to 14 for

      rman recovery because log recovery is always sequence+1 to end

      at +1 after applying the prior sequence.

 

 SQL> select sequence#, thread#, first_change#, next_change#

   2  from v$archived_log

   3  where sequence# in (13,25);

 

  SEQUENCE#    THREAD# FIRST_CHANGE# NEXT_CHANGE#

 ---------- ---------- ------------- ------------

         25          1       1744432      1744802

         13          2       1744429      1744805

 

 SQL> select sequence#, thread#, first_change#, next_change#

   2  from v$backup_redolog

   3  where sequence# in (13,25);

 

  SEQUENCE#    THREAD# FIRST_CHANGE# NEXT_CHANGE#

 ---------- ---------- ------------- ------------

         25          1       1744432      1744802

         13          2       1744429      1744805

 

 f. If using LMT Temporary tablespace the controlfile will have the syntax

    to add the tempfile after recovery is complete.

 

    SQL> alter database backup controlfile to trace;

 

 Example:

 # Commands to add tempfiles to temporary tablespaces.

 # Online tempfiles have complete s

你可能感兴趣的:(thread,oracle,sql,SQL Server,F#)