learn-oracle

Oracle DBA






Oracle DBA - RMAN Backup and Recovery


What is RMAN(Recovery Manager) ?
Recovery Manager (RMAN) is an Oracle provided 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 your ORACLE_HOME/bin directory. In fact, RMAN, is just a Pro*C application that translates commands to a PL/SQL interface. The PL/SQL calls are statically linked into the Oracle kernel, and does not require the database to be opened.

What are the Benefits of RMAN ?
  • 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

What is Recovery Catalog ?
Recovery catalog holds RMAN repository data for one or more databases in a separate database schema, in addition to using the control files of the databases.

Start by creating a database schema (usually called rman). Assign an appropriate tablespace to it and grant it the recovery_catalog_owner role. Look at this example:

sqlplus sys/ as sysdba
SQL> create user rman identified by rman;
SQL> alter user rman default tablespace tools temporary tablespace temp;
SQL> alter user rman quota unlimited on tools;
SQL> grant connect, resource, recovery_catalog_owner to rman;
SQL> exit;

Next, log in to rman and create the catalog schema. Prior to Oracle 8i this was done by running the catrman.sql script.

> rman catalog rman/rman
RMAN> create catalog tablespace tools;
RMAN> exit;
You can now continue by registering your databases in the catalog. Look at this example:

rman catalog rman/rman target backdba/backdba
RMAN> register database;

How to do Offline backups with RMAN ?
RMAN can be used for offline backups regardless if the database is in ARCHIVELOG or NOARCHIVELOG mode.

SQL> select LOG_MODE from v$database;
LOG_MODE
------------
NOARCHIVELOG

1 row selected.

Ensure the database is in MOUNT mode

Shutdown the database and start the instance in mount mode:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area  209715200 bytes
Fixed Size                  1289748 bytes
Variable Size             138412524 bytes
Database Buffers           67108864 bytes
Redo Buffers                2904064 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options

Use RMAN to backup

Now, let's use RMAN to backup the database:

$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed May 30 20:23:56 2007
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: O10GR2 (DBID=1094333359, not open)

RMAN> backup database;

Starting backup at 30-MAY-07
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/app/oracle/product/10.2.0/db_1/oradata/o10gr2/system01.dbf
input datafile fno=00003 name=/app/oracle/product/10.2.0/db_1/oradata/o10gr2/sysaux01.dbf
input datafile fno=00005 name=/app/oracle/product/10.2.0/db_1/oradata/o10gr2/example01.dbf
input datafile fno=00004 name=/app/oracle/product/10.2.0/db_1/oradata/o10gr2/users01.dbf
input datafile fno=00002 name=/app/oracle/product/10.2.0/db_1/oradata/o10gr2/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 30-MAY-07
channel ORA_DISK_1: finished piece 1 at 30-MAY-07
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 30-MAY-07
channel ORA_DISK_1: finished piece 1 at 30-MAY-07
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 30-MAY-07

How to do online backup with RMAN
RMAN can only take online backups if the database is in ARCHIVELOG mode.

SQL> select LOG_MODE from v$database;
LOG_MODE
------------
ARCHIVELOG

1 row selected.

Ensure the database is running

Ensure your database is up and running before starting the on-line backup:

SQL> startup;
ORACLE instance started.
Total System Global Area  209715200 bytes
Fixed Size                  1289748 bytes
Variable Size             138412524 bytes
Database Buffers           67108864 bytes
Redo Buffers                2904064 bytes
Database mounted.
Database opened.
SQL> exit;

Use RMAN to backup

Now, let's use RMAN to backup the database:

$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed May 30 20:32:56 2007
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: O10GR2 (DBID=1094333359)
RMAN> backup database;

Starting backup at 30-MAY-07
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/app/oracle/product/10.2.0/db_1/oradata/o10gr2/system01.dbf
input datafile fno=00003 name=/app/oracle/product/10.2.0/db_1/oradata/o10gr2/sysaux01.dbf
input datafile fno=00005 name=/app/oracle/product/10.2.0/db_1/oradata/o10gr2/example01.dbf
input datafile fno=00004 name=/app/oracle/product/10.2.0/db_1/oradata/o10gr2/users01.dbf
input datafile fno=00002 name=/app/oracle/product/10.2.0/db_1/oradata/o10gr2/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 30-MAY-07
channel ORA_DISK_1: finished piece 1 at 30-MAY-07
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:26
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 30-MAY-07
channel ORA_DISK_1: finished piece 1 at 30-MAY-07
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 30-MAY-07

Want to see more FAQ..SEE TOP MENU

More Tutorials on Oracle dba ...


Liked it ? Want to share it ? Social Bookmarking

Add to: Mr. Wong Add to: BoniTrust Add to: Newsider Add to: Digg Add to: Del.icio.us Add to: Reddit Add to: Jumptags Add to: StumbleUpon Add to: Slashdot Add to: Netscape Add to: Furl Add to: Yahoo Add to: Spurl Add to: Google Add to: Blinklist Add to: Technorati Add to: Newsvine Information


Source : Website | Oracle DBA

Want to share or request Oracle Tutorial articles to become a Oracle DBA. Direct your requests to webmaster@oracleonline.info





FAQ

What is RMAN?

What are the benefits of RMAN?

What is Recovery Catalog?

How to do offline backup with RMAN?

How to do online backup with RMAN?