Sunteți pe pagina 1din 6

RMAN

What is RMAN?
Recovery Manager as it is popularly called RMAN is a platform independent Oracle utility for coordinating Backup and Restoration procedure. This is integrated as a part of Oracle server software. RMAN binary resides at $ORACLE_HOME/bin/rman. RMAN is the Oracle recommended tool to take database backups. It can be used to backup datafiles and datafile image copies, control file and control file image copies, archived redo logs, spfile and RMAN backup pieces.

RMAN Architecture:
RMAN operates via server sessions connecting to target databases which are the databases that need to be backed up. The collection of information about the target database such as its schema information, backup copy information, configuration settings, backup and recovery scripts is called the RMAN repository. RMAN uses this metadata about the target databases to perform its backup and recovery activity. RMAN periodically retrieves information from the target database control file and saves it in the recovery catalog. Brief listings of entities that enable RMAN to perform its function are given below:

Target database:
This is the database that RMAN needs to back up. RMAN server sessions running in the target database perform backup and recovery operations.

RMAN Repository:
This is RMANs metadata about backups, archived redologs, and its own activities. The control file of each database is the primary storage for RMAN repository.

Recovery Catalog schema:


This is the database schema in the recovery catalog database that owns the RMAN backup and recovery metadata (the RMAN repository).

-1-

RMAN
RMAN Client:
RMAN operations can be managed through RMAN client sessions. It is a CLI (command line interface) through which backup, recover, sql, special RMAN commands are issued. Commands communicate with RMAN server and operations are performed. The client starts RMAN server sessions on target databases and directs them to perform backup and recovery operations. The RMAN client uses Oracle Net to connect to the target database. RMAN client can be located on any host that connects to the target host through Oracle Net.

RMAN executable:
This is the actual program that manages all backup and recovery operations. RMAN executable resides at $ORACLE_HOME/bin directory. It performs backup and recovery operations and records the results in the control file and optional recovery catalog.

Server Processes:
These are the background processes that facilitate the communication between the RMAN executable and the target database. The server process performs the real work of reading and writing to disk devices and tape drives during backup and recovery. Apart from this there are three optional entities including flash recovery area, the recovery catalog database (and the recovery catalog schema) and the media management software.

Media Management Software:


RMAN cannot backup directly to tape drives. An interface called MML(Media Management Layer) comes to picture and the software used for this purpose is the media management software.

Rman Recovery Catalog:


Oracle recommends the usage of recovery catalog with RMAN. Recovery catalog is a metadata repository that stores details on the backup sets of datafiles, control files, archived redo logs backups, spfile of the target databases. Recovery catalog is needed for efficient backup of any number of databases. We can use the control file to store details on database backup. The space allocated in control file is a constraint when the amount of metadata increases. RMAN scripts can be stored only in the recovery catalog not in the control file.

Why use RMAN :


No Extra Costs. It is available free. RMAN introduced in Oracle 8 it has become simpler with new version and easier that user managed backups. Proper Security You are 100% sure your database has been backed up. It contains details of backup taken in the central repository Facility of testing validity of backups also commands like cross check to check the status of backup.

-2-

RMAN

Oracle 10g has got further optimized incremental backups with has resulted in improvement of performance during backup and recovery time Parallel operation are supported Better Querying facility for knowing different details of backup. No Extra redo generated when backup is taken. compared to online backup Maintains repository of backup Knows what needs to be backed up metadata. Knows what is required for recovery Remembers backup locations Knows what backups are redundant Knows what needs backup set locations It handles database corruptions

Difference between RMAN and User-managed Backups:


A traditional User-managed backup uses operating system (OS) utilities to copy database files to relevant locations and/or tapes. On the other hand RMAN backups up the database files from with in the database with the help of Oracle database server. RMAN performs incremental backups, which back up only those data blocks that changed after a previous backup where as user-managed method Backs up all blocks, not just the changed blocks. During Backing up and restoring Rman checks for corrupt blocks but user-method does not provide any error checking.

Backup Using RMAN:


Create Recovery Catalog: First create a user to hold the recovery catalog:
Create tablepsace to hold repository SQL> create tablespace mrman datafile /u01/app/oradata/anand/mram.dbf 2 size 6m autoextend on next 2m maxsize 100m; Tablespace created.

Create rman schema owner SQL> create user mrman identified by mrman 2 temporary tablespace temp 3 default tablespace mrman 4 quota unlimited on mrman;
User created.

SQL> grant connect, resource, recovery_catalog_owner to mrman;


Grant succeeded.

-3-

RMAN
Create the recovery catalog:
$ rman catalog=mrman/mrman@anand
Recovery Manager: Release 10.2.0.3.0 - Production on Mon Aug 4 13:18:22 2008 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to recovery catalog database

RMAN> create catalog tablespace MRMAN;


recovery catalog created RMAN> exit Recovery Manager complete. $

Register Database: Each database to be backed up by RMAN must be registered:


$ rman catalog mrman/mrman@anand target sys/sys@monish
Recovery Manager: Release 10.2.0.3.0 - Production on Mon Aug 4 13:29:55 2008 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: MONISH (DBID=2166643499) connected to recovery catalog database

RMAN> register database; database registered in recovery catalog starting full resync of recovery catalog full resync complete RMAN>

To Backup automatic controlfile & spfile:


RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

To see all the parameters:


RMAN> show all;
RMAN configuration parameters are:

-4-

RMAN
Run the following sql command to see the database recovery file destination is configured or not.
SQL> show parameter db

..

NAME TYPE VALUE db_keep_cache_size big integer 0 db_name string monish db_recovery_file_dest string /u02/monish/backup

.. . If its not configured then run the following: to set the controlfile backup location
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO /u01/%F;
new RMAN configuration parameters: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO /u01/%F; new RMAN configuration parameters are successfully stored

to set the database backup location


RMAN>CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT = /u01/bkp/df0_%d_%s_%t;

To take the Backup: run { CROSSCHECK BACKUPSET; # To check available and expired backup sets. CROSSCHECK ARCHIVELOG ALL; # To check available and expired Archive Logs DELETE NOPROMPT EXPIRED BACKUP; # It will delete expired (old/not exists physically) backups DELETE NOPROMPT EXPIRED ARCHIVELOG ALL; # It will delete expired archive logs SQL ALTER SYSTEM ARCHIVE LOG CURRENT; # Switch Log BACKUP DATABASE PLUS ARCHIVELOG; # Backup the whole Database plus archive files DELETE NOPROMPT OBSOLETE; # It will remove old backups according to the redundancy period. } # End of Backup

Restore & Recovery using RMAN:


SQL> shut abort

-5-

RMAN
ORACLE instance shut down. SQL>

SQL> startup mount


SQL>

If the Datafile is crashed then do the following:


RMAN> restore datafile 1;
RMAN>

RMAN> recover database; RMAN> alter database open;


database opened

RMAN>

Examples: ~ Restore and recover the whole database:


RMAN> RMAN> RMAN> RMAN> STARTUP FORCE MOUNT; RESTORE DATABASE; RECOVER DATABASE; ALTER DATABASE OPEN;

Restore and recover a tablespace:


RMAN> RMAN> RMAN> RMAN> SQL ALTER TABLESPACE users OFFLINE; RESTORE TABLESPACE users; RECOVER TABLESPACE users; SQL ALTER TABLESPACE users ONLINE;

Restore and recover a datafile:


RMAN> RMAN> RMAN> RMAN> SQL ALTER DATABASE DATAFILE 64 OFFLINE; RESTORE DATAFILE 64; RECOVER DATAFILE 64; SQL ALTER DATABASE DATAFILE 64 ONLINE;

-6-

S-ar putea să vă placă și