Friday, 27 March 2015

RMAN



RMAN:

RMAN (Recovery Manager) is a backup and recovery manager supplied for Oracle databases (from version 8) created by the Oracle Corporation. It provides database backup, restore, and recovery capabilities addressing high availability and disaster recovery concerns. Oracle Corporation recommends RMAN as its preferred method for backup.

 -RMAN keeps rman backup records in current control file, if the database not using catalog.

-Default location for the RMAN backups is Flash Recovery Area.

Files That RMAN Can Back Up

RMAN's BACKUP command supports backing up the following types of files:

·       datafiles, control files, and the server parameter file (SPFILE)
·       Archived redo logs

Prerequisites

Database should be in archivelog mode and database should be up and running since RMAN backups are online backup.

 

Image Copies and Backup Sets


RMAN backups can be stored in one of two formats as image copies or as backup sets.

 

Image Copies

An image copy is a bit-for-bit duplicate of a database file, identical to a copy made with an operating system command. (RMAN-created image copies are, however, recorded in the RMAN repository, unlike file copies created using operating system-level commands.)
Image copy backups can only be created on disk. RMAN can create image copies of datafiles and datafile copies, control files and control file copies, archived redo logs, and backup pieces. RMAN creates image copies when the AS COPY option is used with the BACKUP command.

Ex: taking full backup copy

$rman target /
RMAN> backup as copy database;

Backup Sets

RMAN can also store backup information a logical structure called a backupset. A backup set contains the data from one or more datafiles, archived redo logs, or control files or SPFILE. You can also back up existing backup sets into another backup set.
A backup set consists of one or more files in an RMAN-specific format, known as backuppieces. By default, a backup set consists of one backup piece. For example, you can backup ten datafiles into a single backup set consisting of a single backup piece.

Ex: Taking full backup as follow

$rman target /
RMAN> backup database;

RMAN Full and Incremental Backups

RMAN backups of datafiles can be either full datafile backups, or incremental backups.
A full backup of a datafile is a backup that includes every used data block in the file. If a full datafile backup is created as an image copy, the entire file contents are reproduced exactly.
RMAN incremental backups back up only datafile blocks that have changed since a specified previous backup. You can make incremental backups of databases, individual tablespaces or datafiles.
The goal of an incremental backup is to back up only those data blocks that have changed since a previous backup.

Level 0 and Level 1 Incremental Backups

Incremental backups can be either level 0 or level 1. A level 0 incremental backup, which is the base for subsequent incremental backups, copies all blocks containing data, backing the datafile up into a backup set just as a full backup would. The only difference between a level 0 incremental backup and a full backup is that a full backup is never included in an incremental strategy.

A level 1 incremental backup can be either of the following types:

·       A differential backup, which backs up all blocks changed after the most recent incremental backup at level 1 or 0. If there is not recent level 0 or 1 backup, RMAN takes level 0 backup.
EX: taking incremental backup (Level 1).

RMAN> backup incremental level 1 database;

·       A cumulative backup, which backs up all blocks changed after the most recent incremental backup at level 0, if there is no recent level 0 backup RMAN takes Level 0 backup.
EX:
             RMAN> backup incremental level 1 cumulative database;

·       Incremental backups are differential by default.

Starting and Exiting RMAN

The RMAN executable is automatically installed with the database and is typically located in the same directory as the other database executables. For example, the RMAN client on Linux is located in $ORACLE_HOME/bin. 

You have the following basic options for starting RMAN:

  • Start the RMAN executable at the operating system command line connecting target database with OS authentication option, as in the following example:
$rman target /

  • Connecting to target database as user
     [oracle@localhost ~]$ rman target sys@orcl
Recovery Manager: Release 11.2.0.1.0 - Production on Thu Feb 26                  03:50:22 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
target database Password:
connected to target database: ORCL (DBID=1341150024)
RMAN>

 To quit RMAN and terminate the program, enter EXIT or QUIT at the RMAN prompt:

     RMAN> EXIT

Specifying the Location of RMAN Output

By default, RMAN writes command output to standard output. To redirect output to a log file, enter the LOG parameter on the command line when starting RMAN, as in the following example:

$ rman target / LOG /tmp/rman.log

In this case, RMAN displays command input but does not display the RMAN output. The easiest way to send RMAN output both to a log file and to standard output is to use the Linux tee command or its equivalent. For example, the following technique enables both input and output to be visible in the RMAN command-line interface:

$ rman target / | tee rman.log

Viewing and change your CONFIGURE command settings:

Run SHOW ALL as shown bellow. The output includes both parameters that you have changed and those that are set to the default. The configuration is displayed as the series of RMAN commands required to re-create the configuration. You can save the output in a text file and use this command file to re-create the configuration on the same or a different database.

SHOW ALL Command:

RMAN>SHOW ALL;

RMAN configuration parameters for database with db_unique_name PROD1 are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO '%F'; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'ENV= (OB_DEVICE=tape1)';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/disk1/oracle/dbs/snapcf_ev.f'; # default


No comments:

Post a Comment