Вы находитесь на странице: 1из 19

Module 16b - Recovery Manager

1 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

module16b-recovery_manager.htm; Updated July 19, 2007.

Module 16b Recovery Manager (RMAN)


Objectives

Learn basic concepts related the use of Recovery Manager (RMAN).

RMAN Features and Components


RMAN Components

RMAN executable is named rman and is located at $ORACLE_HOME/bin and


is installed by default with both Oracle 10g Standard and Enterprise editions.
Invoked from a command line argument as shown here.
o The target parameter defaults to the value of the ORACLE_SID for the
session.
o The forward slash "/" indicates connection without connecting to a
recovery catalog
/a01/student/dbockstd
dbockstd/@oracle2=>rman target /
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.
connected to target database: DBOCKSTD (DBID=2717979554)

One or more target databases can be cataloged in the recovery catalog;


however, use of a recovery catalog (a tablespace stored in some database) is
optional.
The authoritative RMAN repository is always stored in the database control
file.
o The repository contents can also be stored in a recovery catalog
database, as an adjunct to the information stored in the control file.
o While RMAN is designed to work without a recovery catalog, if you
choose not to use a recovery catalog, you must perform some additional
administrative tasks.
Flash Recovery Area starting with Oracle 10g defines a location on disk to
hold all RMAN backups.

2/13/2009 6:18 PM

Module 16b - Recovery Manager

2 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

RMAN Features
Major features of RMAN not available with traditional backup methods (operating
system) or that improve significantly on traditional backup methods include:
Skip unused blocks Blocks that have never been written to in a table are not
backed up by RMAN when the backup is to a RMAN backupset.
Backup compression RMAN provides a binary compression mode that
optimizes compression for the typical kind of data found in Oracle data blocks.
This results in a slight increase in CPU time required for backup and recovery.
Open database backups Tablespace backups with RMAN can be done
without using BEGIN/END BACKUP clause still must be in ARCHIVELOG
mode.
True incremental backups RMAN does not write unchanged blocks since
the last backup.
Block-level recovery RMAN supports block-level recovery to enable
restoring or repairing a small number of blocks identified as being corrupt
during the backup operation keeps the rest of the tablespace online.
Multiple I/O Channels RMAN supports multi-threaded operations for backup
and recovery.
Platform independence Backups written with RMAN commands are
syntactically identical regardless of the operating system or hardware platform.
Tape manager support all major enterprise backup systems from 3rd parties
support RMAN.
Cataloging a record of all RMAN backups are recorded in the target
database control files or optionally to a recovery catalog stored in a different
database.
Scripting capabilities RMAN scripts can be saved in a recovery catalog for
retrieval during backup sessions.

Backup Types

Consistent and Inconsistent Backups a physical backup is consistent


when all datafiles have the same SCN this only results when all changes in
redo log files have committed to datafiles. An inconsistent backup results when
the database is open and system users are using the database.
Full backup includes all blocks of every datafile essentially a bit-for-bit
copy.
Incremental backup RMAN in Oracle 10g supports incremental backups as
level 0 or level 1.
o Level 0 a full backup of all blocks.
o Level 1 backup of only changed blocks.

2/13/2009 6:18 PM

Module 16b - Recovery Manager

3 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

Image Copies these are full backups done with operating system commands
such as the LINUX/UNIX cp command, or the RMAN backup as copy
commands.
Backupsets and Backup Pieces in contrast to Image Copies, backupsets
can be created and restored only with RMAN.
o A backupset is an RMAN backup of part or all of a database consisting
of one or more backup pieces.
o Each backup piece belongs to only one backupset and can contain
backups of one or more datafiles in the database.
Compressed Backups Compressed backups are only usable by RMAN and
require no special processing in a recovery operation compression is
automatic with RMAN.

Overview of RMAN Commands/Options


Frequently Used Commands
This table gives a list of common RMAN commands see the Oracle Database
Recovery Manager Reference for a complete listing.
Command
@

Description
Runs an RMAN script at the pathname specified after @. Default
is current path.
BACKUP
Performs an RMAN backup with or without archived redo log
files. Backs up datafiles, datafile copies, or performs incremental
level 0 or level 1 backup. Also validates blocks to backed up with
the VALIDATE clause.
CHANGE
Changes status of backup in RMAN repository used to exclude
a backup from a restore/recovery operation. Also used to notify
RMAN that a backup file was removed by an operating system
command outside of RMAN.
CONFIGURE
Configures RMAN persistent parameters. These parameters are
available for subsequent sessions unless explicitly
cleared/modified.
CREATE
Creates a repository catalog with RMAN metadata for one (or
CATALOG
more) target databases.
CROSSCHECK Checks records of RMAN repository against actual disk or tape
files.
DELETE
Deletes backup files or copies removes the record of the
backup file from the repository.
FLASHBACK
Performs a Flashback Database operation such as restoration to
a point in time by SCN or log sequence.

2/13/2009 6:18 PM

Module 16b - Recovery Manager

4 of 19

LIST
RECOVER

REGISTER
DATABASE
REPORT
RESTORE

RUN

SET
SHOW
SHUTDOWN
STARTUP
SQL

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

Displays information about backupsets and image copies.


Performs complete or incomplete recovery on a datafile,
tablespace, or entire database. Can apply incremental backups
to roll forward.
Registers a target database in the RMAN repository.
Provides a detailed analysis of the RMAN repository.
Restores files from image copies or backupsets to disk usually
after a media failure. Can also be used to validate a restore
operation without actually performing the restore by specifying the
PREVIEW option.
Runs sequence of RMAN statements as a group between { and }
allows overriding RMAN parameters for the group of statements
executed.
Sets RMAN configuration settings for the duration of a RMAN
session not the same as CONFIGURE.
Shows all or individual RMAN configured settings.
Shuts down the target database with RMAN same as
SHUTDOWN within SQLPlus.
Starts up the target database with RMAN same as STARTUP
within SQLPlus.
Runs SQL commands example: sql 'ALTER TABLESPACE
data01 OFFLINE IMMEDIATE'; -- before a restore/recover
operation.

Backup a Database with Flash Recovery Area


If a Flash Recover Area is specified for a database, a complete backup can be
accomplished without setting any explicit RMAN configuration.
RMAN> backup database;

Establishing a Repository
If a DBA elects to use a repository:
The repository only needs to be created once it can serve hundreds of
databases.
It should not be located in one of the target databases as this would make that
database unrecoverable in the event of failure.
Keep in mind that this is OPTIONAL the target database control files can
store RMAN metadata.

2/13/2009 6:18 PM

Module 16b - Recovery Manager

5 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

This sequence requires a tablespace and user to maintain metadata in a repository


database. This uses the oracle2 database.

Logon to SQLPlus as a DBA to the database that will store the repository
information. Create the tablespace RMAN that will store repository information.

CREATE TABLESPACE rman


DATAFILE '/a02/app/oracle/oradata/oracle2/rman01.dbf'
SIZE 10M AUTOEXTEND ON NEXT 5M;

Create a user named RMAN that will handle backup and recovery operations
and allocate privileges to this user.

CREATE USER rman IDENTIFIED BY rman001


DEFAULT TABLESPACE rman;
GRANT resource, connect, recovery_catalog_owner TO rman;

Logoff from SQLPlus or start a second connect session.


Start the RMAN software with a connection to the catalog. Note the error
message that the recovery catalog is not yet installed.

dbock/@oracle2=>rman catalog rman/rman001@oracle2


Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2004, Oracle.

All rights reserved.

connected to recovery catalog database


recovery catalog is not installed

The repository is created initially with the CREATE CATALOG command. This
command takes a minute or two to create the objects in the repository catalog.

RMAN> CREATE CATALOG;


recovery catalog created
At this point, the repository can be used by specifying the username/password on the
RMAN command line with the CATALOG parameter or by using the CONNECT
CATALOG command in a RMAN session.
Example: This example shows starting up the RMAN utility for the dbockstd
database while specifying that the catalog repository is in the oracle2 database and
the name of the repository owner is the rman user account (rman@oracle2). The

2/13/2009 6:18 PM

Module 16b - Recovery Manager

6 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

system prompts for the password of the rman user account. At this point the utility is
ready for the DBA to enter a command.
dbockstd/@oracle2=>rman target / catalog rman@oracle2
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2004, Oracle.

All rights reserved.

connected to target database: DBOCKSTD (DBID=2717979554)


recovery catalog database Password:
connected to recovery catalog database
RMAN>

Registering a Database
Each database for RMAN backup/recovery must be registered in the RMAN
repository if the repository is used.
Records target database schema.
Records database ID.
Target database need only be registered once.
In this example the database ORACLE_SID is dbockstd. This registers the
database named dbockstd within the RMAN repository that is stored in the
database named oracle2.
RMAN> REGISTER DATABASE;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN>

If you try to register the database twice, this results in an error message stack
as shown.

RMAN> REGISTER DATABASE;


RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============

2/13/2009 6:18 PM

Module 16b - Recovery Manager

7 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

RMAN-00571:
===========================================================
RMAN-03009: failure of register command on default channel at
07/20/2005 16:01:06
RMAN-20002: target database already registered in recovery
catalog

How to Persist an RMAN Setting


The SHOW ALL command displays default RMAN settings.
Parameters set to default display a # default at the end of the configuration
setting.
Execute a CONFIGURE command to change any setting.
RMAN> SHOW ALL;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK
TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO
BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; #
default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
# default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/a02/app/oracle
/product/10g/dbs/snapcf_dbockstd.f'; # default
RMAN>

Retention Policy
Backups can be retained by either recovery window or by redundancy.
Recovery window RMAN will remain as many backups as necessary to
bring a database to a point in time within a recovery window:
o Example: a recovery window of 7 days will cause RMAN to maintain
image copies, incremental backups, and archived redo log files to
restore/recover a database to any point in the last 7 days.

2/13/2009 6:18 PM

Module 16b - Recovery Manager

8 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

o Backups not needed for the recovery window are marked OBSOLETE
and automatically removed by RMAN if a Flash Recovery Area is used
and disk space is required for additional newer backups.
Redundancy RMAN retains a specified number of backups.
o Extra copies beyond the redundancy number are marked OBSOLETE.
o Obsolete backups are automatically removed if a Flash Recovery Area is
used and disk space is required.
o The DELETE OBSOLETE command can also be used to remove
obsolete backups.
None this setting causes no backups or copies to ever be considered
obsolete. The DBA must manually remove old backups.

Example: This sets the retention policy window to 7 days..


RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters are successfully stored
RMAN>

Device Type
If the default device is DISK and no pathname is specified, RMAN uses the Flash
Recovery Area for all backups.
Keeping all backups on disk can become inefficient. This example shows configuring
a tape device the actual specification for the configuration is specific to each
installation depending on the tape backup software and hardware.
RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt PARMS='ENV=(<vendor
specific arguments>)';

Sbt is the device type for any tape backup system for any vendor.

Backup Compression
This command demonstrates how to compress backups to save disk space.
RMAN> CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO compressed
backupset;

2/13/2009 6:18 PM

Module 16b - Recovery Manager

9 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

new RMAN configuration parameters:


CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET
PARALLELISM 1;
new RMAN configuration parameters are successfully stored
RMAN>

Initialization Parameters
A number of PFILE initialization parameters are important for controlling backups.
CONTROL_FILE_RECORD_KEEP_TIME specifies number of days RMAN
will attempt to keep a record of backups in the target control file.
DB_RECOVERY_FILE_DEST parameter specifies the location of the Flash
Recovery Area.
o Locate it on a file system different from any database datafiles, control
files, or redo log files (online or archived).
o This mitigates loss of any datafiles that might inadvertently be stored on
the same disk as the Flash Recovery Area file.
DB_RECOVERY_FILE_DEST_SIZE parameter specifies the upper limit on
the amount of space used by the Flash Recovery Area.
These are the PFILE settings for the ORACLE2 database (at one point in time
subject to change in the future).
db_name='oracle2'
db_recovery_file_dest='/a02/app/oracle/flash_recovery_area'
db_recovery_file_dest_size=2147483648

Backup Operation
Full Database Backup
This example does a full database backup using backupsets to copy all database files
to the Flash Recovery Area. If the database was started with an SPFILE, then the
second command shown below would also backup the SPFILE; otherwise, it
produces an error message.
RMAN> BACKUP AS BACKUPSET DATABASE;
RMAN> BACKUP AS BACKUPSET DATABASE SPFILE;

2/13/2009 6:18 PM

Module 16b - Recovery Manager

10 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

The dbockstd database backup result is shown here.

RMAN> BACKUP AS BACKUPSET database;


Starting backup at 20-JUL-05
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/a01/student/dbockstd/oradata
/dbockstdsystem01.dbf
input datafile fno=00003 name=/a01/student/dbockstd/oradata
/dbockstdsysaux01.dbf
input datafile fno=00007 name=/a01/student/dbockstd/oradata
/dbockstdundo02.dbf
input datafile fno=00005 name=/a01/student/dbockstd/oradata
/application_data/dbockstdDATA01.dbf
input datafile fno=00006 name=/a01/student/dbockstd/oradata
/dbockstdINDEX01.dbf
channel ORA_DISK_1: starting piece 1 at 20-JUL-05
channel ORA_DISK_1: finished piece 1 at 20-JUL-05
piece handle=/a01/student/dbockstd/DBOCKSTD/backupset
/2005_07_20/o1_mf_nnndf_TAG20050720T162632_1fxjd93q_.bkp
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
channel ORA_DISK_1: starting piece 1 at 20-JUL-05
channel ORA_DISK_1: finished piece 1 at 20-JUL-05
piece handle=/a01/student/dbockstd/DBOCKSTD/backupset
/2005_07_20/o1_mf_ncnnf_TAG20050720T162632_1fxjfdcs_.bkp
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:03
Finished backup at 20-JUL-05

The next statement ensures that all transactions are represented in an archive
log including any that occurred during the backup. This enables media
recovery after restoring this backup.

RMAN> SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';


sql statement: ALTER SYSTEM ARCHIVE LOG CURRENT

2/13/2009 6:18 PM

Module 16b - Recovery Manager

11 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

RMAN>

The backupset is stored to the database's Flash Recovery Area and here it is
named 2005_07_20.

/a01/student/dbockstd/DBOCKSTD/backupset
dbockstd/@oracle2=>ls -al
total 12
drwxr-x--3 oracle
dba
4096 Jul 20 16:26 .
drwxr-x--4 oracle
dba
4096 Jul 20 16:26 ..
drwxr-x--2 oracle
dba
4096 Jul 20 16:27
2005_07_20

The LIST command for RMAN will show backups cataloged within the target
database control file and the RMAN repository.

RMAN> list backup by backup;


starting full resync of recovery catalog
full resync complete
List of Backup Sets
===================
BS Key Type LV Size
Device Type Elapsed Time Completion
Time
------- ---- -- ---------- ----------- -------------------------211
Full
189M
DISK
00:00:29
20-JUL-05
BP Key: 213
Status: AVAILABLE Compressed: NO Tag:
TAG20050720T162632
Piece Name: /a01/student/dbockstd/DBOCKSTD/backupset
/2005_07_20/o1_mf_nnndf_TAG20050720T162632_1fxjd93q_.bkp
List of Datafiles in backup set 211
File LV Type Ckp SCN
Ckp Time Name
---- -- ---- ---------- --------- ---1
Full 680185
20-JUL-05 /a01/student/dbockstd
/oradata/dbockstdsystem01.dbf
3
Full 680185
20-JUL-05 /a01/student/dbockstd
/oradata/dbockstdsysaux01.dbf
5
Full 680185
20-JUL-05 /a01/student/dbockstd
/oradata/application_data/dbockstdDATA01.dbf
6
Full 680185
20-JUL-05 /a01/student/dbockstd
/oradata/dbockstdINDEX01.dbf
7
Full 680185
20-JUL-05 /a01/student/dbockstd

2/13/2009 6:18 PM

Module 16b - Recovery Manager

12 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

/oradata/dbockstdundo02.dbf
BS Key Type LV Size
Device Type Elapsed Time Completion
Time
------- ---- -- ---------- ----------- -------------------------212
Full
1M
DISK
00:00:00
20-JUL-05
BP Key: 214
Status: AVAILABLE Compressed: NO Tag:
TAG20050720T162632
Piece Name: /a01/student/dbockstd/DBOCKSTD/backupset
/2005_07_20/o1_mf_ncnnf_TAG20050720T162632_1fxjfdcs_.bkp
Controlfile Included: Ckp SCN: 680313
Ckp time:
20-JUL-05

Tablespace Backup
A tablespace backup should be made as soon as a tablespace is added to a
database this will reduce the time required for restoring the tablespace if media
failure occurs.
This uses the BACKUP command to create a backupset for the DATA01
tablespace.
RMAN> BACKUP AS BACKUPSET TABLESPACE data01;
Starting backup at 20-JUL-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=252 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00005 name=/a01/student/dbockstd/oradata
/application_data/dbockstdDATA01.dbf
channel ORA_DISK_1: starting piece 1 at 20-JUL-05
channel ORA_DISK_1: finished piece 1 at 20-JUL-05
piece handle=/a01/student/dbockstd/DBOCKSTD/backupset
/2005_07_20/o1_mf_nnndf_TAG20050720T170718_1fxlrp9f_.bkp
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
Finished backup at 20-JUL-05
RMAN>

Datafile Backup

2/13/2009 6:18 PM

Module 16b - Recovery Manager

13 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

Individual datafiles may be backed up when it is impractical to backup an entire


tablespace within a single RMAN session.
This backs up a datafile for the INDEX01 tablespace.
RMAN> BACKUP AS BACKUPSET DATAFILE
'/a01/student/dbockstd/oradata/dbockstdINDEX01.dbf';
Starting backup at 20-JUL-05
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00006 name=/a01/student/dbockstd/oradata
/dbockstdINDEX01.dbf
channel ORA_DISK_1: starting piece 1 at 20-JUL-05
channel ORA_DISK_1: finished piece 1 at 20-JUL-05
piece handle=/a01/student/dbockstd/DBOCKSTD/backupset
/2005_07_20/o1_mf_nnndf_TAG20050720T171011_1fxly406_.bkp
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
Finished backup at 20-JUL-05
RMAN>

Image Copy
Backup of copies of the database that are bit-for-bit are automatically recorded in the
RMAN repository this is an advantage over using the O/S commands.
This creates an image copy of the INDEX01 tablespace.
RMAN> BACKUP AS COPY TABLESPACE index01;

Incremental Backup
The initial incremental backup is a level 0 incremental backup.
Each backup after the initial incremental backup (known as a level 1 backup)
contains only changed blocks and take less time.
A cumulative level 1 incremental backup records all changed blocks since the
last initial incremental backup.
A differential level 1 incremental backup records all changes since the last

2/13/2009 6:18 PM

Module 16b - Recovery Manager

14 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

incremental backup (level 0 or 1).


RMAN will choose the best combination of backups when restoring a database.

RMAN> BACKUP INCREMENTAL LEVEL 0 AS COMPRESSED BACKUPSET


database;

This example shows a level 1 differential incremental backup no keyword for


differential is required or allowed as this is the default.

RMAN> BACKUP INCREMENTAL LEVEL 1 AS COMPRESSED BACKUPSET


database;

This example shows a level 1 incremental backup that is cumulative.

RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE AS COMPRESSED


BACKUPSET database;

Validating Backups
It is important to know if a backup is valid. This command shows the use of the
BACKUP VALIDATE DATABASE command to validate an entire database including
the archived redo log files.
RMAN> BACKUP VALIDATE database ARCHIVELOG all;
Starting backup at 20-JUL-05
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=158 recid=1
stamp=564109220
input archive log thread=1 sequence=159 recid=2
stamp=564116430
input archive log thread=1 sequence=160 recid=3
stamp=564123640
input archive log thread=1 sequence=161 recid=4
stamp=564130849
input archive log thread=1 sequence=162 recid=5
stamp=564138059
input archive log thread=1 sequence=163 recid=6
stamp=564145207
input archive log thread=1 sequence=164 recid=7
stamp=564152417

2/13/2009 6:18 PM

Module 16b - Recovery Manager

15 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

input archive log thread=1 sequence=165 recid=8


stamp=564159627
input archive log thread=1 sequence=166 recid=9
stamp=564166335
input archive log thread=1 sequence=167 recid=10
stamp=564166486
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:02
channel ORA_DISK_1: starting compressed full datafile
backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/a01/student/dbockstd/oradata
/dbockstdsystem01.dbf
input datafile fno=00003 name=/a01/student/dbockstd/oradata
/dbockstdsysaux01.dbf
input datafile fno=00007 name=/a01/student/dbockstd/oradata
/dbockstdundo02.dbf
input datafile fno=00005 name=/a01/student/dbockstd/oradata
/application_data/dbockstdDATA01.dbf
input datafile fno=00006 name=/a01/student/dbockstd/oradata
/dbockstdINDEX01.dbf
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:01
channel ORA_DISK_1: starting compressed full datafile
backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current controlfile in backupset
channel ORA_DISK_1: backup set complete, elapsed time:
00:00:03
Finished backup at 20-JUL-05

Recovery Operations
RMAN can perform recovery at various levels including recovering individual blocks,
tablespaces, datafiles, or an entire database.

Block Media Recovery


The block media recovery is used to recover a small number of database blocks that
may have become corrupted this is preferable to recovering an entire database.
Minimizes redo log application time.
Reduces I/O to recover.
Affected datafiles remain online and available to users (except for the corrupt

2/13/2009 6:18 PM

Module 16b - Recovery Manager

16 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

database blocks).
Block corruption is often detected during a read or write (INSERT or SELECT)
operation when Oracle writes to a trace file and aborts a transaction.
Use the V$DATABASE_BLOCK_CORRUPTION view to identify records of
corrupt blocks.
RMAN must know the datafile number and block number within a datafile that
is corrupt.
RMAN> BLOCKRECOVER DATAFILE 4 BLOCK 208;

Restoring a Control File


Control files can be restored from backups if you lose all copies of the control files
an unlikely event if you have multiple disk drives.
RMAN> RESTORE CONTROLFILE;
If you are not using a recovery catalog, use the FROM filename clause.
RMAN> RESTORE CONTROLFILE FROM '/a01/student/dbockstd/oradata
/backup.ctl';

After recovering a control file, you must perform media recover of the database
and open the database with RESETLOGS option see the media recover
documentation on the Oracle web site.

Restoring a Tablespace
To restore/recover a tablespace, the tablespace must be forced offline, restored and
recovered, then brought back online.
First a SQL command is executed from within RMAN to take the tablespace
offline.
RMAN> SQL 'ALTER TABLESPACE data01 OFFLINE immediate';
sql statement: ALTER TABLESPACE data01 OFFLINE immediate

Next the RESTORE TABLESPACE command is executed.

RMAN> RESTORE TABLESPACE data01;


Starting restore at 20-JUL-05
using channel ORA_DISK_1

2/13/2009 6:18 PM

Module 16b - Recovery Manager

17 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

channel ORA_DISK_1: starting datafile backupset restore


channel ORA_DISK_1: specifying datafile(s) to restore from
backup set
restoring datafile 00005 to /a01/student/dbockstd/oradata
/application_data/dbockstdDATA01.dbf
channel ORA_DISK_1: restored backup piece 1
piece handle=/a01/student/dbockstd/DBOCKSTD/backupset
/2005_07_20/o1_mf_nnnd0_TAG20050720T171630_1fxm9ygw_.bkp
tag=TAG20050720T171630
channel ORA_DISK_1: restore complete
Finished restore at 20-JUL-05

The RECOVER command recovers the restored tablespace.

RMAN> RECOVER TABLESPACE data01;


Starting recover at 20-JUL-05
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backupset
restore
channel ORA_DISK_1: specifying datafile(s) to restore from
backup set
destination for restore of datafile 00005: /a01/student
/dbockstd/oradata/application_data/dbockstdDATA01.dbf
channel ORA_DISK_1: restored backup piece 1
piece handle=/a01/student/dbockstd/DBOCKSTD/backupset
/2005_07_20/o1_mf_nnnd1_TAG20050720T171952_1fxmj9l7_.bkp
tag=TAG20050720T171952
channel ORA_DISK_1: restore complete
starting media recovery
media recovery complete
Finished recover at 20-JUL-05

The tablespace is now brought online through an SQL command.

RMAN> SQL 'ALTER TABLESPACE data01 ONLINE';


sql statement: ALTER TABLESPACE data01 ONLINE

Restoring a Datafile

2/13/2009 6:18 PM

Module 16b - Recovery Manager

18 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

Restoring a datafile is similar to restoring a tablespace.


Take the tablespace for the datafile offline, restore and recover the datafile, and
bring the tablespace back online.
The command to restore and recover the datafile requires knowing the file
number assigned within the database to the datafile.
RMAN> RESTORE DATAFILE 4;
RMAN> RECOVER DATAFILE4;

Restoring a Database
In this scenario, the datafiles have been lost, but the control file and online redo log
files are on different disk sets and are available.
$ rman target / catalog rman/rman001@oracle2
RMAN> startup mount
[messages about starting the Oracle instance are displayed]
RMAN> RESTORE DATABASE;
[messages about the restoration process are displayed]
RMAN> RECOVER DATABASE;
[messages about the recovery are displayed]
RMAN> ALTER DATABASE OPEN;
Database opened
RMAN>

Validating Restore Operations


The RESTORE PREVIEW command within RMAN will list all files RMAN will use to
perform a requested operation.
This command reads the catalog information about the backupsets, not the
actual backupset data.
This example shows one incremental backupset to be used for the restore
operation.
RMAN> RESTORE TABLESPACE data01 PREVIEW;
Starting restore at 20-JUL-05

2/13/2009 6:18 PM

Module 16b - Recovery Manager

19 of 19

http://www.siue.edu/~dbock/cmis565/module16b-recovery_manager.htm

using channel ORA_DISK_1


List of Backup Sets
===================
BS Key Type LV Size
Device Type Elapsed Time Completion
Time
------- ---- -- ---------- ----------- -------------------------267
Incr 0 1M
DISK
00:00:12
20-JUL-05
BP Key: 270
Status: AVAILABLE Compressed: NO Tag:
TAG20050720T171630
Piece Name: /a01/student/dbockstd/DBOCKSTD/backupset
/2005_07_20/o1_mf_nnnd0_TAG20050720T171630_1fxm9ygw_.bkp
List of Datafiles in backup set 267
File LV Type Ckp SCN
Ckp Time Name
---- -- ---- ---------- --------- ---5
0 Incr 682276
20-JUL-05 /a01/student/dbockstd
/oradata/application_data/dbockstdDATA01.dbf
Finished restore at 20-JUL-05

The RESTORE VALIDATE command will validate if the backupsets are readable and
not corrupted.
RMAN> RESTORE TABLESPACE data01 VALIDATE;
Starting restore at 20-JUL-05
using channel ORA_DISK_1
channel ORA_DISK_1: starting validation of datafile backupset
channel ORA_DISK_1: restored backup piece 1
piece handle=/a01/student/dbockstd/DBOCKSTD/backupset
/2005_07_20/o1_mf_nnnd0_TAG20050720T171630_1fxm9ygw_.bkp
tag=TAG20050720T171630
channel ORA_DISK_1: validation complete
Finished restore at 20-JUL-05

END OF NOTES

2/13/2009 6:18 PM

Вам также может понравиться