Documente Academic
Documente Profesional
Documente Cultură
Recovery Manager is a tool that: manages the process of creating backups and also manages the
process of restoring and recovering from them.
Advantages: -
* No extra costs …Its available free
* RMAN introduced in Oracle 8 it has become simpler with newer versions and easier than user managed
backups
* Proper security
* You are 100% sure your database has been backed up.
* Its contains detail of the backups taken etc in its central repository
* Facility for testing validity of backups also commands like crosscheck to Check the status of backup.
* Faster backups and restores compared to backups without RMAN
* RMAN is the only backup tool which supports incremental backups.
* Oracle 10g has got further optimized incremental backup which has resulted in improvement of
performance during backup and recovery time
* Parallel operations are supported
* Better querying facility for knowing different details of backup
* No extra redo generated when backup is taken..compared to online backup without RMAN which results
in saving of space in hard disk
* RMAN an intelligent tool
* Maintains repository of backup metadata
* Remembers backup set location
* Knows what need to backed up
* Knows what is required for recovery
* Knows what backup are redundant
RMAN ARCHITECTURE
* An oracle RMAN comprises of RMAN EXECUTABLE This could be present and fired even through
client side TARGET DATABASE This is the database which needs to be backed up
* RECOVERY CATALOG Recovery catalog is optional otherwise backup details are stored in target
database controlfile
* It is a repository of information queried and updated by Recovery Manager
* It is a schema or user stored in Oracle database
* One schema can support many databases
* It contains information about physical schema of target database datafile and archive log, backup sets
and pieces
Media Management software is a must if you are using RMAN for storing backup in tape drive directly.
Backups in RMAN
IMAGE COPY
Its again a kind of backup. The advantage of using Image copy is its not in RMAN proprietary format.
Backup Format
RMAN backup is not in oracle format but in RMAN format. Oracle backup comprises of backup sets and it
consists of backup pieces. Backup sets are logical entity. In oracle 9i it gets stored in a default location.
One more important point of data file backup sets is it do not include empty blocks. A backup set would
contain many backup pieces. A single backup piece consists of physical files which are in RMAN
proprietary format.
You can go to RMAN prompt by just typing rman. RMAN executable is present in
ORACLE_HOME/bin location.
bash-2.05$ rman
RMAN>
You can use target connect to connect to database. The database it will connect to depends on the
environment variable ORACLE_HOME.
Alternatively you can use “rman TARGET SYS/oracle@test NOCATALOG” to connect to the RMAN of
“test” instance.
Here we will be using target database control file to store all the information required for RMAN, like
backupsets and backup image information etc.
Backup Database:
RMAN> shutdown immediate
You can also create a repository for RMAN to store all this information. Repository will be just another
small database which can store the catalog information.
1) Create database which will hold the catalog. Else you can use the existing database also. All you need is
to create a seperate tablespace for holding the information about RMAN catalog.
Tablespace created.
SQL> create user rman identified by rman
2 default tablespace rman_tbs
3 TEMPORARY TABLESPACE TEMPTS1
4 QUOTA UNLIMITED ON rman_tbs account unlock;
User created.
After creating user, you need to grant RECOVERY_CATALOG_OWNER role to that user.
For registering the database, you need to get connected to database as well as catalog at the
same time. Here is how you can do.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-06004: ORACLE error from recovery catalog database: RMAN-20001: target database not found
in recovery catalog
The above error is because the database we connected to is not found in the catalog
database. We can register the database in catalog.
Registering database will also resynch the information present in the target database control file and
catalog database. Since we have taken 1 backup early, it will synchup that information with RMAN
catalog. We can check the same using LIST BACKUP command at RMAN prompt.
o1_mf_ncsnf_TAG20070723T031355_3b8zy7xr_.bkp
Control File Included: Ckp SCN: 562487 Ckp time: 23-JUL-07
SPFILE Included: Modification time: 23-JUL-07
The control file can be automatically backed up after each RMAN backup and database structure change
as a way to protect the RMAN repository (when we are not using a seperate catalog for RMAN).
RMAN> configure controlfile autobackup on;
These are the image copies and are stored in ORACLE format and not in RMAN format. Backupsets and
backuppieces are stored in internal RMAN format. Hence these image copies can be used for manual
restore and recovery as well.
RMAN> backup as copy database;
If you specify BACKUP AS BACKUPSET, then RMAN stores its backups in backup sets. A backup set,
consisting of one or more backup pieces, contains the physical file data being backed up. This backupset is
written in a format that only RMAN can access. Only RMAN can create and restore backup sets. Backup
sets can be written to disk or tape, and they are the only type of backup which RMAN can use to write
backups to tape.
Backup archivelogs
We can backup the archive logs according to the output of some search condition. Example we want to
backup only those archivelogs which starts with “ARCH_616814159_”.
RMAN> backup acrchivelog like ‘%ARCH_616814159_%’;
Suppose we want to copy the archivelogs of last 2 days, then we can use the following commands.
RMAN> BACKUP ARCHIVELOG from time ’sysdate-2′;
Remember that copies option cannot be used with image copies. It can be used only with backupsets.
Backing up backupsets
RMAN> BACKUP BACKUPSET ALL;
Backup imagecopies
RMAN> Backup as copy backupset all;
List Imagecopies
RMAN> list copy;
List Backupsets
RMAN> list backup;
Use the RESTORE and RECOVER commands for RMAN restore and recovery of physical
database files.
RMAN can recover individual corrupted datafile blocks. When RMAN performs a complete scan of a file
for a backup, any corrupted blocks are listed in V$DATABASE_BLOCK_CORRUPTION. Corruption is
usually reported in alert logs, trace files or results of SQL queries. Use BLOCKRECOVER to repair all
corrupted blocks:
As you know that if you do not use a recovery catalog, then control file of the target database is used as
RMAN repository and eventually after some time the control file records for RMAN information will get
overwritten.
Set this initialization parameter in the parameter file of the target database to determine how long records
are kept:
CONTROL_FILE_RECORD_KEEP_TIME =
You can configure a retention policy to be used by RMAN to determine which backups are considered
obsolete. This allows you to remove files from the repository that are no longer needed to meet your
retention requirements. This policy can be based on a recovery window (the maximum number of days
into the past for which you can recover) or redundancy (how many copies of each backed-up file to keep).
You can specify the days days between the current time and the earliest point of recoverability, this is
called RECOVERY WINDOW. RMAN does not consider any full or level 0 incremental backup as obsolete
if it falls within the recovery window.
Alternatively the REDUNDANCY parameter will instruct to store the number of copies of backup in
RMAN repository. If the number of backups for a specific datafile or control file exceeds the
REDUNDANCY setting considers the extra backups as obsolete.
This will make the REDUNDANCY setting to 3. Meaning that it will at max store 3 copies of backups and
ikmages of datafile. Any more images or backups are consider obsolete.
it will configure new retention policy based on the RECOVERY WINDOW of 7 days. This means that all
the backups which falls outside this window will be considered obsolute. So in this case you need to have
backup scheduled every week to have atleast 1 valid backup.
Remember that at any point of time, only one policy can be active. It can be either REDUNDANCY or
RECOVERY WINDOW.
When you change the retention policy to another one, it will suspend the previous policy as shown below.
Crosscheck is needed when an archivelog file or backup is manually removed, i.e., not deleted by RMAN.
This command ensures that data about backups in the recovery catalog or control file is synchronized with
corresponding data on disk or in the media management catalog. The CROSSCHECK command operates
only on files that are recorded in the recovery catalog or the control file.
The CROSSCHECK command does not delete any files that it is unable to find, but updates their
repository records to EXPIRED. Then, you can run DELETE EXPIRED to remove the repository records
for all expired files as well as any existing physical files whose records show the status EXPIRED.
If some backup pieces or copies were erroneously marked as EXPIRED, for example, because the media
manager was misconfigured, then after ensuring that the files really do exist in the media manager, run
the CROSSCHECK BACKUP command again to restore those files to AVAILABLE status.
The DELETE command removes RMAN backups and copies from DISK marks the records in control file
as DELETED or removes the records from the recovery catalog (if you use a catalog).
This will delete all the archives from the oldest one till the sequence we have specified.
List commands
RMAN> list backup;
RMAN> list copy;
RMAN> list incarnation of database;
RMAN> list expired backupset;
RMAN> list expired copy;
RMAN> list backup of tablespace sysaux;
RMAN> list copy of datafile 3;
Reporting in RMAN
RMAN> report need backup;
Reports which database files need to be backed up to meet a configured or specified retention policy
Suppose in the above command we want to skip a perticular tablespace like perfstat then
we can use the below command.
RMAN> report need backup recovery window of 2 days database skip tablespace perfstat;
RMAN> report need backup redundancy 3;
Displays objects requiring backup to satisfy a redundancy-based retention policy.
You can add the options RECOVERY WINDOW and REDUNDANCY with this command as
given below.
This command lists and displays information about the database files.
RMAN> report schema at time ’sysdate - 14′;
This command gives report on schema 14 days ago.
RMAN configuration
You can return any setting to its default value by using CONFIGURE… CLEAR
By default, RMAN sends all backups to an operating system specific directory on disk. So default setting
for DEVICE TYPE is DISK. You can configure to make backups by default on tape or any other device as
given below.
You can configure backup sets or image copies as the default for a perticular device type, using either of
the following commands:
RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY; # Default becomes image copies
RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET; # Default becomes
uncompressed
You can configure RMAN to use compressed backupsets by default on a particular device
type, by using the CONFIGURE DEVICE TYPE command with the BACKUP TYPE TO
COMPRESSED BACKUPSET option, as shown in the following examples.
We can configure RMAN channel to write backups and images in a specific format.
The following command configures RMAN to write disk backups to the /backup directory
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘/backup/ora_df%t_s%s_s%p’;