Oracle, Life, etc.

Oracle, Life, etc.

Chapter 23 – Getting Started with Oracle Recovery Manager

Posted by mnsinger on September 13, 2006

Recovery Manager Features

  • Backup of database plus archive logs made since the backup will be able to survive any data loss as long as redo log groups, exist.
  • RMAN can backup:
    • Whole databases
    • Tablespaces
    • Datafiles
    • Controlfile
    • Spfile (static pfile cannot be backed up)
    • Archive logs
  • Online redo logs are only protected by multiplexing and cannot be backed up.
  • RMAN can create incremental backups, image copies or backupsets. Image copies cannot be written to tape.
  • RMAN validates the contents of blocks as it scans them which will detect block corruption if it occurs.
  • RMAN can be integrated with a tape backup library.

Recovery Manager Components

The RMAN Executable

  • Can be found in $ORACLE_HOME/bin and is named rman
  • RMAN connects to a db via a listener and server process, prompts for user commands and sends the commands to the instance to be executed.
  • RMAN can be run remotely so long as the versions of the RMAN executable and target database, match.
  • RMAN is implemented with the PL/SQL package DBMS_BACKUP_RESTORE. Since this package is kernelized, or part of the instance (stored in the SGA), you don’t need an open database to use RMAN. Other PL/SQL procedures are stored in the Data Dictionary, which means that you need an open database to use them.

The Target Database

  • The target database is the db that you intend to backup, or restore and recover and RMAN can only connect to one target at a time.
  • The controlfile of the target db stores information needed by RMAN:
    • Location of the datafiles
    • Backups that have been made in the past
    • RMAN’s persistent config settings
  • RMAN also writes to the controlfile of the target database to tell where the backups are written.
  • Still, if the target db is totally destroyed, including all copies of the controlfile, it will still be possible for RMAN to restore it, provided that RMAN has been configured correctly.

Server Processes and Channels

  • Whenever a backup or restore operation is initiated, then at least one “channel” is launched. Multiple channels will allow for parallelism.
    A channel is a server process that does the work of copying files.

    • A channel can be launched manually via ALLOCATE CHANNEL or RMAN can launch channels automatically by using configured settings.
  • Two types of channel processes exist:
    • Disk channels – backup or restore to disk
    • SBT channels – backup or restore to tape
  • Another server process is the polling process. This process monitors the progress of the backup or restore operation.

The RMAN Repository

  • The repository is always stored in the controlfile of the target database. There is also the option to store it in the Recovery Catalog database, as well.
  • The repository in the controlfile / Recovery Catalog tells:
    • Location of the datafiles
    • Backups that have been made in the past
    • RMAN’s persistent config settings
  • If the repository is lost, then it may be possible to rebuild it if the proper precautions have been taken.

The Recovery Catalog

  • The RMAN repository is always written to the target db’s controlfile, but it can also be written out to a separate Oracle database, called the Recovery Catalog.
  • Benefits of a Recovery Catalog
    • Enhances functionality
    • You are no longer dependent on the controlfile of the target db. What if controlfile is damaged / lost?
    • The Recovery Catalog can store RMAN scripts.
    • One Recovery Catalog can be used to store metadata for multiple databases.
    • There is no time limit to how long a Recovery Catalog can store metadata. The controlfile relies on the parameter: CONTROL_FILE_RECORD_KEEP_TIME.

Media Management Library

  • To use a tape library, the instance must be linked to a device driver supplied by the tape library vendor.
  • Once the driver is linked, it will be possible to launch channels of type SBT_TAPE.
  • The Oracle Backup Solutions Program (BSP) certifies tape products as being compatible with RMAN.

The Auxiliary Database

  • An auxiliary database is a new database created by RMAN from a backup of the target database.
  • The auxiliary db can be a complete restore of the target (identical copy) or a subset of the target (TSPITR – tablespace point in time recovery – where one tablespace is pushed back while the remainder of the db is the same).
  • An auxiliary db can also be used to create a standby db. A standby db is an exact replica, stored remotely which is continuously updated from the redo generation of the production db. In the event of a disaster, you can switch over to the standby db.

The Flash Recovery Area

  • The flash recovery area is used for all recovery and fault tolerance related files. RMAN uses is as a default location for backups. It is also used for redo logfiles, controlfiles, archivelogs and flashback.

Environment Variables and Instance Parameters

  • Environment variables like nls_date_format and nls_lang can effect RMAN decisions.
    • If the db is in mount mode then RMAN will determine settings from the controlfile.
    • If the db is in nomount or closed then it will take the values from the environment variables.
  • Three parameters within the instance may be of significance:
    • CONTROL_FILE_RECORD_KEEP_TIME – not very important if using the recovery catalog. The data will be transferred from controlfile to recovery catalog whenever RMAN connects to the target. It uses the RESYNC CATALOG command.
    • DB_RECOVERY_FILE_DEST – location of the flash recovery area. RMAN can apply retention policies to files in this area.
    • DB_RECOVERY_FILE_DEST_SIZE – if it fills up, then the db will hang.

Connecting to Databases

  • The rman executable can connect to local dbs or remote dbs
    • C:\> rman target sys/oracle@ocp10g catalog rman/rman@catdb
    • … is the same as …
    • C:\> rman
    • RMAN> connect target sys/oracle@ocp10g
    • connected to target database OCP10G (DBID=54237432)
    • RMAN> connect catalog rman/rman@catdb
    • connected to Recovery Catalog database

Configuring Persistent Settings

  • To see the current RMAN persistent settings type: SHOW ALL.

Channel Allocation

  • At least one channel must be allocated before a backup or restore can be executed.
  • Channels can be allocated for each backup/recovery operation or they can be configured with default settings for all operations.
  • Control Options:
    • Connect – the instance to which RMAN connects
    • Duration – controls the amount of time for the job, specified in hours and minutes
      • Minimize time – tells the job to run at full speed
      • Minimize load – tells the job to slow down if it is going to finish within the duration
      • Partial – allows RMAN to terminate a job that hasn’t finished within the duration without signalling an error
    • Format – path and filename with variables like %u or %d.
    • Maxopenfiles – limits number of input files that RMAN can open at once. default is 8.
    • Maxpiecesize – specified in bytes (default), kilobytes (k), megabytes (m) or gigabytes (g). restricts the size of pieces that the backup set is divided into
    • Parms – used to set variables for SBT_TAPE channel

What RMAN Will Back Up

  • RMAN can exclude certain dbs by using exclude:
    • RMAN> configure exclude for tablespace example;
  • RMAN will also exclude dbs that have not changed since the last backup if optimization is turned on.
    • RMAN> configure backup optimization on;
  • If RMAN is not configured to backup the controlfile and all copies are lost, then the target db will never get past the NOMOUNT state and recovery will be impossible.

Configuring Retention of Backups

  • The default configuration is redundancy 1 which means that RMAN will always attempt to have one backup of every datafile, archive log and controlfile. Delete obsolete will delete all datafile & controlfile copies but not archive logs.
  • It is also possible to set the retention policy to none which will disable automatic deletion aka obsolete files.

Overriding Configured Defaults

  • Defaults can be overridden inside of run braces { … }

Parameters

  • CONTROL_FILE_RECORD_KEEP_TIME – how long the controlfile will keep metadata. Defaults to 7 days.

Views & Tables

  • g

3 Responses to “Chapter 23 – Getting Started with Oracle Recovery Manager”

  1. Minh said

    Can you post all your chapters in 1 place for easy printing or download? 1 zip file is good.

    Do you mind having other people make use of your chapters?

    They are very organize and useful.

    Thanks

  2. Dahi said

    I agree with Minh. Very well organized notes. They’ve come in very handy.

    A cumulative pdf would be the icing on the cake.

    Thanks.

  3. After reading the article, I feel that I really need more information on the topic. Can you share some more resources ?

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>