Oracle Recovery Manager (RMAN) concepts

June 27, 2016 by Leave a comment 

Recovery Manager (RMAN) is an Oracle utility that you use to manage the backup, restore, and recovery operations on Oracle database. RMAN has a powerful command language that is independent of the operating system.

Recovery Manager has a command-line interface. Oracle Enterprise Manager (OEM) also provides a graphical user interface for the Recovery Manager. Recovery Manager can be used on databases of Oracle8 or later releases.

RMAN provides several features not available when you make user-managed backups with operating system commands:

  • You can store frequently executed operations as scripts in the database.
  • Using the incremental block-level backup feature you can limit the backup to only those blocks that have changed since the previous backup. This may also reduce the time it takes to perform recovery operations in ARCHIVELOG mode.
  • You can use RMAN to manage the size of backup pieces and save time by parallelizing the backup operation.
  • RMAN operations can be integrated with the scheduling of the operating system to automate backup operations.
  • You can detect block corruption. The information relating to the block corruption that is detected during backup can be obtained by using the V$BACKUP_CORRUPTION and V$COPY_CORRUPTION dynamic views.
  • RMAN provides performance enhancements such as:

-Automatic parallelization of backup, restore, and recovery operations
-No generation of extra redo during online database backups
-Backups that are restricted to limit reads per file, per second to avoid interfering with OLTP work
-Prevention of flooding of any one file with reads and writes while still keeping a tape drive streaming, using multiplexing

  • RMAN has a media management API to work seamlessly with third-party media management tools interfacing with storage devices providing increased speed and reliability.
  • Under the user-managed method you need to keep track of all database files and backups. In a recovery situations you must locate backups for each datafile, copy them to the correct place using operating system commands, and choose which logs to apply. RMAN manages these tasks automatically.

Recovery Manager Components

Oracle recovery manager rman components

Oracle Recovery Manager (RMAN) components


The Recovery Manager command-line interface is invoked through the executable RMAN. RMAN interprets user commands and appropriately invokes server sessions to perform the desired tasks.

Server Sessions: The server processes (UNIX) or threads (Windows NT) invoked by RMAN connect to the target database to perform the backup, restore, and recovery functions through a PL/SQL interface.

Target Database: The database for which backup and recovery operations are being performed using RMAN is called the target database. The control file of the target database contains information about its physical structure, such as the size and location of datafiles, online and archived redo log files, and control files. This information is used by the server sessions invoked by RMAN in backup and recovery operations.

RMAN Repository: The data used by RMAN for backup, restore, and recovery operations is referred to as RMAN metadata. It is stored in the control file of the target database and in an optional recovery catalog database. The amount of information stored in the control file can increase depending on the frequency of backups, the number of archived redo log files that are generated, and the retention period for RMAN records. Use CONTROL_FILE_RECORD_KEEP_TIME parameter to specify the minimum number of days RMAN information is stored in the control file before being overwritten. A low value results in information being overwritten more frequently, thus minimizing control file growth. If a recovery catalog is used, a lower value should be chosen. The default is seven days. If the size of the control file is too small to store all the information for the time specified by CONTROL_FILE_RECORD_KEEP_TIME, then the control file grows.

Recovery Catalog:

Although it is not mandatory to create a recovery catalog to use RMAN, it is beneficial to use a recovery catalog. The recovery catalog should be located in a database different from the target database.

Channel: To perform and record backup and recovery operations, RMAN requires a link to the target database. This link is referred to as a channel and represent one stream of data to a device type. A channel must be allocated before you execute backup and recovery commands. Each allocated channel establishes a connection from the RMAN executable to a target or auxiliary database instance by starting a server session on the instance. This server session performs the backup and recovery operations. Each channel usually corresponds to one output device, unless your MML is capable of hardware multiplexing.
You can allocate channels manually or preconfigure channels using automatic channel allocation.

Oracle Recovery manager RMAN channel allocation

Oracle Recovery manager (RMAN) channel allocation

The ALLOCATE CHANNEL command with a RUN command and the ALLOCATE CHANNEL FOR MAINTENANCE command issued at the RMAN prompt are used to allocate a channel manually. Manual channel allocation overrides automatic allocation. In addition, you can configure a set of persistent, automatic channels. You specify automatic channels to disk or tape by using the CONFIGURE CHANNEL command.

RMAN provides a preconfigured DISK channel that you can use for backups and copies to disk.

Media Management Library: To use tape storage for your database backups, RMAN requires a media manager. A media manager library (MML) is additional media management software that loads, labels, and unloads sequential media, such as tape drives for the purpose of backing up, restoring, and recovering data. The Oracle server calls MML software routines to back up and restore datafiles to and from media that is controlled by the media manager.
Before you can begin using RMAN with a media manager, you must install it on the target database and make sure that RMAN can communicate with it. Instructions for this procedure should be available in the media manager vendor’s software documentation.

Oracle Recovery Manager RMAN media management

Oracle Recovery Manager (RMAN) media management

Types of Database Connections with RMAN

You can use Recovery Manager to connect to the following types of databases:

  • Target database: You are connected to the target database with the SYSDBA privilege. You must have this privilege for the connection to succeed.
  • Recovery catalog database: This is an optional database which is configured for the RMAN repository.
  • Auxiliary database: An auxiliary database is a database that is created using the RMAN DUPLICATE command. Or it may be a temporary database that is used during tablespace point-in-time recovery (TSPITR).

Connecting to the Target Database Without a Catalog

For a local RMAN connection, at an operating system prompt, enter the following:
UNIX: $ ORACLE_SID=DB01; export ORACLE_SID

$ rman target /

Windows: C:\> SET ORACLE_SID=DB01

C:\> rman target /

To connect from another server, use the net service name for the target database:

$ rman target sys/target_pwd@DB01

RMAN Modes and Commands

Recovery Manager acts as a command-line interpreter (CLI) with its own command language. There are two modes of operation with the RMAN: interactive and batch.

Interactive Mode: To run RMAN commands interactively, start RMAN and then type commands into the command-line interface. For example, you can start RMAN from the UNIX command shell and then execute interactive commands as follows:

$ rman target sys/sys_pwd
RMAN> backup database;

Batch Mode:
You can enter RMAN commands into a file, and then run the command file by specifying its name on the command line. The contents of the command file should be identical to commands entered at the command line. When running in batch mode, RMAN reads input from a command file and writes output messages to a log file (if specified) as follows:

$ rman target sys/sys_pwd @’$HOME/my_rman_script.rcv’ log $HOME/rman.log append

RMAN has two basic types of commands: stand-alone and job commands. Most of them can run in both modes though. Stand-alone commands are executed at the RMAN prompt and are generally self-contained. Following are some of the stand-alone commands:

connect
change
# report – analyze information in the RMAN repository in more detail.
report schema;
# show – display persistent configuration settings
show all;
# list – used to produce a detailed report about backups
list backup summary;
list backup;
list backup of controlfile;
create catalog, resync catalog
create script, delete script, replace script

The job commands are usually grouped and RMAN executes the job commands inside of a RUN command block sequentially.
If any command within the block fails, RMAN ceases processing; no further commands within the block are executed.
Following are examples of job commands:

allocate channel
switch

RMAN Configuration Settings

RMAN is preset with default configuration settings that apply to all RMAN sessions.
You can use the CONFIGURE command to configure persistent settings for RMAN backup, restore, duplication, and maintenance jobs. These settings are in effect for any RMAN session until the configuration is cleared or changed.
Examples are below:

configure retention policy to recovery window of 7 days;
configure retention policy to redundancy 2;
configure backup optimization on;
configure channel device type disk format ‘/u01/backup/%U’;
configure channel device type sbt_tape RATE 50M;

The SHOW command is used to to display persistent configuration settings specified with the CONFIGURE command:
show all;
show channel;
show device type;
show default device type;
show retention policy;

Recovery Manager Packages

Oracle Recovery manager RMAN packages

Oracle Recovery Manager (RMAN) packages

The RMAN executable uses PL/SQL packages to communicate with the target database and recovery catalog. The PL/SQL packages perform the following functions:

  • Maintain the RMAN repository in the control file or recovery catalog
  • Communicate with Oracle and the operating system to create, restore, and recover backup sets and image copies
  • Provide a consistent interface so that the RMAN executable can use either the recovery catalog or target database control file as its backup repository with no change in behavior

RMAN Usage Considerations

Before Recovery Manager is used, consider the following points:

  • Create, detail, test and document your backup / recovery strategy
  • Most of RMAN’s work is performed through Oracle server processes (often in parallel). This implies that the PROCESSES parameter must be sufficiently high.
  • You must decide on the set of users who perform privileged operations. Accordingly, you can set the users’ accounts with the necessary privileges at the operating system and at the Oracle database.
  • To start up and shut down a database, the user should have the SYSDBA privilege (or SYSBACKUP in 12c+)
  • You need to use a password file to connect to the target database remotely to perform privileged operations
  • Before invoking RMAN, set the NLS_DATE_FORMAT and NLS_LANG environment variables. These variables determine the format used for the time parameters in RMAN commands, such as RESTORE, RECOVER, and REPORT.
  • When you use a recovery catalog, RMAN can perform a wider variety of automated backup and recovery functions. Use of the recovery catalog involves storage space and maintenance efforts. You should also decide whether to have a database dedicated to maintain the recovery catalog of many target databases. Also consider the strategy to back up the recovery catalog.
  • RMAN can be used without extra costs but some of its features (like compression) need to be extra-licensed

RMAN backups

  • Backup modes: ARCHIVE or NOARCHIVE / mounted or open database
  • Backup items: entire database, all or single database file, tablespace, control files, all or selected archive redo logs, spfile
  • Types of backups: image copies of datafile, control file, or archived redo log file / backup sets
  • Backup ways: full backup, incremental or incremental cumulative backup, automatic backup of control and spfile

You might like to look at the other RMAN related articles:
Oracle RMAN full backup script to disk with compression
Oracle RMAN full backup script for EMC NetWorker
Oracle RMAN recovery script for EMC NetWorker

That was Oracle Recovery Manager (RMAN) concepts overview as startup for managing the database backup, restore, and recovery operations.

Enjoyed this article? Please share it with others using the social site of your choice:

Add a Comment

We welcome thoughtful and constructive comments from readers.
If you want your own picture to show with your comment?
Go get a Globally Recognized Avatar!

DBMS Blog Updates : Subscribe RSS RSS: Subscribe to Articles · Subscribe to Comments Subscribe RSS Receive site updates via email