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

Backup & Recovery

with Oracle10g RMAN


V1.0
Backup and Recovery with Oracle10g RMAN

SkillBuilders, Inc. Author: David G. Anderson


24 Salt Pond Road, Unit C-4
South Kingstown, RI 02880
www.skillbuilders.com
knowledge@skillbuilders.com

Legal Notice

Copyrights

Copyright © 2005-2007 SkillBuilders, Inc. All rights reserved. Printed in the United States of
America.

No part of this publication may be reproduced, distributed or displayed in any form or by any
means, or stored in a database, retrieval system or other media without the prior written
permission of SkillBuilders, Inc. This publication is the Confidential Property of SkillBuilders,
Inc.

Trademarks

The product/service names mentioned herein are manufacturer/publisher trademarks and are used
only for purposes of identification.

Microsoft, Microsoft Windows 95, Microsoft Windows 98, Microsoft Windows NT, and
Microsoft Windows are registered trademarks of Microsoft Corporation. Netscape, Netscape
Navigator, and the Netscape logo are registered trademarks of Netscape Communications
Corporation in the United States and other countries. Oracle, Oracle8i, Oracle9i and Oracle10g
are registered trademarks of Oracle Corporation.

All other brand, product and service names are the trademarks of their respective companies or
owners as mentioned herein.

Disclaimer

Information within this publication is subject to change without notice. Although every
precaution has been taken in the preparation of this book, the publisher and author assume no
responsibility for errors or omissions. The author and SkillBuilders, Inc. make no representation
or warranty with respect to the contents herein and specifically disclaims any implied warranties
of fitness for any particular purpose. SkillBuilders, Inc. disclaims all liability for any direct,
indirect, incidental or consequential, special or exemplary damages resulting from the use of the
information in this document or from the use of any products described in this document.

Copyright © 2005-2007 SkillBuilders, Inc. Reproduction is strictly prohibited.


Backup and Recovery with Oracle10g RMAN Page i

1. Introduction to Recovery Manager............................................................ 1.1


Lesson Objectives .........................................................................................................1.2
What is RMAN? ...........................................................................................................1.3
Basic Features ...............................................................................................................1.5
Basic Features: Repository ...........................................................................................1.8
9i New Features ..........................................................................................................1.10
9i R2 New Features.....................................................................................................1.13
Introduction Complete!...............................................................................................1.15

2. RMAN Architecture ..................................................................................... 2.1


Lesson Objectives .........................................................................................................2.2
RMAN Components .....................................................................................................2.3
Component Releases.....................................................................................................2.5
The Control File…........................................................................................................2.6
…The Control File........................................................................................................2.7
CFRKT Parameter ........................................................................................................2.8
Control File Creation ..................................................................................................2.10
Control File Size .........................................................................................................2.13
NOCATALOG Mode .................................................................................................2.17
Recovery Catalog........................................................................................................2.19
Recovery Catalog Maintenance ..................................................................................2.23
Where We've Been......................................................................................................2.25
RMAN Architecture Workshop..................................................................................2.27

3. RMAN Setup ............................................................................................... 3.1


Lesson Objectives .........................................................................................................3.2
RMAN Installation .......................................................................................................3.3
User “RMAN” ..............................................................................................................3.4
Password File................................................................................................................3.5
Oracle Net .....................................................................................................................3.7
Catalog Tablespace .......................................................................................................3.8
Create Catalog...............................................................................................................3.9
Register Database .......................................................................................................3.10
Startup Options ...........................................................................................................3.11
Lesson Summary.........................................................................................................3.13
RMAN Setup Workshop ............................................................................................3.14

4. Executing RMAN Commands.................................................................... 4.1


Lesson Objectives .........................................................................................................4.2

© 2005-2007 SkillBuilders, Inc. V1.0


Backup and Recovery with Oracle10g RMAN Page ii

RMAN Command Basics .............................................................................................4.3


8i Job Blocks.................................................................................................................4.4
9i Command Syntax......................................................................................................4.5
SQL Commands............................................................................................................4.6
Common Job Commands..............................................................................................4.7
Common Commands… ................................................................................................4.8
RMAN Commands Workshop....................................................................................4.11

5. RMAN Channels ......................................................................................... 5.1


Lesson Objectives .........................................................................................................5.2
Channel Concepts… .....................................................................................................5.3
Manual Allocation ........................................................................................................5.5
Querying V$SESSION .................................................................................................5.7
Parallel Backups… .......................................................................................................5.8
Automatic Allocation…..............................................................................................5.11
Summary.....................................................................................................................5.14
Channels Workshop....................................................................................................5.15

6. Backup with RMAN .................................................................................... 6.1


Lesson Objectives .........................................................................................................6.2
Backup Concepts ..........................................................................................................6.3
Backup Set Concepts ....................................................................................................6.5
Backupset Pieces...........................................................................................................6.7
Control File AUTOBACKUP.......................................................................................6.9
Full Backup.................................................................................................................6.12
Deleting Archive Logs................................................................................................6.14
BACKUP Syntax ........................................................................................................6.16
Interpreting BACKUP Command Output...................................................................6.18
Full Tablespace Backup..............................................................................................6.21
Datafile Backup ..........................................................................................................6.22
Full Backup Workshop ...............................................................................................6.23
Incremental Backup ....................................................................................................6.24
Cumulative Incremental..............................................................................................6.27
Incremental Backup Workshop ..................................................................................6.29
Duplexing....................................................................................................................6.30
Duplexing Workshop..................................................................................................6.31
Backup Archive Logs .................................................................................................6.32
Backup Archive Logs Workshop................................................................................6.33
Retention Policies .......................................................................................................6.34
Recovery Window ......................................................................................................6.35
Redundancy ................................................................................................................6.36
Overriding...................................................................................................................6.37
Summary.....................................................................................................................6.38

© 2005-2007 SkillBuilders, Inc. V1.0


Backup and Recovery with Oracle10g RMAN Page iii

7. Restore & Recovery with RMAN ............................................................... 7.1


Lesson Objectives .........................................................................................................7.2
Failure Scenarios...........................................................................................................7.3
Recovery-Related Commands ......................................................................................7.4
RESTORE Command ...................................................................................................7.6
RECOVER Command ..................................................................................................7.8
Recover Deleted Files...................................................................................................7.9
Recover Deleted Files Example..................................................................................7.11
Recover Lost Tablespace ...........................................................................................7.12
Restore to New Location ............................................................................................7.13
Restore to New Location Example .............................................................................7.14
PIT Recovery (1) ........................................................................................................7.15
PIT Recovery (2) ........................................................................................................7.16
PIT (3).........................................................................................................................7.17
Control File Recovery.................................................................................................7.19
Control File Recovery Example .................................................................................7.20
Control File Recovery on Tape...................................................................................7.22
Summary.....................................................................................................................7.23
Restore and Recovery Workshop ...............................................................................7.24

8. Debugging RMAN ...................................................................................... 8.1


Lesson Objectives .........................................................................................................8.2
RMAN Messages..........................................................................................................8.3
Capturing RMAN Logs ................................................................................................8.5
Debugging RMAN
Workshop A..................................................................................................................8.7
Reading RMAN Messages............................................................................................8.8
Useful Views.................................................................................................................8.9
V$PROCESS / V$SESSION ......................................................................................8.10
V$SESSION.CLIENT_INFO.....................................................................................8.12
V$SESSION_LONGOPS...........................................................................................8.13
V$SESSION_WAIT...................................................................................................8.14
Debugging RMAN
Workshop B ................................................................................................................8.15
Terminating Disk Jobs ................................................................................................8.16
RMAN Debug Mode ..................................................................................................8.17
Media Manager Debugging ........................................................................................8.18
References...................................................................................................................8.20
Summary.....................................................................................................................8.21
Debugging RMAN
Workshop C ................................................................................................................8.23

© 2005-2007 SkillBuilders, Inc. V1.0


Backup and Recovery with Oracle10g RMAN Page iv

9. Scripting and Reporting ............................................................................ 9.1


Scripting........................................................................................................................9.2
Reporting ......................................................................................................................9.5
Reporting: LIST............................................................................................................9.6
Reporting: REPORT .....................................................................................................9.9
Reporting: Views ........................................................................................................9.10
Reporting: SHOW.......................................................................................................9.12
Scripting and Reporting Workshop ............................................................................9.13

10. Getting Started With Tapes ................................................................... 10.1


Lesson Objectives .......................................................................................................10.2
Media Management Concepts ....................................................................................10.3
Installing the MML.....................................................................................................10.5
Backup to Tape ...........................................................................................................10.6
Environment Variables ...............................................................................................10.7
Default Tape Channels................................................................................................10.8
Configurable Tape Settings ........................................................................................10.9
Setting Default SBT Channels..................................................................................10.10
Backup with Default Channels .................................................................................10.11
Tape Restore .............................................................................................................10.12
V$SESSION_WAIT.................................................................................................10.13
Terminating Tape Jobs..............................................................................................10.14
Media Manager Debugging ......................................................................................10.15
Summary...................................................................................................................10.16
What We’ve Covered................................................................................................10.17
Getting Started with Tapes Workshop......................................................................10.18

11. RMAN Maintenance ............................................................................... 11.1


Lesson Objectives .......................................................................................................11.2
Expired Backups .........................................................................................................11.3
Cross-Checking Backups…........................................................................................11.4
Listing Expired Backups.............................................................................................11.7
Status of All Backups .................................................................................................11.8
Deleting Expired Backups… ......................................................................................11.9
Obsolete Backups .....................................................................................................11.11
Deleting Obsolete Backups.......................................................................................11.12
Retention Policy…....................................................................................................11.13
Summary...................................................................................................................11.15
Maintenance Workshop ............................................................................................11.16

© 2005-2007 SkillBuilders, Inc. V1.0


Backup and Recovery with Oracle10g RMAN Page v

12. Tuning RMAN ......................................................................................... 12.1


Lesson Objectives .......................................................................................................12.2
Getting Started ............................................................................................................12.3
Oracle Benchmark… ..................................................................................................12.4
Performance Factors ...................................................................................................12.6
Tuning Tools...............................................................................................................12.8
Checking RMAN Progress .........................................................................................12.9
V$SESSION_WAIT.................................................................................................12.10
The S.A.M.E. Methodology.....................................................................................12.11
Parallelism ................................................................................................................12.12
Parallelism Test….....................................................................................................12.13
Sync vs. Async I/O ...................................................................................................12.15
Enable Async IO to Tape..........................................................................................12.16
Sync vs. Async Test..................................................................................................12.17
V$SESSION.CLIENT_INFO...................................................................................12.18
Tape Compression… ................................................................................................12.19
Multiplexing…..........................................................................................................12.21
Multiplexing & Memory...........................................................................................12.23
Multiplexing Guidelines ...........................................................................................12.24
Multiplexing Tests ....................................................................................................12.25
Tape Buffer / Block Size ..........................................................................................12.26
Slowing RMAN Down .............................................................................................12.27
Backup Optimization ................................................................................................12.28
Summary...................................................................................................................12.29
References.................................................................................................................12.30
Tuning RMAN Workshop ........................................................................................12.31

13. Oracle10g Backup and Recovery Enhancements................................ 13.1


Lesson Objectives .......................................................................................................13.2
Flash Recovery Area: Concepts..................................................................................13.3
Flash Recovery Area:
Benefits .......................................................................................................................13.4
Flash Recovery Area: Configuration ..........................................................................13.6
Flash Recovery Area: Monitoring… ..........................................................................13.7
Flashback Database….................................................................................................13.9
Flashback Logs .........................................................................................................13.11
Configure Database...................................................................................................13.13
Flashback Database: Example ..................................................................................13.14
Flashback Database TO BEFORE RESETLOGS ....................................................13.15
Monitoring Flashback Database… ...........................................................................13.16
Restore Points… .......................................................................................................13.18
Simplified Recovery Through RESETLOGS (SRR)................................................13.21
SRR Architectural Changes… ..................................................................................13.22

© 2005-2007 SkillBuilders, Inc. V1.0


Backup and Recovery with Oracle10g RMAN Page vi

Compressed Backups................................................................................................13.25
Change Tracking…...................................................................................................13.26
Incrementally Updated Image Copies…...................................................................13.28
SWITCH DATABASE Command ...........................................................................13.30
Encrypted Backups ...................................................................................................13.32
RMAN DROP DATABASE ....................................................................................13.33
RMAN CATALOG Command.................................................................................13.34
DURATION Parameter ............................................................................................13.35
New V$ Views..........................................................................................................13.36
More RMAN Enhancements… ................................................................................13.37
Additional R2 RMAN Enhancements… ..................................................................13.39
User-Managed Enhancements ..................................................................................13.41
Oracle Secure Backup...............................................................................................13.42
Lesson Summary…...................................................................................................13.43

14. RMAN Case Studies............................................................................... 14.1


Lesson Objective.........................................................................................................14.2
#1 – Lost Control File.................................................................................................14.3
#1 – Solution...............................................................................................................14.4
#2 – Lost Cntl File, No Cat.........................................................................................14.5
#2 - Solution................................................................................................................14.6
#3 - Dropped Tablespace ............................................................................................14.7
#3 – Solution...............................................................................................................14.8
#4 - Tuning................................................................................................................14.10
#4 - Solution..............................................................................................................14.11

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.1

Lesson 1
Introduction to
Recovery Manager
What is Recovery Manager?

SKILLBUILDERS
© 2005-2007 SkillBuilders, Inc.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.2

1.2

Lesson Objectives
¾What is RMAN?
¾Basic Feature Summary
¾Focus on the RMAN Repository
¾9i New Features

© 2005-2007 SkillBuilders, Inc.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.3

1.3

What is RMAN?...
¾ Oracle utility for backup, restore and recovery
¾ Provides server-managed recovery
¾ Can be used in place of OS copy (user-
managed) backup techniques
¾ Automates many tasks
¾ Could be considered easier
¾ Shipped with all versions of Oracle

© 2005-2007 SkillBuilders, Inc.

Recovery Manager (usually called “RMAN”) is a utility for the backup and recovery of Oracle 8.0, 8.1
and 9.x databases. It is not compatible with Oracle7 databases. It replaces the version 7 Enterprise
Backup utility, which is now obsolete.
RMAN can be used in place of OS backup techniques (note that Oracle documentation now refers to
OS copy backup techniques as “user-managed”).
RMAN will automate many tasks. For example, RMAN Full Backups will always backup all datafiles
– without script modification – because RMAN has access to the controlfile and knows the current
structure of your database. Also, RMAN eliminates the need to locate the files needed to recover -
RMAN keeps track of this automatically. RMAN also allows administrators to create and save scripts
that perform repeated tasks.
RMAN is shipped with all versions of Oracle. A separate purchase and install is NOT necessary.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.4

1.4

...What is RMAN?
¾ Extra cost
¾ Software - $0 unless purchasing Tape software
¾ Veritas, Legato
¾ Training - ???
¾ Supports Oracle 8 and up
¾ Cannot use with version 7 databases
¾ Command line execution
¾ Or Graphical UI through Oracle Enterprise
Manager

© 2005-2007 SkillBuilders, Inc.

Since RMAN is shipped with all editions of Oracle, there is no extra cost. This changes – perhaps
drastically – if you require direct backup to tape. Except for a very rudimentary plus-in supplied by
Legato, RMAN does not ship with the capability to write to tape – you must purchase software such
as Legato Networker or Veritas Netbackup. We’ll discuss this in further detail later in this course.
RMAN was first introduced with Oracle8.0. It is not compatible with Oracle7 databases. It replaces
the version 7 Enterprise Backup utility, which is now obsolete.
RMAN commands can be executed via a command line utility (much like Server Manager) or through
the graphical user interface in Oracle Enterprise Manager.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.5

1.5

Basic Features...
¾ Full and incremental backups
¾ Online (hot) or offline backups
¾ Elimination of complex hot backup procedures
¾ RMAN server sessions automatically re-reads inconsistent
blocks
¾ No extra redo generated
¾ RMAN Intelligence:
¾ Maintains repository of backup metadata
¾ Remembers backup “set” location
¾ Knows what needs to be backed up
¾ Knows what is required for recovery
¾ Knows what backups are redundant

© 2005-2007 SkillBuilders, Inc.

Short list of basic features:


¾ Full and incremental backups – FULL backups backup all blocks. With incremental backups,
RMAN backs up only blocks that have changed since last backup.
¾ RMAN eliminates the need to put the database in “hot backup” mode. This is because RMAN
starts one or more sessions on the server (you can see them by querying V$SESSION) and
these sessions are responsible for reading blocks. Thus, the server session can detect a block
being written by DBWR and can automatically re-read the block if it detects any inconsistencies.
¾ Recording of backup history - RMAN knows what backups have been taken, where the backup
“sets” are located, what still needs to be backed up and what backups are redundant and
candidates for deletion. Perhaps most importantly, RMAN knows what files are required for
restore and recovery, helping to promote trouble-free recovery operations.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.6

1.6

...Basic Features...
¾ Parallel operations
¾ Backup to disk or tape
¾ Tape requires vendor MML
¾ Compress backups by skipping never-used blocks
¾ Extensive Reporting
¾ Scripting
¾ Create scripts for often repeated tasks
¾ O/S independent scripting language
¾ Can store in central repository

© 2005-2007 SkillBuilders, Inc.

¾ Multiple server sessions can be created on the target database; these are used to perform
backup and recovery operations in parallel
¾ Backup to tape (using tape vendor software – more on this later) or disk
¾ “Compress” backups by skipping unused blocks. RMAN does not backup blocks in datafiles
that have never been used.
¾ Extensive reporting on backups taken, what has not been backed up, what backups are
redundant and more. This includes the ability to create readable and printable logs of all
operations.
¾ RMAN can store often-repeated tasks as scripts in a recovery catalog - a central repository.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.7

1.7

...Basic Features
¾ Duplex backup sets
¾ Support for up to 4 copies
¾ Corrupt block detection
¾ Prevents creation of unusable backups
¾ Backup archive logs
¾ Housekeeping - optional automatic delete of
backed up logs
¾ Test restore
¾ Duplicate a database for testing or standby

© 2005-2007 SkillBuilders, Inc.

¾ RMAN will detect and report on corrupt blocks during the backup operation, eliminating the
creation of unusable backup sets.
¾ Via a simple command, RMAN will backup archive logs and optionally delete the logs after
successful backup.
¾ Test if backups can be restored. See the VALIDATE command.
¾ Create a duplicate database for testing or standby database use. See the DUPLICATE
command.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.8

1.8

Basic Features: Repository...


¾ RMAN maintains a repository
¾ Automatic and not optional
¾ Metadata about “target” database
¾ “Target” is the database your backing up
¾ Provides the intelligence
¾ What has been backed up and when – what has
not?
¾ Where are the backup sets?

© 2005-2007 SkillBuilders, Inc.

RMAN creates and maintains a repository of metadata about the target databases. (“Target” in
RMAN parlance simply means the database that your backup up.) This is not an optional feature.
The repository provides the intelligence in RMAN. For example, this allows RMAN to keep track of
backups. RMAN knows what has been backed up, what has not and where the backup sets (one or
more OS files) are located, plus much more.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.9

1.9

...Basic Features: Repository


¾ Contents
¾ Backup History
¾ History of log switches
¾ Archive log history
¾ Structure of target database

¾ Located in 1 or 2 places
¾ TargetDatabase control file
¾ Optional – Recovery catalog on separate database

© 2005-2007 SkillBuilders, Inc.

The repository contains redo log information including the history of log switches and archived logs,
the history of backups taken and the structure of the target database.
RMAN always maintains a copy of the repository in the target database’s control file – this is not
optional.
Additionally, RMAN can keep a copy of the repository in a separate recovery catalog. The recovery
catalog should be stored in a separate database – optimally on a separate machine.
We will study more about the control file, repository and recovery catalog in the RMAN Architecture
lesson.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.10

1.10

9i New Features...
¾ Persistent Configurations
¾ Use the CONFIGURE command to tailor RMAN environment
¾ Configure automatic channels, retention policies, number of
backup copies and more
¾ Automatic Channels
¾ RMAN automatically allocates channel (optional)
¾ Channels are configurable
¾ AUTOBACKUP of control file
¾ Automatic backup to known name and location
¾ Recover even if control file and RMAN catalog are lost

© 2005-2007 SkillBuilders, Inc.

Oracle9i RMAN added many new features:


¾ The new CONFIGURE command provides the ability to configure the RMAN environment. The
settings affected by CONFIGURE remain in effect until explicitly reset. Some of the things that
can be configured include channels, retention policies, control file autobackup and more.
¾ Channels are connections to server sessions performing the work of backup and recovery.
Automatic channel allocation eliminates the sometimes tedious task of repeatedly reallocating
channels and simplifies command syntax.
¾ Via the CONFIGURE CONTROLFILE AUTOBACKUP ON; command, we tell RMAN to backup
the control file anytime a BACKUP or COPY command is executed. This provides additional
protection even if we lose the control file and the recovery catalog. See examples later in this
document.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.11

1.11

...9i New Features...


¾ Restartable backups
¾ Restarta long running backup after crash
¾ See the NOT BACKED UP SINCE option

¾ Simpler command syntax


¾ Eliminate RUN blocks in some cases
¾ Recovery at the block level
¾ Block Media Recovery

© 2005-2007 SkillBuilders, Inc.

¾ RMAN now supports restartable operations. The unit of restart is a backupset (complete set of
backed up datafiles or archived logs). Multiple backupsets can be created in a single backup –
the advantage of this is that if the backup fails, any complete backupsets do not need to be
redone. See the NOT BACKED UP SINCE clause and “Restartable Backups” section of the
Recovery Manager Users Guide for more information.
¾ The command syntax has been simplified. No longer is it necessary to code the backup,
restore an recover commands in a RUN block.
¾ Block Media Recovery (BMR), is the ability to restore and recover corrupt blocks, rather than an
entire datafile or tablespace. See the BLOCKRECOVER command.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.12

1.12

...9i New Features


¾ Backup and Restore Optimization
¾ Skip restore if file present
¾ Skip backup if already backed up
¾ Adheres to configured redundancy policy
¾ Smarter backup of archive logs
¾ Automatically switches and backs up online logs
before/after backup of database
¾ Useful for online backups – consistent backup set
¾ User defined retention policies
¾ How long OR how many backups should be kept

© 2005-2007 SkillBuilders, Inc.

¾ Restore optimization: RMAN will not restore a file is it has not changed. Can be overridden with
the FORCE option.
Backup optimization: Use the CONFIGURE BACKUP OPTIMIZATION command to tell RMAN
not to backup a file if it has not changed (checks SCN and timestamp). This will decrease
backup elapsed time.
¾ 9i can easily backup online and archive logs with the BACKUP DATABASE PLUS
ARCHIVELOG command. This insures that you create a consistent backup set for backups
done while the database is open.
¾ Create user-defined retention policies. For example, we can configure RMAN so that backups
are retained for 30 days:
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS;
The REPORT OBSOLETE and DELETE OBSOLETE commands will now only report and
delete, respectively, backup sets that are older than 30 days. Alternatively, you can configure
RMAN to retain multiple copies of a backup:
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
Redundancy is mutually exclusive from RECOVERY Window. Recovery Window is usually a
better method but redundancy “1” is the default to maintain compatibility with the 8i REPORT
OBSOLETE command.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.13

1.13

9i R2 New Features...
¾ Backup of Server Parameter Files
¾ Structural DB changes initiate automatic
control file and SPFILE backup
¾ Smarter handling of archived logs
¾ Create duplicate backups before deleting archive
logs with NOT BACKED UP x TIMES
¾ Control and limit space used during recovery with
RESTORE . . . DELETE ARCHIVELOG command

© 2005-2007 SkillBuilders, Inc.

Release 2 of Oracle9i (9.2.x) provides several new features:


¾ RMAN now recognizes the server parameter file. Use the BACKUP SPFILE command.
¾ If CONFIGURE CONTROLFILE AUTOBACKUP is set to ON, RMAN will automatically backup
the control file and server parameter file (if used) whenever a structural change is made to the
database. This includes CREATE/DROP TABLESPACE, online-ing or offline-ing a tablespace,
adding a new online redo log, renaming a file and more. A message is written to the database
alert log that includes the location of the backup set.
Release 2 has better support for archive logs:
¾ You may want to take a second backup of your archive logs prior to deleting them from disk.
Consider using the BACKUP ARCHIVELOG . . . NOT BACKED UP 2 TIMES followed by
DELETE ARCHIVELOG ALL BACKED UP 2 TIMES.
¾ A restore operation may require a tremendous amount of disk space. Space used by the
restore of archive logs can be controlled by the used of the DELETE ARCHIVELOG parameter
of the RECOVER DATABASE command. This parameter will cause RMAN to delete an archive
log after it has been applied.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.14

1.14

...9i R2 New Features


¾ DBNEWID utility available to change DBID or DB
name
¾ New views available
¾ V$DATABASE_BLOCK_CORRUPTION and
RC_DATABASE_BLOCK_CORRUPTION
¾ V$DATABASE_INCARNATION and
RC_DATABASE_INCARNATION
¾ Skip specified tablespaces when duplicating DB
¾ Automatic tags for backups and copies
¾ Improved error messages

© 2005-2007 SkillBuilders, Inc.

New Features continued from the previous page:


¾ A recovery catalog will not accept duplicate DBID’s. If you have used OS commands to create
copies of your database, and now would like to register that database in the same recovery
catalog, use the DBNEWID to change the DBID (and database name, if desired). Using the
RMAN DUPLICATE command, you will avoid the problem of duplicate DBID’s.
¾ New views are available:
¾ V$DATABASE_BLOCK_CORRUPTION lists the logically or physically (media) corrupt
blocks found in the recent BACKUP, BACKUP VALIDATE or COPY operation. This can
be used as input to a block recover operation. See the BLOCKRECOVER command. The
RC_DATABASE_BLOCK_CORRUPTION is the equivalent view in the recovery catalog.
¾ V$DATABASE_INCARNATION lists the incarnations of the database created with an
OPEN RESETLOGS operation.
¾ Tags are a name for a given backup that can be used to help identify the backup and can be
used in the RESTORE command. (e.g. WEEKLY_BACKUP) R2 creates tags automatically if
one is not specified on the BACKUP command, in the format TAGYYYYMMDDTHHMMSS.

© 2005-2007 SkillBuilders, Inc. V1.0


Introduction to Recovery Manager 1.15

1.15

Introduction Complete!
¾ OK, we know what RMAN is
¾ We know some basic functions
¾ We have seen some Release 2 features
¾ Let’s look at the architecture…

© 2005-2007 SkillBuilders, Inc.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.1

Lesson 2
RMAN Architecture
An introduction to the architecture and
components used by the RMAN utility.

SKILLBUILDERS
© 2005-2007 SkillBuilders, Inc.

Author: Dave Anderson, SkillBuilders

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.2

2.2

Lesson Objectives
¾ RMAN Components
¾ Effect of mixed releases
¾ Control File and RMAN
¾ CONTROL_FILE_RECORD_KEEP_TIME parameter
¾ Creation
¾ Size

¾ Operating in NOCATALOG Mode


¾ Using a Recovery Catalog
¾ Synchronizing the Catalog

© 2005-2007 SkillBuilders, Inc.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.3

2.3

RMAN Components...
¾ RMAN executable
¾ Client application
¾ Can run on entirely separate machine
¾ Starts server sessions on Target Database

¾ Target Database
¾ Database to be backed up
¾ Control file contains RMAN metadata

¾ Catalog Database
¾ Optional database to hold Recovery Catalog

© 2005-2007 SkillBuilders, Inc.

An RMAN environment is comprised of several components, each of which has a release (or version)
number.
¾ The RMAN executable is an Oracle client application. This client application spawns server
sessions on the target database to do the work of backup or recovery. It is similar in some
ways to SQL*Plus in that it allows connections to databases and provides a line mode
command interface. It is different in that it allows multiple concurrent connections (one to the
target, one to the catalog database and optionally a third to an “auxiliary” database) and it does
not support SELECT statements. (RMAN actually spawns multiple sessions on the target
database, but supports one CONNECT to the target.)
¾ The Target database is the database to be backed up or recovered. It is where the server
sessions spawned by the RMAN executable run. The target database’s control file contains
recovery metadata - that is, information about backups that have been taken. This information
is needed to perform recovery.
¾ The Catalog database is a separate database created to hold the recovery catalog. It is
optional database because the recovery catalog is optional. See the next page for more
information on the Recovery Catalog.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.4

2.4

...RMAN Components
¾ Recovery Catalog
¾ Optional
¾ Secondary location for RMAN repository
¾ Primary location is target database control file
¾ Contains backup metadata
¾ Media Management Library
¾ Required if backing up to tape
¾ Communicates with server session on target
database
¾ Reads and Writes to tape

© 2005-2007 SkillBuilders, Inc.

¾ The recovery catalog is a series of tables and view owned by a single user (typically called
“RMAN”) populated with backup and recovery information for one or more databases. Since the
target database’s control file also contains this information, this is an optional component.
However, it is recommended. See more in the section “Recovery Catalog" later in this lesson.
¾ Oracle and RMAN do not come with the ability to directly read and write to tape. You must
install compliant software, called a “media management library”, from a tape software vendor.
Oracle ships with an free but scaled down MML from Legato (e.g. the tape drive must reside on
the server). For a list of vendors supplying MML’s visit:
http://otn.oracle.com/deploy/availability/htdocs/bsp.htm.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.5

2.5

Component Releases
¾ Each component has a release or version
¾ Mixing releases can be problematic
¾ For example, assume
¾ Group of 8.1.x production databases – targets
¾ Install new 9i database to hold recovery catalog
¾ Want to use 9i RMAN to backup 8.1.x DB’s
¾ No Good!
¾ See RMAN compatibility matrix
¾ “The versions of the RMAN executable and the target
database should be the same”
¾ http://metalink.oracle.com

© 2005-2007 SkillBuilders, Inc.

Each component in the RMAN environment has a release – and often they are not the same. For
example, you may have a group of release 8.1.x production (target) databases that you would like to
back up with RMAN. You would like to create a new database to hold you recovery catalog and
choose to install Oracle9i. Finally, to take advantage of the new 9i RMAN features, you would like to
use 9i RMAN to backup your 8.1.x databases. However, this is not valid! You will need to backup
your 8.1.x databases with a 8.1.x version of RMAN. Oracle documentation states “The versions of
the RMAN executable and the target database should be the same.” So, in fact, you will need
multiple copies of RMAN to backup your mixed release environment.
See the RMAN compatibility guide for more information. Login to Metalink and search on “RMAN
compatibility” for the latest compatibility guide.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.6

2.6

The Control File…


¾ Always the initial repository of RMAN metadata
¾ Control File contains
¾ Circularly reusable records
¾ Non-reusable records for datafiles and logs
¾ Persistent configuration setting records
¾ Circularly reusable records
¾ Initial allocation of empty records (slots)
¾ LGWR and ARCH add data
¾ History of log switches
¾ Archive log history
¾ Backup history
Control retention with
CONTROL_FILE_RECORD_KEEP_TIME parameter
© 2005-2007 SkillBuilders, Inc.

The control file is actually always used as a repository for RMAN metadata, even if you also use a
recovery catalog. It is the only repository of data if you use RMAN in NOCATALOG mode. See the
“NOCATALOG Mode” section later in this lesson.

The control file is made up of records or slots. There are 3 types of records in the control file:
¾ Circularly reusable records – these records can be overwritten after they are older than value
specified in CONTROL_FILE_RECORD_KEEP_TIME parameter.
¾ Non-Reusable records – these records cannot be overwritten.
¾ Persistent Configuration records – these records contain the RMAN environment settings. They
are changed with the CONFIGURE command.

Initially, (just after CREATE DATABASE) the records are mostly empty. As activity occurs on the
database, the control file receives information about log switches and archived logs from the log
writer and archive writer background processes. This information is stored in reusable records in the
control file. The CONTROL_FILE_RECORD_KEEP_TIME parameter controls when a reusable
record expires – which means the record can be overwritten. The purpose of the CFRKT parameter
is to specify a recovery window – how far back in time you would like to be able to recover to.
Tom Kyte of “asktom.oracle.com” says: “set your control_file_record_keep_time to be at least one
day GREATER then the period of time between your backups, else there is a chance that an archive
record gets aged out during the backup which thoroughly confuses the situation.”

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.7

2.7

…The Control File


¾ Control file size will grow
¾ Affected by
¾ CONTROL_FILE_RECORD_KEEP_TIME parameter
¾ Frequency of log switches
¾ Frequency of backups

© 2005-2007 SkillBuilders, Inc.

The control file become larger as log switches, archiving and backups are performed. The records
generated for log switches and archive logs can be overwritten – thus negating the need for the
control file to expand – but not until the records are older than the value in the
CONTROL_FILE_RECORD_KEEP_TIME parameter. Thus, this parameter has a direct affect on the
size of the control file.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.8

2.8

CFRKT Parameter...
¾ CONTROL_FILE_RECORD_KEEP_TIME parameter
controls reuse of reusable records
¾ Minimum age in days of a reusable record before it
can be overwritten
¾ Reusable records EXPIRE
¾ Default is 7 days
¾ Maximum 365 days
¾ Minimum 0
¾ Overwritten metadata is lost, unless
¾ Using a recovery catalog and RESYNC catalog prior to
overwrite
¾ More on this later…

© 2005-2007 SkillBuilders, Inc.

The CONTROL_FILE_RECORD_KEEP_TIME parameter helps control control file size by specifying,


in days, how old a reusable record must be before it can be overwritten. So, for example, a value of
7 means that a backup record can not be reused (overwritten) unless it has existed for 7 days.
The default value of the CONTROL_FILE_RECORD_KEEP_TIME is 7 days; the minimum is 0 and
the maximum is 365 days. Setting to 0 effectively turns off expiration check, i.e. reusable records are
reused as necessary (and the control file will not expand). Use with caution and you can lose
metadata RMAN needs for recovery
Overwritten metadata is lost - unless you use a recovery catalog and update the catalog with the
RESYNC CATALOG command before the record is overwritten. If the
CONTROL_FILE_RECORD_KEEP_TIME value is 5, you need to resync the catalog every 4 days or
less. See more about resync Catalog in the “Recovery Catalog Maintenance” section of this lesson.
Note that losing the metadata does not necessarily mean you cannot recover. It simply means that
RMAN does not know about it and thus cannot use it in RMAN recovery. If the backup data is still
available (the RMAN backup sets and Oracle archived logs), you can still manually apply them to the
database.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.9

2.9

...CFRKT Parameter

system@DAVE>
system@DAVE> show
show parameter
parameter control_file_record_keep_time
control_file_record_keep_time

NAME
NAME TYPE
TYPE VALUE
VALUE
------------------------------------
------------------------------------ ----------- ------
----------- ------
control_file_record_keep_time
control_file_record_keep_time integer
integer 77

system@DAVE>
system@DAVE> alter
alter system
system
22 set
set control_file_record_keep_time
control_file_record_keep_time == 30 30
33 comment='30
comment='30 days
days of
of history
history in
in control
control file'
file'
44 scope
scope == both;
both;

System
System altered.
altered.

© 2005-2007 SkillBuilders, Inc.

The CONTROL_FILE_RECORD_KEEP_TIME parameter is a dynamic parameter. This example


illustrates how to change the value.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.10

2.10

Control File Creation...


CREATE
CREATE DATABASE
DATABASE prod
prod
MAXINSTANCES
MAXINSTANCES 11
MAXLOGHISTORY
MAXLOGHISTORY 11
MAXLOGFILES
MAXLOGFILES 55
MAXLOGMEMBERS
MAXLOGMEMBERS 55
MAXDATAFILES
MAXDATAFILES 100
100
..
..
..
LOGFILE
LOGFILE GROUP
GROUP 11 ('C:\Oracle\oradata\prod\redo01.log')
('C:\Oracle\oradata\prod\redo01.log')
SIZE
SIZE 100M,
100M,
GROUP
GROUP 22 ('C:\Oracle\oradata\prod\redo02.log')
('C:\Oracle\oradata\prod\redo02.log') SIZE
SIZE 100M,
100M,
GROUP
GROUP 3 ('C:\Oracle\oradata\prod\redo03.log') SIZE 100M
3 ('C:\Oracle\oradata\prod\redo03.log') SIZE 100M

© 2005-2007 SkillBuilders, Inc.

The CREATE DATABASE command creates the control file. Several parameters on this command
affect the construction of the control file. For example, the MAXDATAFILES parameter allocates a
fixed number of empty records (slots) to hold information about the datafiles. In this example, we can
add 100 datafiles to this database. The control file would need to be re-created if we later want to
add more datafiles.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.11

2.11

...Control File Creation...


¾ Excerpt from
V$CONTROLFILE_RECORD_SECTION
select
select type,
type, record_size,
record_size, records_total,
records_total, RECORDS_USED
RECORDS_USED
from
from v$controlfile_record_section
v$controlfile_record_section

TYPE
TYPE RECORD_SIZE
RECORD_SIZE RECORDS_TOTAL
RECORDS_TOTAL RECORDS_USED
RECORDS_USED
------------------
------------------ ----------- ------------- ------------
----------- ------------- ------------
DATABASE
DATABASE 192
192 11 11
REDO LOG
REDO LOG 72
72 55 33
DATAFILE
DATAFILE 180
180 100
100 66
RMAN
RMAN CONFIGURATION
CONFIGURATION 1108
1108 50
50 00
LOG HISTORY
LOG HISTORY 36
36 226
226 77
OFFLINE RANGE
OFFLINE RANGE 56
56 145
145 00
ARCHIVED LOG
ARCHIVED LOG 584
584 13
13 00
BACKUP
BACKUP SET
SET 40
40 204
204 00
© 2005-2007 SkillBuilders, Inc.

The dynamic view V$CONTROLFILE_RECORD_SECTION is a way of looking at the fixed and


reusable records contained within the control file.
This example shows that just after database creation (i.e. control file creation), Oracle has reserved
empty records, or slots, for information to be added later.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.12

2.12

...Control File Creation


¾ CREATE DATABASE MAXLOGFILES 5
¾ Control file contains 5 records of type “REDO
LOG”.
¾ CREATE DATABASE MAXDATAFILES 100
¾ Control
file contains 100 records of type
“DATAFILE”.
¾ CREATE DATABASE MAXLOGHISTORY 1
¾ But,control file created 226 records of type “LOG
HISTORY”.

© 2005-2007 SkillBuilders, Inc.

Here are some notable comparisons between the CREATE DATABASE on the previous page and
this example:
¾ CREATE DATABASE MAXLOGFILES 5 – And the control file contains 5 records of type “REDO
LOG”. Only 3 are used because the CREATE DATABASE command only specifies 3 log files.
¾ CREATE DATABASE MAXDATAFILES 100 – And the control file contains 100 records of type
“DATAFILE”. Only 6 are used because so far only 6 datafiles have been created.
¾ CREATE DATABASE MAXLOGHISTORY 1 – But the control file created 226 records of type
“LOG HISTORY”. These record information about log switches. This is not documented, but I
believe this is the minimum (and default) for a Windows 2000 system.

Note that only 13 records have been created for “ARCHIVED LOGS”. There is no documented
control for this on the CREATE DATABASE command. Certainly, we will want to keep history for
more than 13 archived logs. This will happen because additional records will be dynamically added
to the control file, causing the control file size to increase. See the next page for more information.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.13

2.13

Control File Size...


¾ Size can dynamically grow
¾ Log switches and archiving can add many records
¾ Empty slots can fill up quickly
¾ More records added if necessary
¾ If existing records not expired
¾ See the CFRKT parameter
¾ Limit = 65535 log switch records
¾ Will start to overwrite non-expired records
¾ Warnings given
¾ Does not automatically shrink

© 2005-2007 SkillBuilders, Inc.

The size of the control file will grow in size because of the RMAN data.

If new information needs to be recorded, and all the available slots have been used, RMAN will do
one of the following:
If there are expired records, RMAN will overwrite the expired records. No warnings are given.
If there are no expired records, RMAN will allocate more. This will cause the size of the file to grow.
No warnings are given.
If the LOG HISTORY and/or ARCHIVED LOG section has reached its maximum of 65,535 records
AND there are no expired records, Oracle will begin to overwrite non-expired records, starting at the
oldest record. Warnings are produced in the alert log.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.14

2.14

...Control File Size...


¾ Effect of 65,000 + log switches in 3 days
¾ CFRKT = 7
¾ Size grew to 81 MB
¾ Duplexed 3 times , 243 MB
¾ V$CONTROLFILE_RECORD_SECTION shows
growth:
TYPE
TYPE RECORD_SIZE
RECORD_SIZE RECORDS_TOTAL
RECORDS_TOTAL RECORDS_USED
RECORDS_USED
------------------
------------------ -----------
----------- -------------
------------- ------------
------------
LOG
LOG HISTORY
HISTORY 36
36 65535
65535 65535
65535
ARCHIVED LOG
ARCHIVED LOG 584
584 65535
65535 65535
65535

¾ Log history has maxed out!!!!


© 2005-2007 SkillBuilders, Inc.

Not only did my control file grow to 81MB, but we now start to receive warnings that the control file
cannot be expanded further because the log history records section has reached its maximum of
65,535 records.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.15

2.15

...Control File Size...


¾ Maximum log history records is 65535
¾ Oracle docs wrong on this – say no maximum
¾ Make sure CFRKT not too high if many log
switches occur each day

© 2005-2007 SkillBuilders, Inc.

The initial number of records allocated for log switches is defined by MAXLOGHISTORY. The
Oracle documentation says that the number of records that can be allocated is limited only by OS file
size limitations or available disk space. This is incorrect. So, if your CFRKT parameter is high, say
for example 300, and the number of log switches is also high, say 350 a day, then in 187 days (350 *
187) or less, you will have a problem. The problem is that your control file will have allocated the
maximum 65535 slots for log switches, and the oldest record has not expired, meaning that Oracle
has nowhere to put the new log switch data.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.16

2.16

...Control File Size


¾ Error when no expired records and max log switch
65535 records allocated:
ARC0:
ARC0: Beginning
Beginning toto archive
archive log
log 22 thread
thread 11 sequence
sequence 65533
65533
kccrsz:
kccrsz: denied
denied expansion
expansion ofof controlfile
controlfile section
section 11
11 by
by 24238
24238
record(s)
record(s)
the
the number
number of
of records
records is
is already
already atat maximum
maximum value
value (65535)
(65535)
krcpwnc:
krcpwnc: following
following controlfile
controlfile record
record written
written over:
over:
RECID
RECID #4
#4 Recno
Recno 65526
65526 Record
Record timestamp
timestamp 05/22/02
05/22/02 13:10:55
13:10:55

¾ Set CFRKT = 0 to shutoff expiration checks


¾ And/Or Increase log file size

© 2005-2007 SkillBuilders, Inc.

We can see here that Oracle will start to overwrite non-expired log records.

Possible Solutions:
¾ Set the CONTROL_FILE_RECORD_KEEP_TIME parameter = 0. This will turn off the expiration
check. Use with caution because non-expired records will be written over. If you are using a
recovery catalog, be sure to resync catalog immediately and frequently. Consider an hourly
scheduled job to resync the catalog.
¾ Increase the size of the log files. This will reduce the number of log switches and archived logs.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.17

2.17

NOCATALOG Mode...
¾ Control file is sole source of backup data
¾ Self-contained RMAN environment
¾ Recommended for
¾ Single database environments
¾ Test and development databases
¾ Recovery catalog databases
¾ Set CFRKT to the maximum number of days that you
would think you would possibly want to go back for
recovery
¾ E.g. Weekly full backups
¾ CFRKT = 15 provides 2 weeks of archive log history

© 2005-2007 SkillBuilders, Inc.

NOCATALOG mode is the default. This means that a recovery catalog will not be used and the
target database’s control file is the only repository of RMAN backup information. Oracle
recommends that you use this mode for small, single database environments and development
databases. Environments with many production databases should use CATALOG mode.

Set CONTROL_FILE_RECORD_KEEP_TIME to the maximum number of days that you would think
you would possibly want to go back for recovery.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.18

2.18

...NOCATALOG Mode
¾ Protect control file!
¾ Contains history of backups and archive logs
¾ Needed to RESTORE and RECOVER
¾ Duplex with CONTROL_FILES parameter
¾ Backup frequently
¾ Use 9i AUTOBACKUP feature

© 2005-2007 SkillBuilders, Inc.

In the event of a RESTORE/RECOVERY operation, RMAN relies on the control file for a record of
backups taken when a recovery catalog is not used. What happens if you lose the control file in this
mode? That depends on a few things:
¾ Oracle9i and AUTOBACKUP ON – Easy to RESTORE CONTROLFILE. Oracle9i and
AUTOBACKUP OFF – Difficult, possibly impossible, to recover.
Note this warning about loss of control files is included in the Oracle8i Backup and Recovery
manual:
“WARNING: It is difficult to restore and recover if you lose your control
files and do not use a recovery catalog. The only way to restore and
recover when you have lost all control files and need to restore and
recover datafiles is to call OracleWorldWide Support (WWS). WWS will need
to know:
The current schema of the database.
Which files were backed up.
When the files were backed up.
The names of the backup pieces containing the files.”

Overcome this problem by using the Oracle9i control file AUTOBACKUP feature. See the lesson
titled Backup with RMAN for details on using AUTOBACKUP.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.19

2.19

Recovery Catalog...
¾ Tables and views contain metadata
¾ Backup data for 1 or more target databases
¾ Owned by user “RMAN”
¾ See the “RC_” views
¾ Optional
¾ Target database control file also contains recovery metadata
¾ But, some functionality lost:
¾ Cannot store RMAN scripts
¾ Cannot restore to an old “incarnation” of the database
(see the OPEN RESETLOGS option)

© 2005-2007 SkillBuilders, Inc.

The recovery catalog is a series of tables and view owned by a single user (typically called “RMAN”).
Via the RMAN REGISTER command, these views are populated with backup and recovery
information for one or more databases.
After creating the catalog in the RMAN schema, you will notice a series of views starting with “RC_”.
These are the recovery catalog views; these views can be queried for information on backups.
Since the target database’s control file also contains this information, this is an optional component.
However, it is recommended.
Using a recovery catalog is optional. The control file of the target database also contains recovery
metadata (in fact, the recovery catalog is populated from information stored in the target databases
control file with the RESYNC CATALOG command). However, though RMAN is still very useful
without a recovery catalog, some RMAN functions are lost. For example, you cannot create and
store RMAN scripts and you cannot restore to an older incarnation of the database. (An incarnation
of the database is created when you open the database with the “RESETLOGS” option – necessary
when a point-in-time recovery is performed.)

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.20

2.20

...Recovery Catalog...
¾ The recovery catalog stores information on:
¾ Backup sets and pieces
¾ Image copies
¾ Archived redo logs
¾ Structure of target database
¾ User scripts

¾ Does not contain backup data


¾ Backup data stored in backup sets
¾ OS files on tape or disk

© 2005-2007 SkillBuilders, Inc.

The recovery catalog stores information on:


¾ Backup sets and pieces. (files that contain backups)
¾ Image copies (Mirror image copies of datafiles.)
¾ Archived redo logs
¾ Structure of target database
¾ User scripts (recovery manager commands & SQL)

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.21

2.21

...Recovery Catalog...
¾ Create a separate database to hold RMAN recovery
catalog
¾ On a separate server (with OEM?)
¾ Can create 1 recovery database/catalog for many target
DB1 databases
Target databases RCAT database

DB3 RMAN DB4 Recovery


Executable catalog
DB2

© 2005-2007 SkillBuilders, Inc.

The RMAN client application can CONNECT to both a TARGET and a CATALOG (recovery)
database. The target database is the database to be backed up. The recovery database contains a
recovery catalog. The recovery catalog can contain metadata for many target databases.
Create the recovery catalog in a separate database! You do not want to lose the recovery catalog if
you lose your production (target) database – you would not be able to recover. A helpful
recommendation that I found on the Oracle Technology Network
(otn.oracle.com/availability/htdocs/9ifaq.html) was to create your recovery catalog in the same
database that contains your Oracle Enterprise Manager repository.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.22

2.22

...Recovery Catalog
¾ Backup recovery catalog database
¾ Consider:
¾ RMAN in NOCATALOG mode
¾ EXPORT
¾ User-managed backups
¾ Increase
CONTROL_FILE_RECORD_KEEP_TIME to
maintain safe restore window

© 2005-2007 SkillBuilders, Inc.

The database that contains the recovery catalog must also be backed up. For the RMAN catalog
database, Oracle suggests using RMAN in NOCATALOG mode (to eliminate the need for a recovery
catalog for the recovery catalog). If you choose this technique, consider increasing the
CONTROL_FILE_RECORD_KEEP_TIME to a larger value so more days of backup data are kept
before being overwritten.
You could also consider:
¾ user-managed backups for the recovery catalog database. (User-managed backups are the
old-style OS copy command backups.)
¾ EXPORT. This is a flexible option because you could restore (IMPORT) the recovery catalog
into any working database for the recovery.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.23

2.23

Recovery Catalog
Maintenance...
¾ RESYNC CATALOG command updates
recovery catalog
¾ Propagate new and changed information into
catalog
¾ Log history
¾ New datafiles

¾ Automatic re-syncs when you execute:


¾ RMAN commands backup, copy, crosscheck,
delete, duplicate, list, recover, switch

© 2005-2007 SkillBuilders, Inc.

Keeping the recovery catalog updated with the information from the current control file is critical and
is easily accomplished with the RESYNC CATALOG RMAN command. If we never updated the
recovery catalog with metadata from the control file, and we lost the target database and control file,
RMAN would not know, for example, the most recent structure of the database and the that certain
archived logs exist and would not be able to fully recover your database.

RMAN performs automatic resynchronizations whenever you issue a backup command (other
commands as well).

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.24

2.24

...Recovery Catalog
Maintenance
¾ Must re-sync before data in control file overwritten!
¾ Check CONTROL_FILE_RECORD_KEEP_TIME parameter
¾ Backup or issue RESYNC CATALOG before CFRKT
parameter value!
¾ Frequency of manual re-sync?
¾ Log switches and archiving can occur frequently
¾ e.g. 1000 log switches before backup taken
¾ Consider scheduling hourly job to resync catalog
¾ Inexpensive operation
¾ Alternative: expensive resync during backup

© 2005-2007 SkillBuilders, Inc.

Be sure that a re-sync is performed before the duration specified in the


CONTROL_FILE_RECORD_KEEP_TIME parameter.
If your database supports high volume of DML operations, you may want to consider frequent manual
resynchronizations. For example, assume the database experiences 1000 log switches in between
backup operations. In this case, the resync of the catalog could be reasonably time consuming. If
you schedule hourly cron jobs to RESYNC CATALOG, you will avoid this situation.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.25

2.25

Where We've Been...


¾ Components
¾ RMAN executable
¾ Target Database
¾ Recovery Database (optional)
¾ Recovery Catalog (optional)
¾ MML

¾ Control File
¾ Initial
repository of RMAN metadata
¾ Watch for growth

© 2005-2007 SkillBuilders, Inc.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.26

2.26

...Where We've Been


¾ NOCATALOG Mode
¾ OK for small DB’s, test
¾ Recovery Catalog
¾ Create in separate database
¾ Synchronizing the Catalog
¾ Keep in sync with control file
¾ Next lesson covers setting up catalog
¾ Also see chapters 16 – 18 of the Oracle9i
Recovery Manager Users Guide

© 2005-2007 SkillBuilders, Inc.

Chapters 16 through 18 of the Oracle9i Recovery Manager User’s Guide is dedicated to maintaining
and querying the RMAN repository. In the next lesson in this course we will learn – and practice –
setting up a recovery catalog.

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.27

2.27

RMAN Architecture Workshop


¾ RMAN Architecture Questions for review

© 2005-2007 SkillBuilders, Inc.

RMAN Architecture Workshop


1. Assume you have twelve Oracle 9.0.1 databases that you are responsible for backing up. All can
be reached from your workstation via SQL*Net. Answer the following questions:
1. Q. How many copies of the RMAN executable will you use?
2. Q. Where will you install the RMAN executables?
3. Q. Will you use a Recovery Catalog? Why?
4. Q. If you will use a Recovery Catalog, where will you locate the catalog? Why?
5. Q. If you will use a Recovery Catalog, how will you backup the recovery database?

Continued on the next page…

© 2005-2007 SkillBuilders, Inc. V1.0


RMAN Architecture 2.28

2. Assume you have twelve Oracle databases that you are responsible for backing up. They
range in release from 7.3 to 9.1. All can be reached from your workstation via SQL*Net.
Answer the following questions:
1. Q. How many copies of the RMAN executable will you use?
2. Q. Where will you install the RMAN executables?
3. Q. Will you use a Recovery Catalog? Why?

3. Assume that you have one Oracle 9.0.1 database to backup, and only one machine at your
disposal. Answer the following questions:
1. Q. Will you use a Recovery Catalog? Why?
2. Q. If you decide to backup every 7 days, what value will you set the
CONTROL_FILE_RECORD_KEEP_TIME parameter to?

4. Look in the alert log on your sample database for the CREATE DATABASE command. What
are the following set to:
1. MAXLOGHISTORY:
2. MAXLOGFILES:
3. MAXDATAFILES:

5. Query V$CONTROLFILE_RECORD_SECTION. What are the RECORDS_TOTAL and


RECORDS_USED for the following records types:
1. DATAFILE
2. REDO LOG
3. LOG HISTORY
4. Q. Do the values match the values specified on the CREATE DATABASE command?
Why or why not?
6. Log in as SYSTEM and execute: ALTER SYSTEM SWITCH LOGFILE;
7. Query V$CONTROLFILE_RECORD_SECTION again. What changed in the LOG HISTORY
records area of the control file?

© 2005-2007 SkillBuilders, Inc. V1.0

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