Professional Documents
Culture Documents
D16507GC10
Production 1.0
March 2003
D37796
Author
Jim Womack
Technical Contributors
and Reviewers
Matthew Arrocha
Tammy Bednar
Dairy Chen
Phillip Garm
Joel Goodman
Lex De Haan
Matthew Hart
Magnus Isaksson
Donna Keesling
Petter Stene
Sabine Teuber
Publisher
Michael Sebastian
Contents
iii
vi
vii
viii
Objectives
After completing this lesson, you should be able to do
the following:
Explain the fundamentals of the RMAN
architecture and its components
Identify the features, components, and tasks of
RMAN
Describe the basic concepts of block consistency
1-2
RMAN
1-3
RMAN
RMAN is a tool that manages the process of creating backups and the process of restoring and
recovering data from these backups. The product is a feature of the Oracle database server and
does not require separate installation. RMAN is a client-server application that uses database
server sessions to perform backup and recovery. It stores metadata about its operations in the
control file of the target database and, optionally, in a recovery catalog schema in an Oracle
database.
You can invoke RMAN as a command line executable from the operating system prompt or use
some RMAN features through the Enterprise Manager GUI.
RMAN Features
The features of RMAN include:
Automation of backup, restore, and recovery
Easy backup of archived redo logs
Automatic detection and inclusion of new data
files
Support of incremental backups
Reduction of recovery errors
No generation of extra redo during open database
backups
1-4
RMAN Features
RMAN automates backup and recovery, whereas the user-managed method requires you to keep
track of all database files and backups. For example, instead of requiring you to locate backups
for each data file, then copy them to the correct place by using operating system commands, and
choose which logs to apply, RMAN manages these tasks automatically.
RMAN simplifies the backup and restore process when using Oracle Managed Files. When you
use Oracle Managed Files, the Oracle server names and manages your data files, control files,
and online redo logs. This simplifies your management of these files. However, it may be harder
for you to keep track of the filenames of the various database files because you have not named
them yourself. RMAN handles all record keeping. For example, the addition of a data file will
automatically be detected, and included within the next backup.
RMAN can perform incremental backups, which back up only those data blocks that changed
after a previous backup. However, you can only take incremental backups of a NOARCHIVELOG
database after a consistent shutdown. You can restore the database by using incremental
backups, which means that you can restore a NOARCHIVELOG database.
RMAN Features
1-5
RMAN Architecture
Target instance
Server
session
(default)
Enterprise
Manager
DBMS_RCVMAN
RMAN
Server
session
(Catalog)
DBMS_RCVCAT
DBMS_RCVMAN
1-6
Fixed
tables and
views
DBMS_BACKUP_RESTORE
Server
session
(polling)
MML
Disk
Media Manager
Catalog tables
and views
Recovery
catalog
Target
control file
Server
session
(channel)
Server
session
(channel)
Target
database
files
Tertiary storage
Copyright 2003, Oracle. All rights reserved.
RMAN Architecture
The RMAN executable can run on any machine, with Oracle9i Net Services connections being
made to the databases. The Recovery Catalog is a simple database schema residing in a database
that is separate from the target database. Relevant information is obtained from the control file if
a catalog is not used. Using the Recovery Catalog is optional.
The target database is the database from which backup, restoration, or recovery is taking place.
The RMAN connection to it is always of the SYSDBA type. In the target instance and database,
the following is used:
Two sessions for administrative purposes. These will make use of several packages in the
database that are installed when catproc.sql runs.
One session for every allocated channel. Channels transfer the actual database data.
The control file stores schema, backup, and recovery information. The control file and the
recovery catalog information are synchronized with RMAN.
The Media Management Library (MML) is a software that connects to a particular
vendors tape backup system. This is linked to the Oracle executable at installation.
Backup disks must reside on the same machine as the target database. If you are working with a
tape system, then it can reside anywhere. The MML software component ensures connectivity
between RMAN and the tape subsystem. Using Enterprise Manager to control RMAN is
optional.
1-7
1-8
1-9
RMAN Components
The RMAN tool consists of the following components:
RMAN executable
RMAN library file: recover.bsq
Recovery catalog
Tables
Views
RMAN packages
DBMS_RCVMAN
DBMS_RCVCAT
DBMS_BACKUP_RESTORE
1-10
RMAN Components
RMAN executable: The executable translates RMAN commands into a sequence of steps that
operate on the database physical files. It sends the backup, restore, and recovery steps to the
target database for execution, and coordinates and monitors the execution of these steps.
Recovery catalog: The recovery catalog is a repository that stores information relating to the
target database obtained from the target database control file. It contains information about the
physical schema of the target database, data files, archivelog backup sets and pieces, data file
copies, archived redo logs, and stored scripts. If the recovery catalog is not used, then RMAN
queries the target databases control file to decide what actions to perform.
RMAN packages: RMAN uses the DBMS_RCVMAN and DBMS_RCVCAT packages to query,
and update the recovery catalog, respectively. DBMS_BACKUP_RESTORE is the RPC interface
to the code that physically performs the backup, restore, and recovery actions. Note that these
packages are used by RMAN and it is extremely rare that a DBA would need to access them
directly.
The recover.bsq file: The recover.bsq file is also called the RMAN library file.
RMAN Components
1-11
Target database
Control file fixed tables and views
Channel (Server Sessions)
Media management interface module
Media Manager Server
1-12
RMAN Executable:
The recover.bsq File
1-13
Recovery Catalog
1-14
Recovery Catalog
The recovery catalog is a set of tables, views, indexes, and PL/SQL packages, which are created
in a schema known as the recovery catalog owner. The recovery catalog consists of several
components, which include:
Base tables and indexes: These tables and indexes need not be queried.
RC_* views: RC_* views can be queried. These views will be covered in more detail in
lesson 5.
DBMS_RCVMAN package: RMAN queries the recovery catalog tables via the procedures in
this package. RMAN never selects data directly from the recovery catalog tables; it uses
views.
DBMS_RCVCAT package: RMAN updates the recovery catalog tables via the procedures in
this package. RMAN never updates the recovery catalog tables directly.
Target Database:
Control File Tables and Views
1-15
V$BACKUP_ASYNC_IO
V$BACKUP_CORRUPTION
V$BACKUP_DATAFILE
V$BACKUP_DEVICE
V$BACKUP_PIECE
V$BACKUP_REDOLOG
V$BACKUP_SET
V$CONTROLFILE_RECORD_SECTION
V$COPY_CORRUPTION
V$DATABASE
V$DATAFILE
Target Database:
DBMS_BACKUP_RESTORE
1-16
DBMS_BACKUP_RESTORE
DBMS_BACKUP_RESTORE is the RPC interface to the code that physically performs the
backup, restore, and recovery actions that are requested by RMAN.
Because it is linked to the Oracle executable, DBMS_BACKUP_RESTORE can be called
whenever an instance is started; the database does not need to be mounted or open.
Target Database:
DBMS_BACKUP_RESTORE
1-17
Target
database
1-18
Server
session
Channel (disk)
Server
session
Channel (sbt)
RMAN
Individually:
RMAN> backup database;
In a RUN block:
RMAN>
2>
3>
4>
run {
copy datafile 10 to
'/oracle/prod/backup/prod_10.dbf';
}
1-19
Note that you do not need to run ALLOCATE CHANNEL if you already did so within the script
or if you have automatic channels configured.
The CREATE SCRIPT command is used to create a stored script and is covered in detail in a
later lesson.
Remote operations
Set up the password file
Ensure that the password file is backed up
1-20
1-22
Database Inconsistency
Constraint inconsistency
Logical inconsistency
Structural inconsistency
Physical inconsistency
At the block level
At the inter-block level
1-24
1-26
1-27
Redo Generation
Redo is generated whenever any data block changes for whatever reason. Recall that the data file
header is a special data block, and that the control file, too, is read and written in blocks (but not
cached data blocks like the data files).
When a transaction generates redo, it also generates undo, which in turn generates more redo. In
practice, this is done backward: the server code first generates all the redo, then the undo, and
lastly the data change. The amount of redo generated can be controlled by the use of the
NOLOGGING clause. You can see the amount of redo generated in V$SYSSTAT in the row
redo size.
Undo Generation
Undo cannot be suppressed. It is the same mechanism regardless of whether you use automatic
undo management or manually-managed rollback segments.You can see the amount of undo
generated in V$ROLLSTAT under the column WRITES, and V$TRANSACTION under the
columns USED_UBLK and USED_UREC.
Recovery Concepts
1-28
No generation of redo.
Recovery Concepts
For all redo vectors:
The data block address (DBA) specified in the vector is read into the cache.
If the block has the same time as the redo record, then the redo vector is applied.
The block is written out by a recovery checkpoint at a log switch or when aged out of
cache.
The method that determines whether or not a block needs recovery allows for the situation that
blocks inside the data file were written between the full checkpoints. The start of redo is
determined by the file header and is a safe starting point. The recovery decision process also
facilitates recovery being reapplied repeatedly, or restarted after a crash while applying redo.
The redo will be applied only if the redo and block match in time. Note that the word time
refers to the logical time line as given by the SCN and SEQ (sequence) and not to any
timestamp. This also makes the recovery process safe against changes of the clock such as
daylight savings time. There is no redo generated while performing recovery. The control file is
also modified, tracking the progress of the recovery.
1-29
Stuck Recovery
1-31
Stuck Recovery
Stuck recovery should cause a trace or a dump, typically ORA-600[3020]. To progress past a
stuck recovery, the block must be marked corrupt because there is no consistent information
about what the block content should be.
In Oracle9i, this is performed with either ALLOW 1 CORRUPTIONS, or with TEST in the
recover command.
Test Recovery
Oracle9i introduced test or trial recovery. Test recovery is a dry run of a media recovery,
reading and modifying data blocks, but not writing the changes back to disk. During normal
recovery, if there is any serious error, then the recovery will stop. After correcting the error, the
recovery is attempted again, and possibly fails at the next error. Test recovery is used to see how
many such serious errors might occur. Depending on the answer, a different recovery scenario
might be attempted. Test recovery can also mark blocks as corrupt. Data cannot be retrieved
from such blocks, but can be skipped.
1-32
Summary
In this lesson, you should have learned how to:
Explain the fundamentals of the RMAN
architecture and its components
Describe the basic backup structures
Identify the features, components, and tasks of
RMAN
1-33
Configuring RMAN
Objectives
After completing this lesson, you should be able to do
the following:
Explain RMAN configuration decisions
Outline the steps that are involved in creating a
recovery catalog
Create and grant privileges to an RMAN user
Start RMAN and register a database in a recovery
catalog
Demonstrate the use of recovery catalog
maintenance commands such as RESYNC,
CONFIGURE, and CATALOG
2-2
2-3
Issues to Consider
The following are some issues to consider when
deciding whether to use a recovery catalog or not:
If the control file is lost and you need to restore
and recover the database (Oracle8i), then you
require the assistance of Oracle Customer
Support Services.
Point-in-time recovery (PITR) can be difficult or
impossible.
Overheads are incurred in the use of a recovery
catalog.
2-4
Issues to Consider
RMAN can be configured to use a recovery catalog in addition to the target databases control
file. Some complications that are related to not using a recovery catalog include:
Losing a control file with a need to restore and recover. If the database is pre-Oracle9i,
Oracle Customer Support Services can only help if the user maintains excellent records
(that is, RMAN message log files) of which files were backed up, the date on which the
backup occurred, and the names of the backup pieces.
Point-in-time recovery may be more difficult if the database schema has changed since the
point that you want to recover until, especially if there are data files that existed then but
do not exist now. Such a recovery cannot be automated with RMAN. You must first restore
a backup control file that knows about the physical schema that existed at the recovery
time.
If the database uses a large number of data files (more than 1000), then backup and restore
performance is better with a recovery catalog. If not using a recovery catalog, multiple backups
of the control file should be kept on different disks, tapes, and/or machines. These backups must
be restorable without RMAN.
2-5
2-6
SQL>
2
3
4
2-7
2-8
2-9
2-10
2-11
Starting RMAN
There are many ways that a user can start RMAN depending on how RMAN was configured and
of course the users current needs. In addition to the methods demonstrated in the slide above,
RMAN can also be started in the following ways:
By connecting to a target database (either locally or remotely) when using a password file
and specifying a net service name in the target connect string while not using a recovery
catalog:
$ rman target_db internal/secret@prod rcvcat rman/rman@rcat
By connecting to a target database (either locally or remotely) when using a password file
and specifying a net service name in the target connect string, no recovery catalog:
$ rman target scott/tiger@prod nocatalog
2-12
Each net service name must specify one and only one instance. You cannot specify a net service
name that uses Oracle Net features to distribute connections to more than one instance.
Although RMAN connects to only one instance for its initial target connection, note that this
does not preclude running a backup against all three instances. For example, you can configure
automatic channels to connect to each instance, then make a whole database backup by running
the BACKUP DATABASE command.
2-13
2-14
Registering a Database
in a Recovery Catalog
2-15
2-16
2-17
Noncircular reuse
Resync requires a read-consistent image of the
control file, thus there is a need for snapshot.
2-18
2-19
2-20
2-21
When RMAN needs to resynchronize from a readconsistent version of the control file, it creates a
temporary snapshot control file.
RMAN needs a snapshot control file only when
resynchronizing with the recovery catalog or when
making a backup of the current control file.
The control file is created the same way as
if running the command:
ALTER DATABASE BACKUP CONTROLFILE
Note that if one RMAN job is already backing up the control file while another needs to create a
new snapshot control file, you may see the following message:
waiting for snapshot controlfile enqueue
Under normal circumstances, a job that must wait for the control file enqueue waits for a brief
interval and then successfully retrieves the enqueue. RMAN makes up to five attempts to get the
enqueue and then fails the job. The conflict is usually caused when two jobs are both backing up
the control file, and the job that first starts backing up the control file waits for service from the
media manager.
Persistent RMAN
Configuration Parameters
2-23
Retention Policies
2-24
Retention Policies
A retention policy describes which backups will be kept and for how long. The value of the
retention policy is set by the CONFIGURE command. The best practice is to establish a period of
time during which it will be possible to discover logical errors and fix the affected objects by
doing a point-in-time recovery to just before the error occurred. This period of time is called the
recovery window. This policy is specified in number of days. For each data file, there must
always exist one backup which satisfies the condition:
SYSDATE - CHECKPOINT_TIME <= recovery_window
For example, if the policy were to be set as follows:
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
2-25
2-26
2-27
ORA_DISK_1
ORA_SBT_TAPE_2
Automatic channel allocation also applies to maintenance commands. If you manually allocate a
maintenance channel by using ALLOCATE CHANNEL FOR MAINTENANCE, then RMAN
uses the following convention for channel naming: ORA_MAINT_devicetype_n.
For example, RMAN uses these names for two manually allocated disk channels:
ORA_MAINT_DISK_1 and ORA_MAINT_DISK_2
RMAN knows the command that is being run. For backups, only a single type of channel is
allocated. For restores, RMAN knows which device types are required, and thus allocates all
necessary channels.
2-28
2-29
2-30
2-31
The CONFIGURE EXCLUDE command excludes tablespaces from whole database backups. This
is useful in preventing repeated backups of read-only or offline tablespaces. Note that the system
tablespace may not be excluded.
RMAN> CONFIGURE EXCLUDE FOR TABLESPACE SAMPLE;
By using the CONFIGURE command, the user can adjust the level of parallelism for backup,
restore, and maintenance operations. For tape (SBT), the degree of parallelism should be set to
the number of physical tape drives. Otherwise, degradation will occur. For example:
RMAN> CONFIGURE DEVICE TYPE SBT PARALLELISM 2;
The CONFIGURE DEFAULT DEVICE command specifies which device type is used for
automated backups. Valid values for device_type_spec are DISK or SBT. The default
value is DISK.
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO SBT;
Many elements of RMAN scripts are repetitive and are usually identical in every script. It is
possible to enter and store a persistent configuration that describes such repetitive elements such
as the number and type of channels that will be used or the degree of parallelism.
Also, it is no longer necessary to use the RUN{} syntax for most scripts.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 2-31
2-32
2-33
Catalog of Consistent
and Inconsistent Copies
For a user-managed copy to be cataloged, it must be:
Accessible on disk
A complete image copy of a single file
Either a data file copy, control file copy, or an
archived redo log copy
2-34
2-35
2-36
These rows indicate that the catalog was created with a release 8.1.7 executable, then upgraded
to release 9.0.1, and finally upgraded to release 9.2.0. The current version of the catalog schema
is 9.2.0.
2-37
2-38
Summary
In this lesson, you should have learned how to:
Explain RMAN configuration decisions
Outline the steps that are involved in creating a
recovery catalog
Create and grant privileges to an RMAN user
Start RMAN and register a database in a recovery
catalog
Demonstrate the use of recovery catalog
maintenance commands such as RESYNC,
CONFIGURE, and CATALOG
2-39
Practice Overview:
Configuring RMAN
This practice covers the following topics:
Starting RMAN and connecting to a target
database
Creating a recovery catalog
Registering a database
Querying relevant views in the repository
2-40
Objectives
After completing this lesson, you should be able to do
the following:
Identify the types of backups that are supported
by RMAN
Define a file copy backup, and identify its contents
Define a backup set, its types, contents, and
purpose
Identify the difference between an incremental
backup and a cumulative incremental backup
Outline the RMAN backup algorithm
Demonstrate a working knowledge of the BACKUP
command functionality
3-2
RMAN Backups
3-3
RMAN Backups
Run backups of any of the following objects with the RMAN BACKUP command when the
database is either mounted or open:
Primary or standby database
Tablespace
Data file (current or image copy)
Archived redo log
Control file (current or image copy)
Server parameter file (currently in use)
Backup set
The BACKUP command backs up database files into one or more backup sets on disk or tape.
You can set parameters for the BACKUP command to specify the filenames for the backup
pieces, the number of files to go in each set, and which channel should operate on each input
file. You can make RMAN backups when the database is open or closed. Closed backups can be
consistent or inconsistent, depending on how the database was shut down. RMAN backups are
further divided into full and incremental backups. Full backups are nonincremental, that is, every
used block is backed up.
Interactively:
RMAN> backup database;
3-4
After the RMAN prompt is displayed, you can enter commands such as the following:
RMAN> BACKUP DATABASE;
RMAN> BACKUP SPFILE;
Stored scripts
A stored script is a block of RMAN job commands that is stored in the recovery catalog. To
create a stored script, enter the script interactively into the RMAN command-line interface. You
must be connected to a target database and recovery catalog. An example of stored script
creation and execution is as follows:
RMAN> CREATE SCRIPT backup_whole_db
{
# back up whole database and archived logs
BACKUP
TAG backup_whole
DATABASE PLUS ARCHIVELOG;
}
Oracle9i Database: Advanced Backup and Recovery Using RMAN 3-4
View your stored scripts by querying the recovery catalog view RC_STORED_SCRIPT:
SQL> SELECT * FROM RC_STORED_SCRIPT;
DB_KEY DB_NAME SCRIPT_NAME
------ ------- ----------------------------1
RMAN
full_backup
1
RMAN
incr_backup_0
1
RMAN
incr_backup_1
1
RMAN
incr_backup_2
1
RMAN
log_backup
The following example runs a command file from the RMAN prompt:
RMAN> @/u01/backups/cmd_files/backup_db.rman
Backup Tags
3-6
Backup Tags
A character string called a tag may be assigned to backup sets and image copies. A tag is a caseinsensitive name for a backup set or file copy such as weekly_backup. You can specify the
tag rather than the filename when executing the RESTORE or CHANGE command. The maximum
length of a tag is 30 characters.
RMAN now creates a tag for backups and copies (if you do not specify a tag name) in the format
TAGYYYYMMDDTHHMMSS, where YYYY is the year, MM is the month, DD is the day, HH is
the hour (in 24-hour format), MM is the minutes, and SS is the seconds. The date and time refer
to when RMAN started the backup. For example, a backup of data file 1 may receive the tag
TAG20020208T133437. When applied to a backup set, a tag applies to a specific copy of the
backup set. If the backup set is not duplexed, then a one-to-one relationship exists between the
tag and the backup set.
Tags do not need to be unique, so multiple backup sets or image copies can have the same tag
name, for example, wkly_bkup. When a tag is not unique, then with respect to a given data
file, the tag refers to the most current suitable file. By default, RMAN selects the most recent
backups to restore unless qualified by a tag or a SET UNTIL command. The most current
suitable backup containing the specified file may not be the most recent backup, as can occur in
point-in-time recovery.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 3-6
RMAN-Managed Backups
RMAN-managed backups:
File copy
A file copy is an exact image copy of the original file
that was created by the COPY command.
A file copy can only be written to a disk.
File copies contain only a single input file (data file,
archivelog, or control file).
Backup set
A backup set is a logical object containing backups
of one or more data files or archived logs.
A backup set is created by the BACKUP command.
3-7
RMAN-Managed Backups
File copies
File copies can be performed through RMAN or the host operating system. Operating system
backups on disk can be cataloged in the recovery catalog for immediate use. After the operating
system backups have been cataloged, they can then be backed up by RMAN to a disk or through
the Media Management Layer. The LEVEL 0 option to the CATALOG command allows
operating system backups to be used as a basis for incremental backups. RMAN-initiated file
copies are like OS copies in that all blocks of the file are copied whether they contain data or
not. Because of this, all copies are considered to be LEVEL 0.
run {
allocate channel d1 type disk;
copy level 0 datafile 1 to '/oracle/prod/backup/file1.dbf';
}
Backup sets
A backup set consists of one or more physical output files that are called backup pieces. Backup
sets usually contain multiple source files that are multiplexed in the output. It can be written to a
disk or tertiary storage, which requires media manager support. A restore operation is required to
extract files from a backup set.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 3-7
Backup Sets
There are two types of backup sets:
Data file backup sets
Can include the control files
Can be Incremental or Full backups
Do not include empty blocks
Datafile
4
Datafile
1
Datafile
3
Datafile
2
Control
file
Datafile
2
Datafile
4
Backup
set 1
Backup
set 2
Datafile
3
3-9
Control
file
Backup
set 3
Backup Sets
You can back up data files, control files, archived redo logs, and the current server parameter
file. A backup set contains one or more physical files that are called backup pieces. Archived
logs can be backed up also, but they require a separate set. You can also back up another backup
set, as when you want to back up a disk backup to a tape, or an image copy. For example, you
can issue commands such as the following, each of which uses an automatic channel
configuration:
RMAN> BACKUP DATABASE;
RMAN> BACKUP TABLESPACE users, tools;
When backing up data files, the target database must be mounted or open. If the database is in
ARCHIVELOG mode, then the target can be open or closed: you do not need to close the
database cleanly. If the database is in NOARCHIVELOG mode, then you must close it cleanly
before making a backup.
Data file backup sets do not include empty blocks. An empty block is a block that has never
contained data. If a block has been used, but is no longer part of an allocated extent, then it is
still backed up because the backup process does not have access to space management
information. This is a source of some confusion because some users think that RMAN will omit
blocks that do not currently contain data. For example, if a table is dropped, then RMAN will
continue to back up the blocks even though the extents that are used by that table are now free.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 3-9
3-10
%D specifies the current day of the month from the Gregorian calendar in format DD.
%F combines the database ID (DBID), day, month, year, and sequence into a unique and
repeatable generated name.
%p specifies the piece number within the backup set. This value starts at 1 for each backup
set and is incremented by 1 as each backup piece is created.
%t specifies the backup set time stamp, which is a 4-byte value derived as the number of
seconds that have elapsed since a fixed reference time.
This is a partial list of format identifiers. For more information about format identifiers, refer to
Oracle9i Recovery Manager Reference.
3-11
Backup set
Datafile
1
Datafile
2
Datafile
3
3-12
Server
process
(channel)
Datafile
1,2,3,1,2,3
MML
Tape
Datafile
4
Datafile
5
Backup Set 2
Datafile
2
Datafile
3
Datafile
9
Backup Set 3
Datafile
6
3-13
Datafile
7
Datafile
8
Server
process
(channel)
MML
Set 1
Server
process
(channel)
MML
Set 2
Server
process
(channel)
MML
Set 3
The CONFIGURE DEVICE TYPE ... PARALLELISM command specifies the number of
channels that RMAN uses when allocating automatic channels for a specified device type.
ORA_SBT_TAPE_1
ORA_SBT_TAPE_2
ORA_SBT_TAPE_3
You can change a parallelism setting by issuing another CONFIGURE DEVICE TYPE...
PARALLELISM command.
3-15
Backup Pieces
Datafile
4
Datafile
5
Datafile
3
Datafile
9
Piece 1
Channel
MML
Piece 2
Set 1
Channel
MML
Set 2
Backup Pieces
Each backup set contains at least one backup piece. If you do not restrict the backup piece size,
then every backup set contains only one backup piece. To restrict the size of each backup piece,
specify the MAXPIECESIZE option of the CONFIGURE CHANNEL or ALLOCATE CHANNEL
commands. This option limits backup piece size to the specified number of bytes.
RMAN> ALLOCATE CHANNEL DEVICE TYPE DISK MAXPIECESIZE = 2G;
You can either let RMAN determine a unique name for backup pieces or use the FORMAT
parameter to specify a name. If you do not specify a filename, then RMAN uses the %U
substitution variable to generate a unique name.
RMAN automatically generates unique names for the backup pieces. The FORMAT parameter
provides substitution variables that you can use to generate unique filenames. For example, you
can run a command as follows:
RMAN> BACKUP TABLESPACE user FORMAT = '/tmp/user_%u%p%c';
Format can be specified in three places, and will be used in the following precedence:
1. BACKUP OBJECT
2. BACKUP COMMAND
3. ALLOCATE/CONFIGURE CHANNEL
3-17
Database ID
Piece number
Set stamp, set count
Type of backup
How many directory blocks follow the piece header
Level 0
Day
Sun
3-18
2
Mon
2
Tue
1
Wed
2
Thu
2
Fri
2
Sat
0
Sun
Level 0
Day
Sun
3-19
2
Mon
2C
Tue
1
Wed
2
Thu
2C
Fri
2C
Sat
0
Sun
3-20
3-21
Algorithm Rules
The most important rules in the algorithm for creating
a backup set are:
Each allocated channel that performs work in the
backup job generates at least one backup set
containing at least one piece.
RMAN will calculate FILESPERSET parameter of
the BACKUP command if it is not set.
3-22
Algorithm Rules
The basic backup algorithm follows several important tenets when creating backup sets. Each
allocated channel that performs work in the backup jobthat is, each channel that is not idle
generates at least one backup set. By default, this backup set contains one backup piece. RMAN
always tries to divide the backup load so that all allocated channels have roughly the same
amount of work to do.
The basic algorithm determines the number and size of the backup pieces by balancing the
FILESPERSET and MAXSETSIZE (if used) parameters of the BACKUP command. The
FILESPERSET parameter of the BACKUP command determines the maximum number of data
files in each backup set. If none is specified, RMAN will calculate this figure by comparing the
value 64 to the rounded-up ratio of number of files divided by the number of channels, and sets
FILESPERSET to the lower value. For example, if you are backing up 140 files and allocating
two channels, RMAN divides 140 by two, compares the resultant 70 to 64 and chooses 64 as the
value for FILESPERSET.
The maximum size of a backup set is determined by the MAXSETSIZE parameter of the
CONFIGURE or BACKUP command. When you set this, RMAN uses the algorithm to determine
the number of files to write to each set.
Advanced Algorithm
3-24
Advanced Algorithm
The advanced algorithm uses the same factors as the basic algorithm to determine the number
and size of backup sets. The difference is that the advanced algorithm is also influenced by the
DISKRATIO parameter. If DISKRATIO = n, then each backup set must read data from at
least n disk drives. RMAN uses file location information obtained from the database server to
determine which data files are present on which disk drives.
If you set FILESPERSET but not DISKRATIO, then DISKRATIO defaults to the same value
as FILESPERSET. If you specify neither parameter, then DISKRATIO defaults to 4. RMAN
compares DISKRATIO to the number of devices and uses the lowest value.
Assume that a database contains 50 data files spread across six disks, and the operating system is
able to deliver this disk contention information to the server. You configure a single sbt
channel and then run BACKUP DATABASE.
RMAN uses the advanced algorithm for the reason that the basic algorithm indicates that
because you did not specify FILESPERSET or MAXSETSIZE, RMAN should produce a single
backup set. The advanced algorithm also looks at DISKRATIO, which in this case defaults to 4.
Therefore, each backup set must contain data files from at least four disks. Because RMAN is
only producing one backup set containing all data files from all six disks, DISKRATIO makes
no difference.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 3-24
3-25
3-26
3-27
3-28
Backup Optimization
3-29
Backup Optimization
If you enable backup optimization, then the BACKUP command skips the backup of a file when
the identical file has already been backed up to the allocated device type. If RMAN determines
that a file is identical and it has already been backed up, then it is a candidate for skipping.
However, RMAN must do further checking to determine whether to skip the file, because both
the retention policy feature and the backup duplexing feature influence the algorithm that
determines whether RMAN has enough backups on the specified device type.
With backup optimization, the BACKUP command skips the backup of a file if the identical file
has already been backed up to the allocated device type. To override this behavior and back up
all files whether they have changed or not, specify the FORCE option of the BACKUP command.
To enable or disable backup optimization, specify ON or OFF with the CONFIGURE BACKUP
OPTIMIZATION command.
Backup set
Same backup set record ID and stamp
3-30
In this case, RMAN sets n = 3 and so will not back up the logs that were created before 9 a.m.
because three copies already exist on tape. However, only two copies of the logs that were
created after 9 a.m. exist on tape, so RMAN does not optimize backups of these logs. Therefore,
RMAN backs up three copies of the logs that were created after 9 a.m.
Duplexed Backups
Datafile
1
Datafile
2
Datafile
1
Datafile
1
Datafile
2
Datafile
2
BACKUP1
BACKUP2
Backup set
3-32
Duplexed Backups
Multiple or duplexed backup copies can be made by using the SET BACKUP COPIES command
when running your backup. Use the SET BACKUP COPIES command before allocating any
channels. The SET BACKUP COPIES command affects all channels that were allocated after
issuing the command. Duplexed backups require a FORMAT specification that guarantees
uniqueness.
Duplexed Backups
Backup duplexing provides an efficient way to
produce multiple copies of each backup piece.
Duplexing requires the COPIES option:
RMAN> BACKUP DEVICE TYPE DISK COPIES 3 DATAFILE
2> 7 FORMAT '/tmp/%U','?/oradata/%U','?/%U';
3-33
Mirrored Backups
3-35
Mirrored Backups
When making mirrored backups it is possible to specify up to four different locations with the
format option. The second, third, and fourth values are used in conjunction with the SET
BACKUP COPIES command. RMAN will use the first format value for copy 1, the second
format value for copy 2, and so on. If more format values are specified than copies, then the
extra format values will be discarded. If there are more copies specified than format values, then
the format values will be reused starting with the first value. The following example illustrates
this concept:
RMAN> SET BACKUP COPIES 3;
RMAN> BACKUP DATABASE FORMAT '/U01/backups/%U','/U02/backups/%U';
As a result, the first copy is placed in /u01/backups, the second copy is placed in
/u02/backups, and the third copy is placed in /u01/backups.
Proxy Copy
3-36
Proxy Copy
A proxy copy is a special type of backup in which RMAN turns over control of the data transfer
to a media manager that supports this feature. The PROXY option of the BACKUP command
specifies that a backup should be a proxy copy. For each file that you attempt to back up by
using the BACKUP PROXY command, RMAN queries the media manager to determine whether
it can perform a proxy copy. If the media manager cannot proxy copy the file, then RMAN uses
conventional backup sets to perform the backup. An exception occurs when you use the PROXY
ONLY option, which causes the Oracle server to issue an error message when it cannot proxy
copy.
The Oracle server records each proxy-copied file in the control file. RMAN uses this data to
resynchronize the recovery catalog. Use the V$PROXY_DATAFILE view to obtain the proxy
copy information. Use the CHANGE PROXY command or DELETE PROXY command to change
the status of or delete a proxy backup respectively.
You can monitor the progress of proxy copies, backups, regular copies, and restores by querying
the view V$SESSION_LONGOPS. RMAN uses two types of rows in V$SESSION_LONGOPS:
detail and aggregate rows. Detail rows describe the files that are being processed by one job step,
whereas aggregate rows describe the files that are processed by all job steps in an RMAN
command.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 3-36
3-37
Now your backups exist on both disk and tape. You can also duplex backups of backup sets
(except for control file autobackups), as in this example:
RMAN> BACKUP COPIES 2 DEVICE TYPE sbt BACKUPSET ALL;
Note: If backup optimization is enabled when you issue the command to back up a backup set
and the identical backup set has already been backed up to the same device type, then RMAN
skips the backup of that backup set.
3-38
3-39
Please note that only the archivelog backed up is deleted. This is an important issue when using
multiple archivelog destinations.
Long-Term Backups
3-40
Long-Term Backups
The KEEP option can be used with the CHANGE, COPY, or BACKUP commands to allow the
backups to be kept until the time specified by the UNTIL TIME option regardless of the
retention policy.
If the backup should never expire, then use the FOREVER option, but keep in mind that a
recovery catalog is required when this option is used. The use of the LOGS option ensures that
the backup can be recovered to any point in time as the required archive logs will be kept in
support. This is the default behavior. If NOLOGS is specified, then the supporting archive logs
will not be kept. This means that this backup cannot be used in database recovery. The backup
will be limited to restore the database only to the point in time that the backup was performed.
NOKEEP specifies that the backup will not be kept beyond the window that is defined by the
retention policy; this is the default.
Some examples:
RMAN> BACKUP DATABASE KEEP UNTIL TIME
2> "to_date('31-MAR-2002','DD_MM_YYYY)" nologs;
RMAN> BACKUP TABLESPACE SAMPLE KEEP FOREVER NOLOGS;
3-41
If the backup validation discovers corrupt blocks, then RMAN updates the
V$DATABASE_BLOCK_CORRUPTION view with rows describing the corruptions. After a
corrupt block is repaired, the row identifying this block is deleted from the view.
Another important use of BACKUPVALIDATE is to identify corrupt blocks and populate the
V$DATABASE_BLOCK_CORRUPTION view, then use the data to repair the blocks with the
BLOCKRECOVER command like this:
RMAN> BACKUP VALIDATE DATABASE;
RMAN> BLOCKRECOVER CORRUPTION LIST;
Note: You cannot use the MAXCORRUPT or PROXY parameters with the VALIDATE option or
validate backups of backup sets.
Restarting a Backup
3-43
Restarting a Backup
Using the restartable backup feature, RMAN can back up only those files that have not been
backed up since a specified date. This feature is intended for cases when a backup fails midway
through and you only want to back up the part of the database that was not backed up. Use the
SINCE TIME parameter of the BACKUP command to specify a date after which a new backup is
required. If you do not specify the SINCE parameter, then RMAN only backs up files that have
never been backed up.
To back up only the files that were not backed up after a specified date, specify a valid date in
the SINCE TIME parameter. For example, this command uses the default configured channel to
back up all database files and archived redo logs that have not been backed up in the last two
weeks:
RMAN> BACKUP NOT BACKED UP SINCE TIME 'SYSDATE-14'
2> DATABASE PLUS ARCHIVELOG;
The unit of restartability is a single backup set. If the entire database is backed up into one
backup set, and if a backup fails, then the entire backup has to be rerun. If the backup generates
multiple backup sets, then the backups that completed successfully do not have to be rerun. For
this reason, you can set FILESPERSET to a value much lower than the default so that RMAN
limits the number of files that it places in each backup set.
3-44
Summary
In this lesson, you should have learned how to:
Identify the types of backups that are supported
by RMAN
Define a file copy backup, and identify its contents
Define a backup set, its types, contents, and
purpose
Identify the difference between an incremental
backup and a cumulative incremental backup
Outline the RMAN backup algorithm
Demonstrate a working knowledge of the BACKUP
command functionality
3-45
Practice Overview:
Backups with RMAN
This practice covers the following topics:
Creating a cold backup
Using the CATALOG command
3-46
Objectives
After completing this lesson, you should be able to do
the following:
Identify the tasks that are performed by RMAN
before restoring
Identify the RESTORE functionality
4-2
4-3
4-4
4-5
Restore Optimization
4-6
Restore Optimization
RMAN restores a file only if the header check does not succeed. By using the FORCE option of
the RESTORE command it is possible to override this behavior and restore the requested files
unconditionally. Understand however, that restore optimization only checks the data file header
and does not the scan the data file body for corrupted blocks.
Restore optimization is particularly useful in cases where a restore only partially completes. For
example, assume that your system or instance crashed during a full database restore. If you start
the same restore after startup, RMAN will only restore the data files that were not restored
during the previous attempt. With the ever-increasing size of databases, this time-saving feature
is extremely important.
Or
A new location using the SET NEWNAME command
RUN {
SET NEWNAME FOR datafile
'/u01/oradata/tools01.dbf'
TO '/tmp/tools01.dbf';
RESTORE datafile '/u01/oradata/tools01.dbf';
}
Restore a tablespace:
RMAN> RESTORE TABLESPACE tools;
4-7
When RMAN performs a restore, the restored files are created as data file copies and recorded in
the repository. If the SWITCH command is run in conjunction with the SET NEWNAME
command, then RMAN updates the data file names in the control file to the names of the
restored files; otherwise this update does not take place. When restoring data files or tablespaces,
the database can be up but the data files or tablespaces must be offline:
RMAN>
RMAN>
RMAN>
RMAN>
4-8
4-9
Within a run command, you can override the LOG_ARCHIVE_DEST location if needed and
restore the archived logs:
RUN
{
SET ARCHIVELOG DESTINATION TO '/u02/tmp_restore';
RESTORE ARCHIVELOG ALL;
# restore datafiles as needed
}
Oracle9i Database: Advanced Backup and Recovery Using RMAN 4-9
Using a catalog:
RMAN> RESTORE SPFILE;
Without a catalog:
RMAN> RESTORE SPFILE FROM AUTOBACKUP;
4-10
Next, shutdown the instance and restart without mounting and restore the SPFILE:
RMAN> STARTUP FORCE NOMOUNT
RMAN> RESTORE SPFILE;
Finally, restart the instance. If the server parameter file was restored to a nondefault location,
then the steps are slightly different.
The SPFILE now resides in a location that is different from what was originally specified in the
initialization parameter file. Create a temporary file with a pointer to the restored SPFILE
location. Using the HOST command, it is possible to create the file without exiting the RMAN
prompt by using the UNIX echo command:
RMAN> HOST 'echo "SPFILE=/tmp/spfileTEMP.ora" > /tmp/init.ora';
Start the instance by using the temporary parameter file and SPFILE:
RMAN> STARTUP FORCE PFILE=/tmp/init.ora;
4-12
A common cause of this error is that the data file backups that are being used for the duplication
are inconsistent. Most likely an ALTER SYSTEM ARCHIVE LOG CURRENT command was
not executed after the data file backup is completed. Because of this, RMAN is looking for the
necessary redo records in the online redo logs.
To address this, use the set until command to specify a log sequence number for
incomplete recovery when creating the duplication script. For example, to stop recovery at log
sequence 6, the script might look like this:
run {
set until logseq 6 thread 1;
allocate auxiliary channel dupdb1 type disk;
duplicate target database to dupdb;
}
4-14
4-15
If you see an error message stack and output similar to the following example, then there is a
problem with the restore of the specified file:
RMAN-03009: failure of restore command on c1 channel at 12-DEC-01
23:22:30
ORA-19505: failed to identify file "oracle/dbs/1fafv9gl_1_1"
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
If you do not see an error stack, then RMAN has successfully validated the files.
Restore Autolocation
4-17
Restore Autolocation
In a Real Application Clusters configuration, RMAN automatically restores backups, control file
copies, and data file copies from channels that can read the files on tape or a local file system. So
long as you configured or manually allocated channels that connect to each node in the cluster,
RMAN hunts for files on all channels and restores files only from those channels that locate the
backup or copy on tape or on a local file system.
For example, if channel 1 that is connected to instance 1 can read log 1000 from its tape drive,
but channel 2 connected to instance 2 cannot read the log from its tape drive, then channel 1
restores the log. Autolocation is automatically enabled when the channels meet any of the
following criteria:
Different PARMS settings
Different connect strings
4-18
4-20
RMAN then queries the repository, which in this example is a recovery catalog. The recovery
catalog obtains its metadata from the target database control file. RMAN then decides which
backup sets to restore and which incremental backups and archived logs to use for recovery. A
server session on the target database instance performs the actual work of restore and recovery.
4-21
4-23
4-24
4-25
4-26
4-27
Tape
4-28
4-29
ORACLE data
datafile 6:
ORACLE data
datafile 2:
You can then specify the corrupt blocks in the BLOCKRECOVER command as follows:
RMAN> BLOCKRECOVER datafile 6 BLOCK 3 datafile 2 BLOCK 235;
4-31
Trial Recovery
4-32
Trial Recovery
In the past, some problems that might occur during media recovery were not recoverable. For
media recovery, this means that you must restore the backup and recover the database again to
an SCN before the point where the corruption occurred. For a large database, this can take a long
time. The following enhancements are now provided:
If media recovery of a full database encounters a problem, then recovery leaves behind a
consistent database, that is a database that can be opened read-only or with resetlogs.
Database administrators can instruct media recovery to mark a data block as being
corrupted and therefore ignore its inconsistency in order to proceed with recovery. The
block will be inaccessible but the rest of the recovery process will continue.
Using another new option of recovery command, database administrators can invoke Trial
Recovery to investigate if a recovery problem is an isolated problem.
Almost all practical problems during media recovery are recoverable, because of an optimistic
redo application algorithm. Recovery optimistically assumes that no problem will occur during
media recovery. If one does occur, then the Oracle server will roll back the last changes that
caused inconsistency in the recovered database.
Note: Trial recovery is a user-managed recovery option. For more information on Trial
Recovery, refer to the Oracle9i User-Managed Backup and Recovery Guide.
4-33
4-34
2. Start the target instance without mounting the database. For example:
STARTUP NOMOUNT;
3. Set the database identifier for the target database. RMAN displays the DBID whenever you
connect to the target. You can also get it by running LIST or querying the catalog.
RMAN> SET DBID 676549873;
4. Restore the autobackup control file, then perform recovery. Specify the most recent
backup time stamp that RMAN can use when searching for a control file autobackup to
restore. If a nondefault format was used to create the control file, then specify a nondefault
format for the restore of the control file. If the channel that created the control file
autobackup was device type sbt, then you must allocate one or more sbt channels.
Because no repository is available, you cannot use automatic channels. However, if the
autobackup was created on a disk channel, then you do not need to allocate a channel
manually.
5. If recovery was successful, then open the database and reset the online logs:
RMAN> ALTER DATABASE OPEN RESETLOGS;
6. You should back up the database immediately, with the database mounted. Because the
database is a new incarnation, the backups made before the RESETLOGS are not easily
usable. Enter:
RMAN>
RMAN>
RMAN>
RMAN>
SHUTDOWN IMMEDIATE
STARTUP MOUNT
BACKUP DATABASE;
ALTER DATABASE OPEN;
4-36
RUN {
ALLOCATE CHANNEL c1 TYPE DISK;
ALLOCATE CHANNEL c2 TYPE DISK;
SET UNTIL TIME = '2002-12-09:11:44:00';
RESTORE DATABASE;
RECOVER DATABASE;
ALTER DATABASE OPEN RESETLOGS; }
Note: If you need to restore archived redo log files to a new location, then use the RMAN
SET ARCHIVELOG DESTINATION TO <location> command.
7. Recover the database to the time specified in the SET UNTIL command:
RMAN> ... recover database;
4-38
RUN {
SET UNTIL SEQUENCE 120 THREAD 1;
ALTER DATABASE MOUNT;
RESTORE DATABASE;
RECOVER DATABASE; # recovers through log 119
ALTER DATABASE OPEN RESESTLOGS;
}
Recovering a NOARCHIVELOG
Database: Example
Assume the following scenario:
The database TRGT operates in NOARCHIVELOG
mode.
A recovery catalog is used.
The database is shut down consistently and a
level 0 backup is made to tape on Sunday
afternoon.
The database is shut down consistently and a
level 1 differential incremental backup is made to
tape at 4:00 a.m. on Wednesday and Friday.
4-39
STARTUP NOMOUNT;
RESTORE CONTROLFILE; # restore control file from consistent backup
ALTER DATABASE MOUNT;
RESTORE DATABASE; # restore datafiles from consistent backup
RECOVER DATABASE NOREDO; # specify NOREDO online redos are lost
ALTER DATABASE OPEN RESETLOGS;
All changes that are generated between the Friday incremental backup and the Saturday failure
are not applied.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 4-39
Examples of BLOCKRECOVER
4-40
Examples of BLOCKRECOVER
1. Recovering a group of corrupt blocks
BLOCKRECOVER datafile 2 BLOCK 12, 13 datafile 7 BLOCK 5, 98, 99
datafile 9 BLOCK 19;
2. This example recovers a series of blocks and restores only from data file copies: RUN {
BLOCKRECOVER datafile 3 BLOCK 1,2,3,4,5
TABLESPACE sales DBA 4194405, 4194409, 4194412
FROM datafile COPY;
}
4. The following example recovers two blocks in the SYSTEM tablespace and forces the
blocks to be restored from backups that were created at least two days ago:
BLOCKRECOVER TABLESPACE SYSTEM DBA 4194404, 4194405 RESTORE UNTIL
TIME 'SYSDATE-2';
The following example recovers two blocks and forces the blocks to be restored by using
backups that were made before log sequence 7024:
BLOCKRECOVER datafile 9 BLOCK 13 datafile 2 BLOCK 19 RESTORE UNTIL
SEQUENCE 7024;
Summary
In this lesson, you should have learned how to:
Identify the tasks that are performed by RMAN
before restoring
Identify the RESTORE functionality
4-42
Practice Overview:
Restore and Recovery with RMAN
This practice covers the following topics:
Familiarizing with DBMS_BACKUP_RESTORE
4-43
RMAN Maintenance
Objectives
After completing this lesson, you should be able to do
the following:
Use the LIST command to display backup data
that is recorded in the catalog or target control file
Use the REPORT command to gather detailed
information about recovery catalog data
Use the CROSSCHECK and DELETE commands
Use the SHOW command to view configuration
details
Use the CHANGE command to alter the status of
object backups
5-2
Restore/Recovery
RMAN
Backup
Enterprise
Manager
Reporting
REPORT
LIST
Catalog maintenance
CROSSCHECK
DELETEEXPIRED
LIST
CHANGE
5-3
Stored
scripts
Catalog
database
DELETE lists specified backup objects and prompts for confirmation to remove them.
5-4
5-5
Inc Key
------2
73
DB Name
-------U02
U02
DB ID
-----------775813490
775813490
CUR
--NO
YES
Reset SCN
---------1
440227
Reset Time
---------06-MAR-02
27-MAR-02
Column
----------File
Key
Indicates
-------------------------------------------------------------------------------------------The absolute data file number
A unique key identifying this backup set. If you are connected to a recovery
catalog, then Key is the primary key of the backup set in the catalog. It
corresponds to BS_KEY in the RC_BACKUP_SET view. If you are connected
in NOCATALOG mode, then Key displays the RECID from
V$BACKUP_SET. RECID and STAMP form a concatenated primary key
that uniquely identifies this record in the target control file.
TY
The type of backup: backup set (B) or proxy copy (P)
LV
The backup level: F for non-incrementals, level 0-4 for incrementals
S
The backup set status: available (A), unavailable (U), or expired (X)
Ckp SCN The checkpoint of the data file at the time it was backed up.All database
changes before the SCN have been written to the file; changes after the
specified SCN have not been written to the file.
Ckp Time The checkpoint of the data file at the time it was backed up. All changes
before the time have been written to the file; changes after the specified time
have not been written to the file.
#Piece
The number of backup pieces in the backup set
#Copies The number of copies made of each backup piece in the set. The number
is 1 if no duplexing was performed. Otherwise, the value ranges from 2
through 4.
Tag
The tag applied to the backup set; NULL if none
5-7
Device Type
----------DISK
DISK
DISK
DISK
DISK
Completion Time
--------------24-MAR-02
24-MAR-02
27-MAR-02
27-MAR-02
27-MAR-02
#Pieces
------1
1
1
1
1
#Copies Tag
------- --1
1
1
1
1
5-8
5-9
2. If you have a retention policy configured, then run REPORT NEED BACKUP
without any other options to determine which files need backups.
RMAN> REPORT NEED BACKUP;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of files with less than 1 redundant backups
File #bkps Name
---- ----- --------------------------------------------2
0
/u01/user02/ORADATA/u02/undo1_01_U02.dbf
3
0
/u01/user02/ORADATA/u03/users_01_U02.dbf
3. If you do not have a retention policy enabled, then run REPORT NEED BACKUP
DAYS n. Any files that are older than the DAYS parameter value need a new backup
because their backups require the specified number of DAYS worth of archived logs
for recovery. For example, run:
RMAN> REPORT NEED BACKUP DAYS = 7 DATABASE; # 7 days of logs to
recover
RMAN> REPORT NEED BACKUP DAYS = 30 TABLESPACE SYSTEM;
4. To determine which files need an incremental backup, specify the INCREMENTAL
parameter. If complete recovery of a data file requires more than the specified
number of incremental backups, then RMAN considers it in need of a new backup.
For example, enter:
RMAN> REPORT NEED BACKUP INCREMENTAL = 1 DATABASE;
RMAN> REPORT NEED BACKUP INCREMENTAL = 3 TABLESPACE SYSTEM;
5-11
5-12
4. Optionally, delete backups that are obsolete with the DELETE OBSOLETE
command.
RMAN> DELETE OBSOLETE;
5-14
K-bytes
------307200
20480
Tablespace
---------SYSTEM
UNDOTB
RB segs
------YES
YES
Datafile Name
---------------------------/oracle/oradata/trgt/system01.dbf
/oracle/oradata/trgt/undotb01.dbf
10240
USERS
NO
/oracle/oradata/trgt/users01.dbf
This type of information is useful for incomplete recovery because you can determine the
schema of the database for the time to which you want to recover.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 5-14
5-15
5-16
5-17
5-18
2. If you do not have automatic channels configured, then allocate a channel for
maintenance.
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
3. Run the DELETE command to eliminate the specified physical files and their
repository records. You can delete any type of object in the recordSpecclause,
for example:
RMAN>
RMAN>
RMAN>
RMAN>
DELETE
DELETE
DELETE
DELETE
BACKUPPIECE 101;
CONTROLFILECOPY '/tmp/control01.ctl';
NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 300;
BACKUP OF TABLESPACE users DEVICE TYPE sbt;
5-20
5-21
Catalog
database
5-22
Summary
In this lesson, you should have learned how to:
Use the LIST command to display backup data
that is recorded in the catalog or target control file
Use the REPORT command to gather detailed
information about recovery catalog data
Use the CROSSCHECK and DELETE commands
Use the SHOW command to view configuration
details
Use the CHANGE command to alter the status of
object backups
5-23
Practice Overview:
RMAN Maintenance
This practice covers the following topics:
Using the LIST command
Using the REPORT command
5-24
Objectives
After completing this lesson, you should be able to do
the following:
Identify how RMAN makes backups to tape
Describe the Media Management Interface
functionality
Identify the two versions of the SBT interface
Link the Oracle server to a media manager
Describe media manager issues and informational
messages
6-2
Backups to Tape
6-3
Backups to Tape
To use tape storage for database backups, RMAN requires a media manager. A media
manager is a utility that loads, labels, and unloads sequential media such as tape drives for
backing up and recovering data. Oracle Corporation publishes a media management API that
third-party vendors can use to build software that works with RMAN. To use RMAN to
make backups to sequential media such as tape, integrate media management software with
your Oracle software. Note that Oracle does not need to connect to the media management
library software when it backs up to disk.
Some media management products can manage the entire data movement between Oracle
data files and the backup devices. Such products may use technologies such as high-speed
connections between storage and media subsystems, which can remove much of the backup
load from the primary database server.
For a list of compliant vendors, and compatibility information, visit the following site:
http://www.oracle.com/database/recovery/index.html?/database/
recovery/backupsp.html
Media Manager
Media Manager architecture
Oracle Media
Server Manager
Session Library
Recovery
Manager
Recovery
Catalog
Control File
6-4
Media
Management
Server
Software
Tape Subsystem
6-5
6-6
Alternatively, you can change the name of the library to libobk.so. For example:
$ mv /vendor/lib/oracle_lib.so
$ORACLE_HOME/lib/libobk.so
6-8
6-9
If you do not receive an error message, then Oracle successfully loaded the shared library.
However, the channel allocation can fail raising the ORA-27211 error:
RMAN-03009: failure of allocate command on c1 channel at 13:57:18
ORA-19554: error allocating device, device type: SBT_TAPE
ORA-27211: Failed to load Media Management Library
Additional information: 25
The ORA-27211 error indicates that the Oracle server was not able to load the media
management library that was installed. In this case, check your media management
installation to make sure that the library is correctly installed and retry. For any other errors,
check the trace file in USER_DUMP_DEST directory for more information.
6-10
Also, you should determine which PARMS settings are needed for the ALLOCATE
CHANNEL or CONFIGURE CHANNEL commands as well as the vendor-recommended
FORMAT string for the BACKUP command (if needed). The PARMS parameter sends
instructions to the media manager. For example, the following vendor-specific PARMS
setting instructs the media manager to back up to a volume pool that is called
oracle_tapes:
PARMS='ENV=(NSR_DATA_VOLUME_POOL=oracle_tapes)'
A hanging backup usually indicates that the media manager is waiting to mount a tape.
Check if there are any media manager jobs in the tape mount request mode and fix the
problem. An ORA-19511 or ORA-70 nnn error indicates that the media management
software is not correctly configured.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 6-10
6-11
2. After configuring the channel, test the backup with the following command:
RMAN> BACKUP DEVICE TYPE sbt DATAFILE 1;
4. Configure the default device to sbt. By configuring the device to sbt, RMAN will
automatically send all backups to the media manager. For example:
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt;
7. If you use more than one media manager, then you must specify the channel
parallelism. Assume that you want to back up to your media manager by using two
tape drives in parallel. In this case, you can run the following commands:
RMAN> CONFIGURE DEVICE TYPE sbt PARALELLISM 2;
RMAN> BACKUP DATABASE; # Backup goes to tape but in two streams in parallel
(two tapes)
6-13
allocate channel c1
type 'sbt_tape'
'ENV=SBT_LIBRARY=oracle.disksbt,
(BACKUP_DIR=/your/backup/directory)';
6-14
6-15
If there is more data to be backed up, then the algorithm returns to step 4.
9. After the Oracle server sessions backs up all data, it calls sbtend() to clean up and
release resources. After sbtend() returns, the channel is released and the server
session terminates.
6-16
6-17
sbttest
It tests whether the MML is installed, and can accept
and return an identical data stream.
sbtio.log
This is the trace file that the media management
product may use to write debugging/trace
information.
It is found in USER_DUMP_DEST, or by default on
UNIX systems in $ORACLE_HOME/rdbms/log.
6-18
6-19
If the media manager function causes a core dump, then the trace file contains some of
the SBT functions in the stack trace. For example, if sbtinfo2() core dumps, then the
stack may look like the following:
ssexhd()+380 CALL ksedmp()+0
sigacthandler()+40 PTR_CALL 00000000
free_sbtinfo2_mem PTR_CALL 00000000
sbtinfo2()+744 CALL free_sbtinfo2_mem
skgfgsm()+244 PTR_CALL 00000000
skgfgsi()+184 CALL skgfgsm()+0
skgfcls()+888 CALL skgfgsi()+0
kgffsubmit()+12928 CALL skgfcls()+0
What was happening at the time of failure? Remember, the sbtinfo2() function
requests the media manager to return the mediumID, location, and expiration time of the
backup medium on which the backup piece is stored.
6-22
The SBT disk library provided by Oracle can be loaded without removing the existing MML
and the library can back up to /dev/null. For example:
RUN {
ALLOCATE CHANNEL tst TYPE SBT FORMAT '/dev/null'
PARMS='SBT_LIBRARY=oracle.disksbt, ENV=(BACKUP_DIR=/tmp)';
BACKUP DATABASE; }
These tests are important when you suspect that the MML is causing problems in Oracle
server functions.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 6-22
6-23
The trace output indicates exactly which are the environment variables that are set in the
Oracle Server session. For example, if the channel has the option
PARMS=ENV=(NB_ORA_CLASS=class1), then the trace output displays the
following::
skgfidev(): processing: ENV=(NB_ORA_CLASS=fdfa)
skgfidev(): setting environment variable: NB_ORA_CLASS=fdfa
Running a backup with the TRACE=1 option also indicates whether a function is hanging.
For example:
skgfwrt(ctx=0x262bf98, file=0x2647f08, iosb=0x2647cf4,
buf=0x815b0000, numblks=1)
skgfwrt(data=13020000 00000001 0003A1B1 00000104)
entering sbtwrite on line 903
If there is no more information logged after this, then the function sbtwrite is hung.
Note: The other possible trace levels are 0 and 2. A trace level 0 traces all error
conditions that result in a return code of -1 from an SBT function, except
SBT_ERROR_EOF and SBT_ERROR_NOTFOUND, which are handled by the client. A
trace level 2 traces the entry and exit from each SBT function, the value of all function
parameters, and the first 32 bytes of each read/write buffer, in hexadecimal. The read
buffer is traced upon function entry and the read buffer is traced after it has been filled
with data, before returning to the client.
6-25
6-26
The media manager library can return a text line describing the error. The error text is
written to the RMAN output. Below is an error text line returned by the NetBackup
implementation of SBT API 2.0:
ORA-19511: Error received from media manager layer, error text:
sbtbackup: Failed to open for backup.
The media manager library creates the log file sbtio.log. This file is not written by
Oracle. The media manager should write a detailed description of the error in this file.
However, some media managers (for example, NetBackup) do not write to this file at all.
Here is an example of sbtio.log written by Legato LSM:
(24677) LSM 2.2.0.1: 03/19/02 10:26:27 Sbtopen: unable to start
save session with server dlsun1556:
There is no pool named 'fdfa'.
From the preceding text it is obvious that the backup failed because there is no data pool.
The messages that are written in the media manager monitor and logs are also very
helpful if you need support from the media manager software vendor.
6-28
At first glance, it would appear that this is a media manager error and it indeed is.
However, if you look closely, you will see that the BACKUP_DIR environment variable
was improperly set. This indicates that this error came from Oracle Corporations
dummy SBT module using the SBT_DISK device.
6-30
6-31
6-32
6-33
For example, if a function returns SBT_ERROR_MM, then the server session calls
sbterror() to get the error description. The text is then reported (not the numeric code) in
an ORA-19511. Note that some of the return codes are not errors at all like the 7504.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 6-33
Vendor Differences
There are several media manager issues existing that
must be taken into consideration:
Files created by the Oracle server may be larger
than those supported by the media manager
Include a SET LIMIT clause in the channel
configuration command
ALLOCATE CHANNEL C1 DEVICE TYPE sbt
...
SET LIMIT CHANNEL C1 KBYTES=1000000;
6-34
Vendor Differences
A problem that can be encountered with making backups to tape is the backup file size that
is created by the Oracle server may be much larger than the file size that is supported by the
media manager. This is because RMAN multiplexes multiple input files into one output file.
Some media managers may not return errors in this situation, but fail silently. For this
reason, it is important to determine the maximum file size supported for your media
management software, then use the RMAN keyword KBYTES in a SET LIMIT CHANNEL
command to limit the output file size to be within the supported size for your media
management software.
When writing backups to a media manager, use the substitution variables that are provided
by RMAN to generate unique backup piece names. If the FORMAT parameter is not
specified, then RMAN automatically generates a unique filename using the %U substitution
variable. Make sure that your media manager supports filenames that are generated by %U if
you intend to use the automatic file naming of RMAN. The media manager considers the
name of the backup piece as the filename that is backed up, so this name must be unique in
the media manager catalog. In addition, some media managers only support a 14-character
backup piece name. If you need to restore to a different node, then be sure of this
functionality and also of any license limitations. Check the media management
documentation to be sure.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 6-34
Summary
In this lesson, you should have learned how to:
RMAN makes backups to tape
Describe the Media Management Interface
functionality
Identify the two versions of the SBT interface
Link the Oracle server to a media manager
Describe media manager issues and informational
messages
6-35
Practice Overview:
Using RMAN with a Media Manager
This practice covers the following topics:
Configuring RMAN to use a media manager
Investigating media manager errors
6-36
Debugging RMAN
Objectives
After completing this lesson, you should be able to do
the following:
Debug RMAN errors
Debug media manager errors
Debug OS errors occurring in the RMAN stack
7-2
7-3
7-4
Remember that the DEBUG output can be voluminous, so make sure that you have adequate
disk space for the trace file. This simple backup session that does not generate any errors
creates a trace file that is almost half megabyte in size:
$ rman target / catalog rman/rman debug trace sample.log
RMAN> backup database;
RMAN> host "ls l sample.log";
-rw-r--r-1 user02
dba
576270 Apr 6 10:38 sample.log
host command complete
Oracle9i Database: Advanced Backup and Recovery Using RMAN 7-4
7-5
5000-5499
5500-5999
6000-6999
7000-7999
8000-8999
10000-10999
12000-12999
7-6
RMAN-00571:
RMAN-00569:
RMAN-00571:
RMAN-03009:
===========================================
======= ERROR MESSAGE STACK FOLLOWS =======
===========================================
failure of backup command on c1 channel at
09/04/2001 13:18:19
ORA-19506: failed to create sequential file,
name="07d36ecp_1_1", parms=""
ORA-27007: failed to open file
SVR4 Error: 2: No such file or directory
Additional information: 7005
Additional information: 1
ORA-19511: Error from media manager layer,error text:
7-7
7-8
7-9
7-10
7-11
SERIAL# : The server session serial number. This value changes each time a server
session is reused.
OPNAME: A text description of the row. Detail rows include RMAN:datafile copy,
RMAN: full datafile backup, and RMAN: full datafile restore.
CONTEXT: For backup output rows, this value is 2. For all the other rows except proxy
copy (which does not update this column), the value is 1.
SOFAR: For image copies, the number of blocks that have been read. For backup input
rows, the number of blocks that have been read from the files that are being backed up.
For backup output rows, the number of blocks that have been written to the backup
piece. For restores, the number of blocks that have been processed to the files that are
being restored in this one job step. For proxy copies, the number of files that have been
copied.
TOTALWORK: For image copies, the total number of blocks in the file. For backup
input rows, the total number of blocks to be read from all files that are processed in
this job step. For backup output rows, the value is 0 because RMAN does not know
how many blocks that it will write into any backup piece. For restores, the total
number of blocks in all files restored in this job step. For proxy copies, the total
number of files to be copied in this job step.
SPID EVENT
SECWAIT STATE
CLIENT_INFO
---- --------- ------- ------- --------------------------8642 sbtbackup
600 WAITING rman channel=ORA_SBT_TAPE_1
7-13
7-14
Set the command ID to a string such as sess2 in the job running in session 2:
RUN
{
ALLOCATE CHANNEL c1 TYPE sbt;
SET COMMAND ID TO 'sess2';
BACKUP DATABASE;
}
2. Start a SQL*Plus session and then query the joined V$SESSION and V$PROCESS
views while the RMAN job is being executed. For example, enter:
SELECT SID, SPID, CLIENT_INFO
FROM V$PROCESS p, V$SESSION s
WHERE p.ADDR = s.PADDR
AND CLIENT_INFO LIKE '%id=sess%';
If you run the SET COMMAND ID command in the RMAN job, then the
CLIENT_INFO column displays in the following format:
id= command_id,rman channel= channel_id
7-16
CHANGE#
---------0
0
0
TIME
-------
NAME
--------------DRSYS
EXAMPLE
USERS
Insufficient Privileges
7-17
Insufficient Privileges
The RMAN user that was created for the recovery catalog owner needs to be granted the
privileges that are necessary for catalog ownership. Connect to the recovery catalog database
and grant RECOVERY_CATALOG_OWNER to the RMAN user:
SQL> connect system/manager
SQL> grant RECOVERY_CATALOG_OWNER to rman;
Insufficient privileges at the target database is the most common source of the ORA-1031
error. RMAN appends as sysdba to every target connection, so the user must have sysdba
privileges. Before troubleshooting the error at the target, find out where they are running
RMANfrom the target database software installation, or from a different ORACLE_HOME,
or from a different system altogether.
When connecting locally to the target database, the user must be a member of the operating
system group that is responsible for managing SYSDBA privileges, usually DBA. If an
ORA-1031 is logged when connecting locally, then make sure the username that is being
used is a member of the DBA group. When connecting remotely to the target database, you
must specify a username and password, along with a TNS alias, to connect to the target
database.
==========================================
======ERROR MESSAGE STACK FOLLOWS ========
==========================================
failure of backup command at 04/07/2002
15:42:22
ORA-19554: error allocating device, device type:
SBT_TAPE, device name:
ORA-27000: skgfqsbi: failed to initialize storage
subsystem Additional information: 4110
ORA-19511: Error received from media manager layer,
error text: SBT error = 4110, errno = 0, Oracle Test
Disk API: BACKUP_DIR environment variable is not set
7-19
This particular example shows the SBT_TAPE device is indeed attempting to use the
dummy disk API, which is not supported for actual backups and the required parameter for
this library; BACKUP_DIR is not defined, causing the 4110.
7-21
SQL>
2
3
4
5
7-22
EVENT
--------sbtwrite2
sbtwrite2
SEC_WAIT STATE
-------------600 WAITING
600 WAITING
CLIENT_INFO
----------------------------rman channel=ORA_SBT_TAPE_1
rman channel=ORA_SBT_TAPE_2
2. Terminate the hung processes with an operating system utility. For example, on Solaris
execute a kill -9 command:
$ kill -9 8642 8374
3. Check that the media manager also clears its processes, or else the next backup or
restore may still hang due to the previous hang. In some media managers, the only
solution is to shut down and restart the media manager.
Some systems have OS utilities to show a stack trace from an arbitrary process. On
Solaris, /usr/proc/bin/pstack will provide this information.
$ /usr/proc/bin/pstack 21397
7-24
======================================
==== ERROR MESSAGE STACK FOLLOWS =====
======================================
failure of backup command at
04/07/2002 16:32:21
ORA-00230: operation disallowed: snapshot
controlfile enqueue unavailable
7-25
A typical job waiting for the control file enqueue waits for a brief time and then obtains the
enqueue. RMAN makes up to five attempts to acquire the enqueue and then fails. The
conflict is usually caused when two jobs are both backing up the control file, and the job that
first starts backing up the control file waits for service from the media manager. To
determine which job is holding the conflicting enqueue, perform the following steps:
1. When you see the first message stating RMAN-08512: waiting for
snapshot controlfile enqueue, start a new SQL*Plus session on the target
database:
$ sqlplus 'SYS/oracle@trgt AS SYSDBA'
2. Execute the following query to determine which job is causing the wait:
SQL>
2
3
4
RMAN-00571:
RMAN-00569:
RMAN-00571:
RMAN-03002:
=======================================
===== ERROR MESSAGE STACK FOLLOWS =====
=======================================
failure of backup command at 04/07/2002
15:04:21
RMAN-06059: expected archived log not found, loss of
archived log compromises recoverability
ORA-19625: error identifying file /u01/ORADATA/1_9.dbf
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
7-27
It is always better to use RMAN to delete logs than to use an operating system utility. The
easiest method to remove unwanted logs is to specify the DELETE INPUT option when
backing up archived logs. For example, enter:
RMAN> BACKUP DEVICE TYPE sbt
2> ARCHIVELOG ALL
3> DELETE ALL INPUT;
======================================
==== ERROR MESSAGE STACK FOLLOWS =====
======================================
failure of Duplicate Db command at
04/04/2002 21:14:33
RMAN-03015: error occurred in stored script Memory
Script
RMAN-06053: unable to perform media recovery
because of missing log
RMAN-06025: no backup of log thread 1 seq 16 scn
145858 found to restore
7-29
Summary
In this lesson, you should have learned how to:
Debug RMAN errors
Debug media manager errors
Debug OS errors occurring in the RMAN stack
7-30
Practice Overview:
Debugging RMAN
This practice covers the following topics:
Analyzing RMAN errors
Analyzing media manager errors
Analyzing OS errors in the RMAN stack
7-31
Objectives
After completing this lesson, you should be able to do
the following:
Apply general performance tips and techniques
Implement synchronous and asynchronous I/O
Tune the RMAN BACKUP/RESTORE process
8-2
Tuning RMAN
8-3
Tuning RMAN
RMAN backup and restore operations perform the following distinct tasks:
Reading or writing input data
Processing data by validating and copying blocks from the input to the output buffers
The slowest of these operations is called a bottleneck. RMAN tuning is the task of
identifying the bottleneck (or bottlenecks) and attempting to make it more efficient by using
RMAN commands, initialization parameter settings, or adjustments to the physical media.
The key to tuning RMAN is understanding I/O. The backup and restore jobs of RMAN use
two types of I/O buffers: disk and tertiary storage (usually tape). When performing a backup,
RMAN reads input files by using disk buffers and writes the output backup file by using
either the disk or the tape buffer. When performing restores, RMAN reverses these roles.
Besides being divided into DISK and SBT, I/O is also divided into synchronous and
asynchronous. Synchronous devices only perform one I/O task at a time. Therefore, you can
easily determine how much time the backup jobs require. In contrast to synchronous I/O
(SIO), asynchronous I/O (AIO) can perform more than one task at a time. To tune RMAN
effectively, you must thoroughly understand the concepts such as synchronous and
asynchronous I/O, disk and tape buffers, and channel architecture. When you understand
these concepts, you can learn how to use fixed views to monitor bottlenecks.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 8-3
Allocation Rule
8-4
8-5
1 MB
1 MB
1 MB
1 MB
1 MB
1 MB
1 MB
1 MB
1 MB
1 MB
1 MB
1 MB
1 MB
1 MB
Channel
FILESPERSET = 4
MAXOPENFILES = 4
Set the MAXOPENFILES parameter so that the number of files that are read simultaneously
is just enough to use the output device fully. This consideration is important when the output
device is a tape.
Tape buffers
256 kb 256 kb
256 kb 256 kb
8-6
RMAN allocates the tape buffers in the System Global Area (SGA) or the Program Global
Area (PGA), depending on whether I/O slaves are used. If the initialization parameter
BACKUP_TAPE_IO_SLAVES is True, then RMAN allocates tape buffers from the SGA or
the large pool if the LARGE_POOL_SIZE initialization parameter is set. If you set the
parameter to False, then RMAN allocates the buffers from the PGA. If you use I/O slaves,
then set the LARGE_POOL_SIZE initialization parameter to set aside SGA memory that is
dedicated to holding these large memory allocations. By doing this, the RMAN I/O buffers
do not compete with the library cache for SGA memory.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 8-6
Server
Process
0100100
0100100
Server process
3 writes data to
new buffer
8-7
Tape
buffers
4 Tape process
signals finish
Server
Process
0100100
0100100
0100100
Tape
buffers
8-8
Setting LARGE_POOL_SIZE
8-9
Setting LARGE_POOL_SIZE
The requests for contiguous memory allocations from the shared pool are small, usually
under 5 KB in size. However, it is possible that a request for a large contiguous memory
allocation can either fail or require significant memory housekeeping to release the required
amount of contiguous memory. Although the shared pool may be unable to satisfy this
memory request, the large pool is able to do so. The large pool does not have a least recently
used list so that Oracle does not attempt to age memory out of the large pool.
Use the LARGE_POOL_SIZE initialization parameter to configure the large pool. To see in
which pool (shared pool or large pool) the memory for an object resides, query
V$SGASTAT.POOL. The suggested LARGE_POOL_SIZE is calculated as:
#_of_allocated_channels * (16 MB + ( 4 * size_of_tape_buffer ))
For backups to disk, the tape buffer is obviously 0 so set LARGE_POOL_SIZE to 16 MB.
For tape backups, the size of a single tape buffer is defined by the RMAN channel parameter
BLKSIZE, which defaults to 256 KB. Assume a case in which you are backing up to two
tape drives. If the tape buffer size is 256 KB, then set LARGE_POOL_SIZE to 18 MB. If
you increase BLKSIZE to 512 KB, then increase LARGE_POOL_SIZE to 20 MB.
Performance Monitoring
8-10
Performance Monitoring
The maximum backup speed is limited by the available hardware. It is not possible to back
up any faster than the aggregate tape bandwidth. One exception to this is if there are many
empty blocks in the data files that need not be backed up.
One component of the backup system is always a bottleneck; unless the speeds of the disk
and tape are exactly matched (which is not likely), I/O at one component will always block,
no matter how many buffers are used. If the bottleneck is the tape drive, and the tape is
streaming, then the backup cannot possibly proceed any faster.
In which view the SBT_TAPE row appears is a good indication of whether the
BACKUP_TAPE_IO_SLAVES parameter is set, and whether AIO or SIO is being used.
This option should definitely cause increased throughput on UNIX. Because of the memory
management model, it is recommended that this be used with care on NT.
8-11
8-12
8-13
8-14
Performance Rules
You can speed up the backup and restore processes by buying more tape drives, faster tape
drives, or ideally a combination of the two. It is a waste of system resources to allocate more
than one channel per tape drive. If more channels than physical drives are used, then the
backup sets will be intermingled. This can adversely affect the time it takes to restore
selected files.
If a tape drive is not streaming, increasing the number of files multiplexed together may
help. Remember that if a small subset of files in a backup set must be restored, the restore
will take longer if many files are multiplexed into the backup set. Put just enough files into
each backup set to keep the tape drives streaming. It is better to store files that are likely to
be restored together in the same backup set.
8-15
8-17
Channel Tuning
Use the CONFIGURE CHANNEL and ALLOCATE CHANNEL
commands to:
Limit the size of backup pieces
Prevent RMAN from consuming too much disk
bandwidth
Determine the level of multiplexing for each
channel
8-18
Channel Tuning
You can set various channel limit parameters that apply to operations that are performed by
the allocated server session in the CONFIGURE CHANNEL and ALLOCATE CHANNEL
commands.
The MAXPIECESIZE parameter specifies the maximum size of a backup piece. Use this
parameter to make RMAN create multiple backup pieces in a backup set. RMAN creates
each backup piece with a size that is no larger than the value that has been specified in the
parameter.
The RATE parameter specifies the bytes per second that RMAN reads on the channel. This
parameter is useful in preventing RMAN from consuming excessive disk bandwidth and
degrading OLTP performance. For example, by setting RATE=1500K, each disk drive
delivers 3 MB per second and RMAN leaves some disk bandwidth available to the online
system.
The MAXOPENFILES parameter determines the maximum number of input files that a
backup or copy can have open at a given time. If not set manually, then the value defaults to
8. The level of RMAN multiplexing is partially determined by MAXOPENFILES. The level
of multiplexing in turn determines how RMAN allocates disk buffers. Multiplexing is the
number of input files that are simultaneously read and then written into the same backup
piece.
Oracle9i Database: Advanced Backup and Recovery Using RMAN 8-18
8-19
Summary
In this lesson, you should have learned how to:
Apply general performance tips and techniques
Implement synchronous and asynchronous I/O
Tune the RMAN BACKUP/RESTORE process
8-20
__________
Appendix A
__________
Corresponding V$ View
View Description
RC_ARCHIVED_LOG
V$ARCHIVED_LOG
RC_BACKUP_CONTROLFILE
V$BACKUP_DATAFILE
RC_BACKUP_CORRUPTION
V$BACKUP_CORRUPTION
RC_BACKUP_DATAFILE
V$BACKUP_DATAFILE
RC_BACKUP_PIECE
V$BACKUP_PIECE
Backup pieces
RC_BACKUP_REDOLOG
V$BACKUP_REDOLOG
RC_BACKUP_SET
V$BACKUP_SET
RC_BACKUP_SPFILE
V$BACKUP_SPFILE
RC_CHECKPOINT
RC_CONTROLFILE_COPY
V$DATAFILE_COPY
RC_COPY_CORRUPTION
V$COPY_CORRUPTION
RC_DATABASE_BLOCK_
CORRUPTION
V$DATABASE_BLOCK_
CORRUPTION
RC_DATABASE_
INCARNATION
V$DATABASE_
INCARNATION
RC_DATAFILE
V$DATAFILE
RC_DATAFILE_COPY
V$DATAFILE_COPY
RC_LOG_HISTORY
V$LOG_HISTORY
RC_OFFLINE_RANGE
V$OFFLINE_RANGE
RC_PROXY_CONTROLFILE
V$PROXY_DATAFILE
RMAN Executable
Catalog Database
Catalog Schema
8.0.3
8.0.3
greater/equal to 8.x
8.0.3
8.0.4
8.0.4
greater/equal to 8.x
greater/equal to 8.0.4
8.0.5
8.0.5
greater/equal to 8.x
greater/equal to 8.0.5
8.0.6
8.0.6
greater/equal to 8.x
8.0.6
8.0.6
8.0.6
greater/equal to 8.1.x
greater/equal to 8.1.x
8.1.5
8.1.5
greater/equal to 8.1.x
greater/equal to 8.1.5
8.1.6
8.0.6.1
greater/equal to 8.x
8.0.6
8.1.6
8.0.6.1
greater/equal to 8.1.x
greater/equal to 8.1.x
8.1.6
8.1.
5 greater/equal to
8.1.x
greater/equal to
RMAN executable
8.1.6
8.1.
6 greater/equal to
8.1.x
greater/equal to
RMAN executable
8.1.7
8.0.6.1
greater/equal to 8.x
8.0.6
8.1.7
8.0.6.1
greater/equal to 8.1.x
greater/equal to 8.1.x
8.1.7
8.1.x
greater/equal to 8.1.x
greater/equal to
RMAN executable
9.0.1
9.0.1
greater/equal to 8.1.x
greater/equal to
RMAN executable
9.2.0
greater/equal to 9.0.3
greater/equal to 8.1.x
greater/equal to
RMAN executable
Deprecated Syntax
9.2
REPLICATE
9.2
SET AUTOLOCATE
9.0.1
Not available
9.0.1
9.0.1
9.0.1
9.0.1 ...
ARCHIVELOG ...
LOGSEQ ...
9.0.1
9.0.1
CROSSCHECK
9.0.1
DELETE
9.0.1
9.0.1
SET AUXNAME
CONFIGURE AUXNAME
__________
Appendix B
Practices
__________
Lesson 2 Practices
1. Put your database in archivelog mode. Ensure that the archived logs are written to
$HOME/ORADATA/ARCHIVE1.
2. On your database Unn, create a tablespace called RCVCAT that will contain the schema for
the repository tables, views, and so on. Make the datafile 20 MB in size and place it in
$HOME/ORADATA/u04. Create a Recovery Manager user called RMAN and set the users
default tablespace to RCVCAT. Let the RMAN user have unlimited quota on this tablespace.
Set the temporary tablespace to TEMP. Grant the role RECOVERY_CATALOG_OWNER to this
user. Create the catalog and register the target database.
3. Create a persistent configuration for the recovery catalog. Use the following specifications as
a guide:
Lesson 3 Practices
1. By using operating system commands, make a complete cold backup into the directory
DONTTOUCH. This is done to provide a point-of-disaster recovery, if all else fail. Confirm
the copy when finished. Query the recovery catalog to see if RMAN knows about this
backup.
2. Use the CATALOG command to advise the repository of the backup that was taken
previously. Then confirm by examining the appropriate tables.
3. Use RMAN to make a datafile copy of all the files of the database. Put the files in
$HOME/BACKUP/RMAN. Then confirm that the repository was automatically updated
with the knowledge of this backup.
4. Make a full or incremental 0 backup of the database and put the backup files in the BACKUP
directory. Put all files into one set, but restrict the size of each piece to 20 MB. Confirm
whether the backup has occurred by examining the appropriate tables in the repository.
5. Perform a database backup by using automatic channel allocation. Ensure that the backup
command behaves as specified in your persistent configuration.
6. By using Enterprise Manager, perform a level 1 database backup.
Lesson 4 Practices
Complete recovery from a total failure
1. Delete all the datafiles and controlfiles that are associated with the target database. Use the
V$DATAFILE and V$CONTROLFILE views to get the filenames. You can do this
individually, or by using the spool command to make a script to run. It is suggested that the
recover database validate command be run first to ensure that the database can be
recovered to the current point in time.
Incomplete recovery to some time in the past
2. This practice simulates the need to recover a database to some point in the past because of
the introduction of questionable data. Create a table called HR.DEPARTMENTS2 as select
* from HR.DEPARTMENTS and perform some inserts, noting the time before committing
the inserts. Start Enterprise Manager and use this time (less 5 minutes) to recover the
database to a point in time before the new data was introduced.
Recover a single block
3. Using the DEPARTMENTS table, corrupt a block in the object with the corrupt.sh script
and use the BLOCKRECOVER command to fix the corruption. Run the script as shown below:
$ corrupt.sh
The script will corrupt a block in the DEPARTMENTS table. Immediately after running the
script, start a SQL*Plus session and perform a select against the DEPARTMENTS table:
SQL> select * from DEPARTMENTS;
Note the error output and use it with the BLOCKRECOVER command to correct the
corruption. Verify whether the table has been repaired.
Lesson 5 Practices
1. Use the LIST command to:
Identify the current database incarnation and identify the SCN at which it changed
2. Use CONFIGURE to change the REDUNDANCY to two. Using REPORT:
Identify files that have less than four redundant backups.
Identify files whose recovery needs more than seven days of archived logs.
Identify backups that are obsolete according to the new retention policy
View your database schema
3. Delete obsolete backups as identified by the redundancy value that was set in practice 2.
4. Create a stored script called whole_bkup that allocates a disk channel and backs up the
entire database. Run the script to be sure it works properly. Query the appropriate view to see
the script lines. Next, use the PRINT command to view the stored script lines.
Lesson 6 Practices
Configure the channel SBT_TAPE to use Oracles SBT dummy disk API. Use the
SBT_LIBRARY parameter to direct RMAN to load the proper library. Configure the
SBT_TAPE channel to be the default channel. Test the SBT configuration by performing a
backup. Troubleshoot the configuration if unsuccessful.
Lesson 7 Practices
1. Use RMAN to start a backup. While the backup is running log on to the target database by
using another telnet session and examine the view V$SESSION_LONGOPS. By using this
view you can determine if the backup is progressing, or hanging. If the backup is
progressing, the time_remaining column should be decreasing.
2. Using RMAN perform another backup by using the DEBUG option. On completion of the
backup script, examine the trace file that is produced by DEBUG.
3. Run the shell script les07_03.sh. After doing this, perform a database backup by using the
SBT_TAPE device. Use the error stack to identify the problem. If it is indeterminate, look at
the files (trace files, sbtio.log) in USER_DUMP_DEST or use debug to gather more
information. Correct the error and rerun the backup to verify the repair.
4. Run the shell script les07_04.sh. After doing this, perform a database backup by using
the persistent configuration. Investigate the alert log and trace files for any clues. If this does
not work, then use debug to gather more information. Correct the condition and run the
backup.
__________
Appendix C
Solutions
__________
Lesson 2 Practices
1. Put your database in archivelog mode. Ensure that the archived logs are written to
$HOME/ORADATA/ARCHIVE1.
To switch a databases archiving mode between NOARCHIVELOG and ARCHIVELOG
mode, edit your initialization parameter file and set LOG_ARCHIVE_DEST to
$HOME/ORADATA/ARCHIVE1 and LOG_ARCHIVE_START to TRUE. The database
should not be running.
$ cd $HOME/ADMIN/PFILE
$ vi initUnn.ora
LOG_ARCHIVE_DEST=$HOME/ORADATA/ARCHIVE1
LOG_ARCHIVE_START=TRUE
Start the instance and mount, but do not open, the database.
$sqlplus /nolog
SQL> connect / as sysdba
SQL> startup mount pfile=$HOME/oracle/dbs/initUnn.ora
2. On your database Unn, create a tablespace called RCVCAT that will contain the schema for
the repository tables, views, and so on. Make the datafile 20 MB in size and place it in
$HOME/ORADATA/u04. Create a Recovery Manager user called RMAN and set the users
default tablespace to RCVCAT. Let the RMAN user have unlimited quota on this tablespace.
Set the temporary tablespace to TEMP. Grant the role RECOVERY_CATALOG_OWNER to
this user. Create the catalog and register the target database.
Use the create tablespace command. Name the file rcvcat.dbf and place it in
$HOME/ORADATA/u04.
SQL> create tablespace rcvcat
2 datafile '$HOME/ORADATA/u04/rcvcat.dbf'
3 size 20m;
Tablespace created.
Create the RMAN user. Make RCVCAT the default tablespace and TEMP the temporary
tablespace. Give RMAN unlimited quota in RCVCAT.
NOTE: To connect to your target database the target user must be identified as a
SYSDBA.
SQL>
2
3
User
Grant RECOVERY_CATALOG_OWNER and any other privileges that are needed to the
RMAN user:
SQL> grant RECOVERY_CATALOG_OWNER, connect, resource, sysdba
Grant succeeded.
TO rman;
Start RMAN and connect to the target database and the catalog. Create the catalog and
register the database.
SQL> exit
$ rman target / catalog rman/rman
connected to target database: U221 (DBID=4278320558)
connected to recovery catalog database
recovery catalog is not installed
RMAN> CREATE CATALOG
RMAN> create catalog
recovery catalog created
RMAN> register database;
database registered in recovery catalog
Starting full resync of recovery catalog
full resync complete
3. Create a persistent configuration for the recovery catalog. Use the following specifications as
a guide:
Run the appropriate configure commands to create the persistant configuration. Note
that DISK is already the default device type. Remember that the show all command
output was designed to allow easy cut and past operations to modify parameters.
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'$HOME/ORADATA/u05/%F'
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '$HOME/ORADATA/u06/snapcf_U01.f';
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
RMAN> CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '$HOME/ORADATA/u06/C1_%U';
RMAN> CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '$HOME/ORADATA/u06/C2_%U';
Confirm that the necessary changes have been made by issuing the show all command
again and comparing the output with the practice requirements.
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'$HOME/ORADATA/u05/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT
'$HOME/ORADATA/u06/C1_%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT
'$HOME/ORADATA/u06/C2_%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '$HOME/ORADATA/u06/snapcf_U01.f';
Lesson 3 Practices
1. By using operating system commands, make a complete cold backup into the directory
DONTTOUCH. This is done to provide a point-of-disaster recovery, if all else fail. Confirm the
copy when finished. Query the recovery catalog to see if RMAN knows about this backup.
Shutdown your database and copy the datafiles located in the ORADATA directory to the
DONTTOUCH directory. The datafiles are on different disks (simulated) so that the find
command is useful for copying files from multiple locations and consolidating them into
a single directory, DONTTOUCH, in this case. Please note that there is no space between
the French braces.
$ sqlplus /nolog
SQL> connect / as sysdba
SQL> shutdown immediate;
SQL> exit
$ cd
$ find $HOME/ORADATA exec
$ ls l $HOME/DONTTOUCH
total 821824
-rw-r----1 user01
dba
-rw-r----1 user01
dba
-rw-r----1 user01
dba
...
-rw-r----1 user01
dba
cp
{}
$HOME/DONTTOUCH
\;
Query the CDF table in the RMAN schema. The backups that are listed include ALL
blocks and are like an operating system backup. In this case, there is no history of the
backup at all.
SQL> column fname format a50
SQL> select file#, fname, completion_time from rman.cdf;
no rows selected
2. Use the CATALOG command to advise the repository of the backup that was taken
previously. Then, confirm by examining the appropriate tables.
Run each catalog individually from the RMAN prompt or include them in a run block.
Use the output from the list command that was performed earlier to get the names of the
datafile copies.
SQL> exit
$ rman target / catalog
RMAN> run {
2> catalog datafilecopy
3> catalog datafilecopy
4> catalog datafilecopy
5> catalog datafilecopy
6> catalog datafilecopy
7> catalog datafilecopy
}
rman/rman
'$HOME/DONTTOUCH/indx01.dbf';
'$HOME/DONTTOUCH/rcvcat.dbf';
'$HOME/DONTTOUCH/example01.dbf';
'$HOME/DONTTOUCH/system01.dbf';
'$HOME/DONTTOUCH/undotbs01.dbf';
'$HOME/DONTTOUCH/users01.dbf';
To confirm RMAN is aware of the cataloged datafile copies, query the CDF table as done
previously.
$ sqlplus rman/rman
SQL> column fname format a50
SQL> select file#, fname, completion_time from cdf;
FILE# FNAME
COMPLETIO
---------- -------------------------------------------------- --------1 /home1/user01/DONTTOUCH/system01.dbf
14-APR-02
4 /home1/user01/DONTTOUCH/indx01.dbf
14-APR-02
...
3 /home1/user01/DONTTOUCH/users01.dbf
14-APR-02
6 rows selected.
3. Use RMAN to make a datafile copy of all the files of the database. Put the files in
$HOME/BACKUP/RMAN. Then, confirm that the repository was automatically updated
with the knowledge of this backup.
Query V$DATAFILE to get the file numbers and filenames that are needed to perform
the RMAN datafile backup.
SQL> column name format a45;
SQL> select file#, name from v$datafile;
FILE #
NAME
------------------------------------------------1
/home1/user01/ORADATA/u01/system01.dbf
2
/home1/user01/ORADATA/u02/undotbs01.dbf
3
/home1/user01/ORADATA/u03/users01.dbf
4
/home1/user01/ORADATA/u03/indx01.dbf
5
/home1/user01/ORADATA/u02/example01.dbf
6
/home1/user01/ORADATA/u04/rcvcat.dbf
Using the information from V$DATAFILE execute RMAN, connecting to the catalog
and the target database and perform the backup.
$ rman target / catalog rman/rman
RMAN> run {
2> copy datafile 1 to '$HOME/BACKUP/RMAN/system01.dbf';
3> copy datafile 2 to '$HOME/BACKUP/RMAN/undotbs01.dbf';
4> copy datafile 3 to '$HOME/BACKUP/RMAN/users01.dbf';
5> copy datafile 4 to '$HOME/BACKUP/RMAN/indx01.dbf';
6> copy datafile 5 to '$HOME/BACKUP/RMAN/example01.dbf';
7> copy datafile 6 to '$HOME/BACKUP/RMAN/rcvcat.dbf';
8> }
Starting copy at 14-APR-02
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=10 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=11 devtype=DISK
channel ORA_DISK_1: copied datafile 1
Oracle9i Database: Advanced Backup and Recovery Using RMAN C-6
FNAME
COMPLETION_TIME
--------------------------------------------- --------------/home1/user01/DONTTOUCH/system01.dbf
14-APR-02
/home1/user01/DONTTOUCH/indx01.dbf
14-APR-02
/home1/user01/DONTTOUCH/rcvcat.dbf
14-APR-02
/home1/user01/DONTTOUCH/example01.dbf
14-APR-02
/home1/user01/DONTTOUCH/undotbs01.dbf
14-APR-02
/home1/user01/DONTTOUCH/users01.dbf
14-APR-02
/home1/user01/BACKUP/RMAN/system01.dbf
14-APR-02
/home1/user01/BACKUP/RMAN/undotbs01.dbf
14-APR-02
/home1/user01/BACKUP/RMAN/users01.dbf
14-APR-02
/home1/user01/BACKUP/RMAN/indx01.dbf
14-APR-02
/home1/user01/BACKUP/RMAN/example01.dbf
14-APR-02
FILE# FNAME
COMPLETION_TIME
---------- --------------------------------------------- --------------6 /home1/user01/BACKUP/RMAN/rcvcat.dbf
14-APR-02
12 rows selected.
Oracle9i Database: Advanced Backup and Recovery Using RMAN C-7
4. Make a full or incremental 0 backup of the database and put the backup files in the BACKUP
directory. Put all files into one set, but restrict the size of each piece to 20 MB. Confirm
whether the backup has occurred by examining the appropriate tables in the repository.
Use the backup full command as shown in the example.
$ rman target / catalog rman/rman
RMAN> run {
2> allocate channel c1 type disk;
3> set limit channel c1 kbytes=20000;
4> backup full
5> (database format '$HOME/BACKUP/back_%p%d.%s');
6> release channel c1;
7> }
Starting backup at 14-APR-02
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=/home1/user01/ORADATA/u01/system01.dbf
...
input datafile fno=00003 name=/home1/user01/ORADATA/u03/users01.dbf
channel c1: starting piece 1 at 14-APR-02
channel c1: finished piece 1 at 14-APR-02
piece handle=/home1/user01/BACKUP/back_1U01.3 comment=NONE
...
channel c1: starting piece 7 at 14-APR-02
channel c1: finished piece 7 at 14-APR-02
piece handle=/home1/user01/BACKUP/back_7U01.3 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:33
Finished backup at 14-APR-02
Starting Control File Autobackup at 14-APR-02
piece handle=/home1/user01/ORADATA/u05/c-0574317449-20020414-02
comment=NONE
Finished Control File Autobackup at 14-APR-02
Take note of the channel allocation. Does the number of channels allocated match the degree of
parallelization that is specified for the DISK device in the persistent configuration? Note the files
that were created by channels 1 and 2. Do the format and the file location match the persistent
configuration created earlier? In the output above, the channels are automatically allocated as
desired and the backup pieces are written in the correct format and location.
Lesson 4 Practices
Complete recovery from a total failure
1. Delete all the datafiles and controlfiles that are associated with the target database. Use the
V$DATAFILE and V$CONTROLFILE views to get the filenames. You can do this
individually, or by using the spool command to make a script to run. It is suggested that the
recover database validate command be run first to ensure that the database can be
recovered to the current point in time.
Run recover database validate to ensure that we can recover the database. If
this fails, then back up the database again and try again.
$ rman target / catalog rman/rman
connected to target database: U01 (DBID=574317449)
connected to recovery catalog database
RMAN> restore database validate;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=10 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=7 devtype=DISK
channel ORA_DISK_1: starting validation of datafile backupset
channel ORA_DISK_2: starting validation of datafile backupset
channel ORA_DISK_1: restored backup piece 1
...
channel ORA_DISK_2: validation complete
Finished restore at 15-APR-02
Query V$DATAFILE and V$CONTROLFILE to find the location of the control file and
datafiles and delete them. Do not delete your backups.
SQL> select name from v$datafile;
NAME
--------------------------------------------/home1/user01/ORADATA/u01/system01.dbf
/home1/user01/ORADATA/u02/undotbs01.dbf
/home1/user01/ORADATA/u03/users01.dbf
/home1/user01/ORADATA/u03/indx01.dbf
/home1/user01/ORADATA/u02/example01.dbf
/home1/user01/ORADATA/u04/rcvcat.dbf
6 rows selected.
SQL> select name from v$controlfile;
NAME
------------------------------------------/home1/user01/ORADATA/u01/ctrl01.ctl
Shut down the database and remove the control file and datafiles.
SQL> shutdown immediate;
Oracle9i Database: Advanced Backup and Recovery Using RMAN C-10
SQL>
$ cd
$ rm
$ rm
$ rm
$ rm
$ rm
exit
$HOME/ORADATA
u01/*.dbf
u01/*.ctl
u02/*.dbf
u03/*.dbf
u04/*.dbf
Start RMAN and connect to the target database only because the recovery catalog resides
in the database and is unavailable. Start the database in nomount mode. The first thing
that must be done is to restore the control file. List the controlfiles in the autobackup
location and find the most recent one. Then use the restore controlfile from
filename command to do this.
$ sqlplus /nolog
$connect / as sysdba
SQL> startup nomount;
SQL> exit
$ rman target /
RMAN> host ls l $HOME/ORADATA/u05;
total 13328
-rw-r----1 ora9i dba
963072 Apr
-rw-r----1 ora9i dba
963072 Apr
-rw-r----1 ora9i dba
963072 Apr
-rw-r----1 ora9i dba
963072 Apr
-rw-r----1 ora9i dba
963072 Apr
-rw-r----1 ora9i dba
963072 Apr
-rw-r----1 ora9i dba
963072 Apr
host command complete
14
14
14
14
14
15
15
20:59
21:14
21:46
21:51
23:51
12:41
14:17
c-0574317449-20020414-00
c-0574317449-20020414-01
c-0574317449-20020414-02
c-0574317449-20020414-03
c-0574317449-20020414-05
c-0574317449-20020415-00
c-0574317449-20020415-01
By using RMAN, restore the datafiles and recover the database. At the end of the
recovery, you will need to reset the database and make a complete backup because the
database will need to be opened by using the resetlogs option.
RMAN> alter database mount;
RMAN> restore database;
Starting restore at 15-APR-02
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /home1/user01/ORADATA/u01/system01.dbf
restoring datafile 00003 to /home1/user01/ORADATA/u03/users01.dbf
restoring datafile 00004 to /home1/user01/ORADATA/u03/indx01.dbf
channel ORA_DISK_1: restored backup piece 1
piece handle=/home1/user01/ORADATA/u06/C2_0kdlvnad_1_1 tag=null
params=NULL
Oracle9i Database: Advanced Backup and Recovery Using RMAN C-11
STATUS
---------------INACTIVE
CURRENT
Query V$LOG again to confirm the switch and then insert three lines into
DEPARTMENTS2 and commit. Confirm the number of rows in the table. These inserts
represent the introduction of questionable data into the table.
SQL> select sequence#, status from v$log;
SEQUENCE#
---------5
4
STATUS
---------------CURRENT
ACTIVE
By using RMAN perform an incomplete recovery until the date and time recorded in the
previous step, less 5 minutes. Use the set until time clause to the time reported in
the first step and then recover the database.
Oracle9i Database: Advanced Backup and Recovery Using RMAN C-13
$ rman target /
connected to target database: U01 (DBID=574317449)
RMAN> run {
2> set until time "TO_DATE('02-APR-16:17:00:00','YY-MON-DD:HH24:MI:SS')";
3> restore database;
4> recover database;
5> }
executing command: SET until clause
using target database controlfile instead of recovery catalog
Starting restore at 16-APR-02
...
channel ORA_DISK_2: restore complete
Finished restore at 16-APR-02
Starting recover at 16-APR-02
using channel ORA_DISK_1
using channel ORA_DISK_2
starting media recovery
archive log thread 1 sequence 3 is already on disk as file
/home1/user01/ORADATA/ARCHIVE1/1_3.dbf
archive log thread 1 sequence 4 is already on disk as file
/home1/user01/ORADATA/ARCHIVE1/1_4.dbf
archive log filename=/home1/user01/ORADATA/ARCHIVE1/1_3.dbf thread=1
sequence=3
media recovery complete
Finished recover at 16-APR-02
RMAN> exit
Open the database with the resetlogs option and get a row count for the DEPARTMENTS2
table. If it returns the same count as step 1, then the recovery was successful. Always
perform a reset and a backup after opening the database with the resetlogs option. Finally,
bounce the database.
SQL> alter database open resetlogs;
SQL> select count(*) from hr.departments2;
COUNT(*)
---------27
SQL> exit
$ rman target / catalog rman/rman
RMAN> reset database;
RMAN> backup database;
RMAN> shutdown immediate;
RMAN> startup;
1 ora9i
dba
31461376 May
9 22:45 example01.dbf
Corrupt the block identified in the query above (in this case 417 in example01.dbf) by
using the corrupt.sh shell script. Bounce the database to clear the buffer cache.
SQL> !
$ corrupt.sh /home1/user01/ORADATA/u02/example01.dbf 417
0+1 records in
0+1 records out
$ exit
SQL> shutdown immediate;
SQL> startup
Lesson 5 Practices
1. Use the LIST command to:
Identify the current database incarnation and identify the SCN at which it changed
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size
Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ --------------19
Full
928K
DISK
00:00:00
17-APR-02
BP Key: 20
Status: AVAILABLE
Tag:
Piece Name: /home1/user01/ORADATA/u05/c-0574317449-20020417-00
Controlfile Included: Ckp SCN: 163384
Ckp time: 17-APR-02
BS Key Type LV Size
Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ --------------23
Full
45M
DISK
00:00:24
17-APR-02
BP Key: 25
Status: AVAILABLE
Tag:
Piece Name: /u03/ora9ir2/dbs/03dm4rji_1_1
List of Datafiles in backup set 23
File LV Type Ckp SCN
Ckp Time Name
---- -- ---- ---------- --------- ---2
5
6
Full 163636
Full 163636
Full 163636
17-APR-02 /home1/user01/ORADATA/u02/undotbs01.dbf
17-APR-02 /home1/user01/ORADATA/u02/example01.dbf
17-APR-02 /home1/user01/ORADATA/u04/rcvcat.dbf
Full 163637
Full 163637
Full 163637
17-APR-02 /home1/user01/ORADATA/u01/system01.dbf
17-APR-02 /home1/user01/ORADATA/u03/users01.dbf
17-APR-02 /home1/user01/ORADATA/u03/indx01.dbf
...
BS Key Type LV Size
Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ --------------50
Full
928K
DISK
00:00:00
17-APR-02
BP Key: 51
Status: AVAILABLE
Tag:
Piece Name: /home1/user01/ORADATA/u05/c-0574317449-20020417-02
Controlfile Included: Ckp SCN: 167802
Ckp time: 17-APR-02
BS Key Type LV Size
Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ --------------66
Full
928K
DISK
00:00:00
17-APR-02
BP Key: 67
Status: AVAILABLE
Tag:
Piece Name: /home1/user01/ORADATA/u05/c-0574317449-20020417-03
Oracle9i Database: Advanced Backup and Recovery Using RMAN C-17
TY
B
B
B
B
B
LV
-F
F
F
F
F
S
A
A
A
A
A
Ckp SCN
---------74588
74176
70420
69997
69942
Ckp Time
--------28-MAY-02
28-MAY-02
28-MAY-02
28-MAY-02
28-MAY-02
#Pieces
------1
1
1
1
1
#Copies
------1
1
1
1
1
Tag
--TAG20020528T145408
WKLY_BKUP
TAG20020528T115053
TAG20020528T113959
TAG20020528T113852
B
B
B
B
B
B
B
B
F
F
F
F
F
F
F
F
A
A
A
A
A
A
A
A
74588
70421
69997
69942
74588
70421
69997
69942
28-MAY-02
28-MAY-02
28-MAY-02
28-MAY-02
28-MAY-02
28-MAY-02
28-MAY-02
28-MAY-02
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
TAG20020528T145408
TAG20020528T115053
TAG20020528T113959
TAG20020528T113852
TAG20020528T145408
TAG20020528T115053
TAG20020528T113959
TAG20020528T113852
S
A
A
A
#Pieces
------1
1
1
Seq
------1
2
3
Low SCN
---------70236
74241
74293
Low Time
--------28-MAY-02
28-MAY-02
28-MAY-02
BS Key
------441
440
454
CUR
--NO
YES
#Copies
------1
1
1
Reset SCN
---------1
440227
Tag
--TAG20020528T144920
TAG20020528T144920
TAG20020528T144927
Reset Time
---------06-MAR-02
27-MAR-02
...
Backup Set
Backup Piece
50
51
17-APR-02
17-APR-02
/home1/user01/ORADATA/u05/c-
0574317449-20020417-02
RB segs
------YES
YES
NO
NO
NO
NO
Datafile Name
------------------/home1/user01/ORADATA/u01/system01.dbf
/home1/user01/ORADATA/u02/undotbs01.dbf
/home1/user01/ORADATA/u03/users01.dbf
/home1/user01/ORADATA/u03/indx01.dbf
/home1/user01/ORADATA/u02/example01.dbf
/home1/user01/ORADATA/u04/rcvcat.dbf
4. Create a stored script called whole_bkup that allocates a disk channel and backs up the
entire database. Run the script to be sure it works properly. Query the appropriate view to see
the script lines. Next, use the PRINT command to view the stored script lines.
Create and store the script.
RMAN> create script whole_bkup
2> {
3> ALLOCATE CHANNEL d1 DEVICE TYPE DISK FORMAT '$HOME/ORADATA/u06/%U';
4> backup database;
5> }
Issue the RMAN print script command to view the stored script lines.
RMAN> print script whole_bkup;
printing stored script: whole_bkup
{
Oracle9i Database: Advanced Backup and Recovery Using RMAN C-20
Lesson 6 Practices
Configure the channel SBT_TAPE to use Oracles SBT dummy disk API. Use the
SBT_LIBRARY parameter to direct RMAN to load the proper library. Configure the
SBT_TAPE channel to be the default channel. Test the SBT configuration by performing a
backup. Troubleshoot the configuration if unsuccessful.
First, issue the show all command to view the current configuration.
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO 'DISK';
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'$HOME/ORADATA/u05/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT
'/home1/user01/ORADATA/u06/C1_%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT
'/home1/user01/ORADATA/u06/C2_%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/home1/user01/ORADATA/u06/snapcf_U01.f';
Issue the configure channel command to configure the SBT_TAPE channel. Set
the SBT_LIBRARY parameter to oracle.disksbt. Configure SBT_TAPE as the
default channel.
RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/home1/user01/ORADATA/u06)";
...
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
...
new RMAN configuration parameters are successfully stored
If you receive an error, then troubleshoot the configuration. The following are a few
common configuration errors.
The failure to set the BACKUP_DIR parameter (required by the Oracle SBT Disk API)
will produce the following error stack:
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 04/18/2002 10:42:43
ORA-19554: error allocating device, device type: SBT_TAPE, device name:
ORA-27000: skgfqsbi: failed to initialize storage subsystem (SBT) layer
Additional information: 4110
ORA-19511: Error received from media manager layer, error text:SBT error = 4110,
errno = 0, Oracle Test Disk API: BACKUP_DIR environment variable is not set
The failure to write the backup piece and the initial SBT catalog will result in this error.
Make sure that BACKUP_DIR can be written by the owner of the Oracle binaries or by
members of the DBA group.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_SBT_TAPE_1 channel at 04/18/2002
09:58:44
ORA-19506: failed to create sequential file, name="0ndm75aj_1_1", parms=""
ORA-27028: skgfqcre: sbtbackup returned error
ORA-19511: Error received from media manager layer, error text:
sbtpvt_catalog_open: file $HOME/ORADATA/u06/Oracle_Disk_SBT_Catalog, open
error, errno = 2
An improperly configured default device will produce an error stack like this:
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 04/18/2002 09:55:36
ORA-19569: no device is allocated to this session
Lesson 7 Practices
1. Use RMAN to set a backup in progress. While the backup is running, log on to the target
database by using another telnet session and examine the view V$SESSION_LONGOPS. By
using this view you can determine if the backup is progressing, or hanging. If the backup is
progressing, the time_remaining column should be decreasing.
Start RMAN and back up the database.
$ rman target / catalog rman/rman
RMAN> backup database;
The decreasing TIME_REMAINING value indicates that this backup is progressing normally.
It is also interesting to see the server processes starting as the backup progresses. You can see
the initial process started when the backup is initiated, you can see the process that is
associated with the media manager starting and processing the backup and finally, the
process associated with the control file autobackups, which are done to disk.
2. Using RMAN perform another backup by using the DEBUG option. On completion of the
backup script, examine the trace file that is produced by DEBUG.
$ rman target / catalog rman/rman trace $HOME/rman.out
RMAN> run {
2> debug on;
3> backup database;
4> debug off;
5> }
Debugging set to level=9, types=ALL
Starting backup at 19-APR-02
using channel ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: starting full datafile backupset
channel ORA_SBT_TAPE_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/home1/user01/ORADATA/u01/system01.dbf
...
Debugging turned off
RMAN> exit
$ vi rman.out
Recovery Manager: Release 9.2.0.0.0 - Beta
(c) Copyright 2001 Oracle Corporation.
ORACLE_HOME = /u03/ora9ir2
System name:
SunOS
Node name:
stc-sun02
Release:
5.8
Version:
Generic_108528-05
Machine:
sun4u
Starting with debugging set to level=9, types=ALL
DBGSQL: EXEC SQL AT TARGET select decode(status,'OPEN',1,0) into :b1 from
v$instance
DBGSQL:
sqlcode=0
DBGSQL:
:b1 = 1
...
# Version Setting
DBGSQL: EXEC SQL AT TARGET declare vsn varchar2 ( 20 ) ; begin vsn :=
dbms_rcvman . getPackageVersion ; :pkg_vsn:pkg_vsn_i := vsn ;
if vsn is not null then :pkg_vsnub4 := to_number ( substr ( vsn , 1 , 2 ) ||
substr ( vsn , 4 , 2 ) || substr ( vsn , 7 , 2 ) ) ; en
d if ; end ;
DBGSQL:
sqlcode=0
DBGSQL:
:b1 = "08.00.04"
DBGSQL:
:b3 = 80004
...
DBGSQL: EXEC SQL AT TARGET declare vsn varchar2 ( 20 ) ; begin vsn :=
dbms_rcvman . getPackageVersion ; :pkg_vsn:pkg_vsn_i := vsn ;
if vsn is not null then :pkg_vsnub4 := to_number ( substr ( vsn , 1 , 2 ) ||
substr ( vsn , 4 , 2 ) || substr ( vsn , 7 , 2 ) ) ; en
d if ; end ;
DBGSQL:
sqlcode=0
DBGSQL:
:b1 = "09.02.00"
DBGSQL:
:b3 = 90200
...
DBGSQL: EXEC SQL AT RCVCAT select user into :b1 from dual
DBGSQL:
sqlcode=0
DBGSQL:
:b1 = "RMAN"
# Encoding the backup request
RMAN> 2> 3> 4> 5>
DBGMISC: Node # 1
DBGMISC: run
DBGMISC:
1 JCL
DBGMISC:
1 DEBUG
DBGMISC:
1 ON
DBGMISC:
2 backup
DBGMISC:
1 BSLIST
DBGMISC:
1 BSPEC
DBGMISC:
1 DBASE
DBGMISC:
3 DEBUG
DBGMISC:
1 OFF
...
Debugging set to level=9, types=ALL
DBGMISC: EXITED krmice on [04/19/2002 14:25:12]
...
# Finishing up
DBGRPC:
krmqgns: no work found for channel ORA_SBT_TAPE_1 (krmqgns)
DBGRPC:
(krmqgns)
DBGRPC:
EXITED krmqgns with status 1 on [04/19/2002 14:25:46]
DBGMISC:
EXITED krmice on [04/19/2002 14:25:46]
DBGMISC:
ENTERED krmice on [04/19/2002 14:25:46]
DBGMISC:
command to be compiled and executed is: DEBUG
DBGMISC:
command after this command is: NONE (krmice)
Debugging turned off
(krmice)
3. Run the shell script les07_03.sh. After doing this, perform a database backup by using the
SBT_TAPE device. Use the error stack to identify the problem. If it is indeterminate, look at
the files (trace files, sbtio.log) in USER_DUMP_DEST or use debug to gather more
information. Correct the error and rerun the backup to verify the repair.
From the operating system prompt, run the les07_03.sh script. Start RMAN and back up
the database, observing any errors.
$ les07_03.sh
$ rman target / catalog rman/rman
RMAN> backup database;
starting full resync of recovery catalog
full resync complete
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of allocate command on t1 channel at 05/07/2002
13:42:26
ORA-19554: error allocating device, device type: SBT_TAPE, device name:
ORA-27211: Failed to load Media Management Library
Additional information: 25
This is not correct. The SBT library that needs to be loaded is defined by the SBT_LIBRARY
parameter of the configure channel command. Use the show command to see how it
is currently defined:
RMAN> show channel;
RMAN configuration parameters are:
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS
"SBT_LIBRARY=phony.disksbt,ENV=(BACKUP_DIR=$HOME/ORADATA/u06)";
...
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT
'$HOME/ORADATA/u06/C2_%U';
4. Run the shell script les07_04.sh. After doing this, perform a database backup by using
the persistent configuration. Investigate the alert log and trace files for any clues. If this does
not work, then use debug to gather more information. Correct the condition and run the
backup.
After running the les07_04.sh shell script, use RMAN to perform a backup and
observe the error:
$ rman target / catalog rman/rman
RMAN> backup database;
Starting backup at 30-MAY-02
...
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 05/30/2002 17:536
ORA-19504: failed to create file "/home1/user01/ORADATA/u06/C1_0udppd9k_1_1"
ORA-27040: skgfrcre: create error, unable to create file
SVR4 Error: 13: Permission denied
The error SVR4 Error: 13: Permission denied is an operating system error.
Running the backup again with the debug option may provide some useful information.
$ rman target / catalog rman/rman debug trace $HOME/rman.out
RMAN> backup database;
RMAN> exit
$ vi rman.out
...
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-10035: exception raised in RPC:
RMAN-10031: RPC Error: ORA-19624 occurred during call to DBMS_BACKUP_RESTORE.BE
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 05/30/2002 17:547
RMAN-10032: unhandled exception during execution of job step 1:
ORA-19624: operation failed, retry possible
ORA-19504: failed to create file "/home1/user01/ORADATA/u06/C1_10dppdat_1_1"
ORA-27040: skgfrcre: create error, unable to create file
SVR4 Error: 13: Permission denied
ORA-06512: at "SYS.DBMS_BACKUP_RESTORE", line 625
ORA-06512: at line 255
RMAN-10035: exception raised in RPC:
ORA-19624: operation failed, retry possible
ORA-19504: failed to create file "/home1/user01/ORADATA/u06/C1_10dppdat_1_1"
ORA-27040: skgfrcre: create error, unable to create file
SVR4 Error: 13: Permission denied
...
OS raises the SVR4 (Unix System V Kernel Release 4) exception. This looks like a
permissions issue. Using cd, navigate ORADATA and inspect the u06 directory.
$ pwd
/home1/user01
$ cd ORADATA
$ ls -la
total 21316
drwxrwxr-x 10
drwxrwxrwx 10
drwxrwsr-x
2
-rw-rw---1
drwxrwsr-x
2
drwxrwsr-x
2
drwxrwsr-x
2
drwxrwsr-x
2
drwxrwsr-x
2
drwxrwsr-x
2
dr-xr-s--2
user01
user01
user121
user121
user121
user121
user121
user121
user121
user121
user121
dba
dba
class7
class7
class7
class7
class7
class7
class7
class7
class7
512
512
96
4096
96
96
8192
8192
96
8192
8192
May
May
May
May
May
May
May
May
May
May
May
7
7
29
29
28
30
30
30
30
29
29
17:32
17:23
17:52
14:26
16:33
06:23
06:23
06:23
06:23
17:59
17:58
.
..
ARCHIVE1
ARCHIVE15_193_0_60083.bkd
ARCHIVE2
u01
u02
u03
u04
u05
u06
Notice that there are no write privileges on u06 where the backup pieces are to be
written. Use chmod to give write privileges to the user and the group and retest the
backup.
$ chmod 770 u06
$ ls -ld u06
drwxrws--2 user01
dba
$ rman target / catalog rman/rman
RMAN> backup database;
Starting backup at 07-MAY-02
...
Finished backup at 07-MAY-02
512 May
7 16:18 u06