RMAN in Oracle
Oracle Recovery Manager (RMAN)
RMAN was introduced in Oracle8, RMAN has since
been enhanced (in Oracle 9i), enhanced (in Oracle
10g) and enhanced (in Oracle 11g).
Recovery Manager(RMAN) is an Oracle provided (free) utility for backing-up, restoring and
recovering Oracle databases. RMAN ships with the Oracle database and doesn't require a
separate installation. The RMAN executable is located in $ORACLE_HOME/bin directory.
RMAN is a Pro*C application that translates commands to a PL/SQL interface through RPC
(Remote Procedure Call). The PL/SQL calls are statically linked into the Oracle kernel, and
does not require the database to be opened (mapped from the ?/rdbms/admin/recover.bsq
file).
The RMAN environment consists of the utilities and databases that play a role in backing up
our data. At a minimum, the environment for RMAN must include the following:
The target database to be backed up.
The RMAN client (rman executable and recover.bsq), which interprets backup and
recovery commands, directs server sessions to execute those commands, and records our
backup and recovery activity in the target database control file.
Some environments will also use these optional components:
A recovery catalog database, a separate database schema used to record RMAN
activity against one or more target databases (this is optional, but highly recommended).
A flash recovery area, called as fast recovery area from 11g release2, a disk location
in which the database can store and manage files related to backup and recovery.
Media management software, required for RMAN to interface with backup devices
such as tape drives.
Large pool (LARGE_POOL_SIZE) is used for RMAN.
Benefits of RMAN
Some of the benefits provided by RMAN include:
Backups are faster and uses less tapes (RMAN will skip empty blocks)
Less database archiving while database is being backed-up
RMAN checks the database for block corruptions
Automated restores from the catalog
Files are written out in parallel instead of sequential
RMAN can be operated from Oracle Enterprise Manager, or from command line. Here are
the command line arguments:
Argument
Value
Description
target
quoted-string connect-string for target database
catalog
quoted-string connect-string for recovery catalog
nocatalog
none
cmdfile
quoted-string name of input command file
log
quoted-string name of output message log file
trace
quoted-string name of output debugging message log file
One (base) recovery catalog can manage multiple target databases. All the target databases
should be register with the catalog.
Start by creating a database schema (usually named rman), in catalog database. Assign an
appropriate tablespace to it and grant it the recovery_catalog_owner role.
$ sqlplus "/as sysdba"
SQL> create user rman identified by rman default tablespace rmants quota unlimited on
rmants;
SQL> grant resource, recovery_catalog_owner to rman;
No need to grant connect role explicitly, because recovery_catalog_owner role has it.
Log in to catalog database with rman and create the catalog.
$ rman catalog rman/rman
RMAN> create catalog;
RMAN> exit;
Now you can continue by registering your databases in the catalog.
A virtual private catalog is a set of synonyms and views that enable user access to a subset
of a base recovery catalog. The owner of the base recovery catalog can GRANT or REVOKE
restricted access to the catalog to other database users. Each restricted user has full
read/write access to his own metadata, which is called a virtual private catalog. The RMAN
metadata is stored in the schema of the virtual private catalog owner. The owner of the base
recovery catalog controls what each virtual catalog user can access.
$ sqlplus "/as sysdba"
SQL> create user vpc identified by vpc default tablespace rmants quota unlimited on
rmants;
SQL> grant resource, recovery_catalog_owner to vpc;
Log in to catalog database with rman and grant the catalog to vpc.
$ rman catalog rman/rman
RMAN> GRANT CATALOG FOR DATABASE target_db TO vpc;
RMAN> exit;
Log in to catalog database with vpc and create the virtual private catalog.
$ rman catalog vpc/vpc
RMAN> CREATE VIRTUAL CATALOG;
RMAN> exit;
$ sqlplus vpc/vpc
SQL>exec rman.DBMS_RCVCAT.CREATE_VIRTUAL_CATALOG;
Recovery Manager commands
ADVISE FAILURE
Will display repair options for the specified failures. 11g
R1 command.
ALLOCATE
Establish a channel, which is a connection between RMAN
and a database instance.
ALTER DATABASE Mount or open a database.
BACKUP
Backup database, tablespaces, datafiles, control files,
spfile, archive logs.
BLOCKRECOVER
Will recover the corrupted blocks.
CATALOG
Add information about file copies and user-managed
backups to the catalog repository.
CHANGE
Update the status of a backup in the RMAN repository.
CONFIGURE
To change RMAN settings.
CONNECT
Establish a connection between RMAN and a target,
auxiliary, or recovery catalog database.
CONVERT
Convert datafile formats for transporting tablespaces and
databases across platforms.
CREATE CATALOG Create the base/virtual recovery catalog.
CREATE SCRIPT
Create a stored script and store it in the recovery
catalog.
CROSSCHECK
Check whether backup items still exist or not.
DELETE
Delete backups from disk or tape.
DELETE SCRIPT
Delete a stored script from the recovery catalog.
DROP CATALOG
Remove the base/virtual recovery catalog.
DROP DATABASE Delete the target database from disk and unregisters it.
DUPLICATE
Use backups of the target database to create a duplicate
database that we can use for testing purposes or to
create a standby database.
EXECUTE SCRIPT Run an RMAN stored script.
EXIT or QUIT
Exit/quit the RMAN console.
FLASHBACK
DATABASE
Return the database to its state at a previous time or
SCN.
GRANT
Grant privileges to a recovery catalog user.
HOST
Invoke an operating system command-line subshell from
within RMAN or run a specific operating system
command.
IMPORT CATALOG
Import the metadata from one recovery catalog into
another recovery catalog.
LIST
List backups and copies.
PRINT SCRIPT
Display a stored script.
RECOVER
Apply redo logs or incremental backups to a restored
backup set in order to recover it to a specified time.
REGISTER
Register the target database in the recovery catalog.
RELEASE
CHANNEL
Release a channel that was allocated.
REPAIR FAILURE
Will repair database failures identified by the Data
Recovery Advisor. 11g R1 command.
Replace an existing script stored in the recovery catalog.
REPLACE SCRIPT If the script does not exist, then REPLACE SCRIPT creates
it.
REPORT
Report backup status - database, files, backups.
Inform RMAN that the SQL statement ALTER DATABASE
OPEN RESETLOGS has been executed and that a new
RESET DATABASE
incarnation of the target database has been created, or
reset the target database to a prior incarnation.
RESTORE
Restore files from RMAN backup.
Perform a full resynchronization, which creates a
snapshot control file and then copies any new or changed
RESYNC CATALOG
information from that snapshot control file to the
recovery catalog.
REVOKE
Revoke privileges from a recovery catalog user.
RUN
To run set of RMAN commands, only some RMAN
commands are valid inside RUN block.
SEND
Send a vendor-specific quoted string to one or more
specific channels.
SET
Settings for the current RMAN session.
SHOW
Display the current configuration.
SHUTDOWN
Shutdown the database.
SPOOL
To direct RMAN output to a log file.
SQL
Execute a PL/SQL procedure or SQL statement (not
SELECT).
STARTUP
Startup the database.
SWITCH
Specify that a datafile copy is now the current datafile,
that is, the datafile pointed to by the control file.
TRANSPORT
TABLESPACE
Create transportable tablespace sets from backup for one
or more tablespaces.
UNREGISTER
Unregister a database from the recovery catalog.
UPGRADE
CATALOG
Upgrade the recovery catalog schema from an older
version to the version required by the RMAN executable.
VALIDATE
To validate. 11g R1 command.
All RMAN commands executed through channels. A channel is a connection (session) from
RMAN to target database. These connections or channels are used to perform the desired
operations.
Flash/Fast Recovery Area (FRA)
Flash recovery area is a disk location in which the database can store and manage files
related to backup and recovery.
To set the flash recovery area location and size,
use DB_RECOVERY_FILE_DEST and DB_RECOVERY_FILE_DEST_SIZE.
RMAN new features in Oracle 10g
Managing recovery related files with flash recovery area.
Optimized incremental backups using block change tracking (Faster incremental
backups) using a file (namedblock change tracking file). CTWR (Change Tracking Writer) is
the background process responsible for tracking the blocks.
Reducing the time and overhead of full backups with incrementally updated backups.
Comprehensive backup job tracking and administration with Enterprise Manager.
Backup set binary compression.
New compression algorithm BZIP2 brought in.
Automated Tablespace Point-in-Time Recovery.
Automatic channel failover on backup & restore.
Cross-Platform tablespace conversion.
Ability to preview the backups required to perform a restore operation.
RMAN> restore database preview [summary];
RMAN> restore tablespace tbs1 preview;
RMAN new features in Oracle 11g Release 1
Multisection backups of same file - RMAN can backup or restore a single file in
parallel by dividing the work among multiple channels. Each channel backs up one file
section, which is a contiguous range of blocks. This speeds up overall backup and restore
performance, and particularly for bigfile tablespaces, in which a datafile can be sized
upwards of several hundred GB to TB's.
Recovery will make use of flashback logs in FRA (Flash Recovery Area).
Fast Backup Compression - in addition to the Oracle Database 10g backup
compression algorithm (BZIP2), RMAN now supports the ZLIB algorithm, which offers 40%
better performance, with a trade-off of no more than 20% lower compression ratio, versus
BZIP2.
RMAN> configure compression algorithm 'ZLIB' ;
Will backup uncommitted undo only, not committed undo.
Data Recovery Advisor (DRA) - quickly identify the root cause of failures; auto fix
or present recovery options to the DBA.
Virtual Private Catalog - a recovery catalog administrator can grant visibility of a
subset of registered databases in the catalog to specific RMAN users.
RMAN> grant catalog for database db-name to user-name;
Catalogs can be merged/moved/imported from one database to another.
New commands in RMAN
o
RMAN> list failure;
o
RMAN> list failure errnumber detail;
o
RMAN> advise failure;
o
RMAN> repair failure;
o
RMAN> repair failure preview;
o
RMAN> validate database; -- checks for corrupted blocks
o
RMAN> create virtual catalog;
RMAN new features in Oracle 11g Release2
The following are new clauses and format options for the SET NEWNAME command:A
single SET NEWNAME command can be applied to all files in a database or tablespace.
SET NEWNAME FOR DATABASE TO format;
SET NEWNAME FOR TABLESPACE tsname TO format;
# New format identifiers are as follows:
# %U - Unique identifier. data_D-%d_I-%I_TS-%N_FNO-%f
# %b - UNIX base name of the original datafile name. For example, if the original datafile
name was $ORACLE_HOME/data/tbs_01.f, then %b is tbs_01.f.
RMAN related views
Control File V$ View
Recovery Catalog View
View Describes
V$ARCHIVED_LOG
RC_ARCHIVED_LOG
Archived and
unarchived redo
logs
V$BACKUP_DATAFILE
RC_BACKUP_CONTROLFILE
Control files in
backup sets
V$BACKUP_CORRUPTION
RC_BACKUP_CORRUPTION
Corrupt block
ranges in datafile
backups
V$BACKUP_DATAFILE
RC_BACKUP_DATAFILE
Datafiles in
backup sets
V$BACKUP_FILES
RC_BACKUP_FILES
RMAN backups
and copies in the
repository
V$BACKUP_PIECE
RC_BACKUP_PIECE
Backup pieces
V$BACKUP_REDOLOG
RC_BACKUP_REDOLOG
Archived logs in
backups
V$BACKUP_SET
RC_BACKUP_SET
Backup sets
V$BACKUP_SPFILE
RC_BACKUP_SPFILE
Server parameter
files in backup
sets
V$DATAFILE_COPY
RC_CONTROLFILE_COPY
Control file copies
on disk
V$COPY_CORRUPTION
RC_COPY_CORRUPTION
Information about
datafile copy
corruptions
V$DATABASE
V$DATABASE_
BLOCK_CORRUPTION
RC_DATABASE
Databases
registered in the
recovery catalog
(RC_DATABASE)
or information
about the
currently
mounted
database
(V$DATABASE)
RC_DATABASE_
BLOCK_CORRUPTION
Database blocks
marked as
corrupt in the
most recent
RMAN backup or
copy
All database
V$DATABASE_INCARNATIO RC_DATABASE_INCARNATIO incarnations
N
N
registered in the
catalog
V$DATAFILE
RC_DATAFILE
All datafiles
registered in the
recovery catalog
V$DATAFILE_COPY
RC_DATAFILE_COPY
Datafile image
copies
V$LOG_HISTORY
RC_LOG_HISTORY
Historical
information about
online redo logs
V$OFFLINE_RANGE
RC_OFFLINE_RANGE
Offline ranges for
datafiles
V$PROXY_ARCHIVEDLOG
RC_PROXY_ARCHIVEDLOG
Archived log
backups created
by proxy copy
V$PROXY_CONTROLFILE
RC_PROXY_CONTROLFILE
Control file
backups created
by proxy copy
V$PROXY_DATAFILE
RC_PROXY_DATAFILE
Datafile backups
created by proxy
copy
V$LOG and V$LOGFILE
V$THREAD
V$RESTORE_POINT
-
RC_REDO_LOG
Online redo logs
for all
incarnations of
the database
since the last
catalog
resynchronization
RC_REDO_THREAD
All redo threads
for all
incarnations of
the database
since the last
catalog
resynchronization
RC_RESTORE_POINT
All restore points
for all
incarnations of
the database
since the last
catalog
resynchronization