+ All Categories
Home > Documents > Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Date post: 08-Apr-2015
Category:
Upload: srav2010
View: 913 times
Download: 26 times
Share this document with a friend
330
Oracle9i Database: Supporting Recovery Manager Student Guide D13929GC10 Production 1.0 June 2002 D34786 Oracle Internal & OAI Use Only
Transcript
Page 1: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery ManagerStudent Guide

D13929GC10Production 1.0June 2002D34786

Oracle In

ternal & O

AI Use

Only

Page 2: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Copyright © Oracle Corporation, 2002. All rights reserved.

This documentation contains proprietary information of Oracle Corporation. It is provided under a license agreement containing restrictions on use and disclosure and is also protected by copyright law. Reverse engineering of the software is prohibited. If this documentation is delivered to a U.S. Government Agency of the Department of Defense, then it is delivered with Restricted Rights and the following legend is applicable:

Restricted Rights Legend

Use, duplication or disclosure by the Government is subject to restrictions for commercial computer software and shall be deemed to be Restricted Rights software under Federal law, as set forth in subparagraph (c)(1)(ii) of DFARS 252.227-7013, Rights in Technical Data and Computer Software (October 1988).

This material or any portion of it may not be copied in any form or by any means without the express prior written permission of Oracle Corporation. Any other copying is a violation of copyright law and may result in civil and/or criminal penalties.

If this documentation is delivered to a U.S. Government Agency not within the Department of Defense, then it is delivered with “Restricted Rights,” as defined in FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).

The information in this document is subject to change without notice. If you find any problems in the documentation, please report them in writing to Education Products, Oracle Corporation, 500 Oracle Parkway, Box SB-6, Redwood Shores, CA 94065. Oracle Corporation does not warrant that this document is error-free.

Oracle and all references to Oracle Products are trademarks or registered trademarks of Oracle Corporation.All other products or company names are used for identification purposes only, and may be trademarks of their respective owners.

AuthorJim Womack

Technical Contributorsand ReviewersAgustin AmadorDarren PriceDonna KeeslingHarald van BreederodeJaime FigueroaJanet SternLex De HaanMatthew ArrochaMatthew HartMuthu OlagappanPetter SteneRavinder RansiRic Van DykeSharmila KulasekaramVicki Obrien

PublisherGlenn Austin

Oracle In

ternal & O

AI Use

Only

Page 3: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

1 Overview of Recovery ManagerObjectives 1-2Recovery Manager 1-3RMAN Features 1-4RMAN Architecture 1-6The RMAN Environment 1-7RMAN Version Compatibility 1-8RMAN Components 1-9Recovery Manager Utility Executable 1-11Recovery Manager Executable: The recover.bsq File 1-12Recovery Catalog 1-13Target Database: Controlfile Tables and Views 1-14Target Database: SYS.DBMS_RCVMAN 1-15Target Database: DBMS_BACKUP_RESTORE 1-16Channels and Media Manager Server 1-18Running RMAN Commands 1-19Simple Backup and Recovery Concepts 1-20Database Inconsistency 1-22Comparing Redo and Undo 1-24Redo and Undo Generation 1-25Recovery Concepts 1-26Crash and Media Recovery Differences 1-27Stuck Recovery 1-29NOLOGGING and Recovery 1-30Summary 1-31

2 Configuring RMANObjectives 2-2RMAN Configuration Decisions 2-3Issues to Consider 2-4Using RMAN Without a Recovery Catalog 2-5Steps to Create the Recovery Catalog 2-6Creating an RMAN User 2-7Creating the Repository 2-8Recovery Catalog Strategy 2-9RMAN Backup Strategy Guidelines 2-10Ways to Start RMAN 2-11Oracle Real Application Clusters 2-12Connecting to an Auxiliary Database 2-13RMAN and Pipes 2-14Registering a Database in a Recovery Catalog 2-15

Contents

iii

Oracle In

ternal & O

AI Use

Only

Page 4: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Catalog Maintenance Commands 2-16RESYNC CATALOG Command 2-17Control File Record Types 2-18Recovery Catalog Resync Types 2-19When to Run a RESYNC CATALOG 2-20Resync and Snapshot Control Files 2-21Persistent RMAN Configuration Parameters 2-23Retention Policies 2-24CONFIGURE RETENTION POLICY Command 2-25Automatic Channel Allocation 2-26The CONFIGURE CHANNEL Command 2-27CONFIGURE CONTROLFILE AUTOBACKUP 2-28CONFIGURE SNAPSHOT CONTROLFILE and CONFIGURE AUXNAME 2-29Other Configuration Commands 2-30Calling Configuration Sets 2-31CATALOG Command 2-32Catalog of Consistent and Inconsistent Copies 2-33Recovery Catalog Compatibility 2-34Determine the Schema Version of the Recovery Catalog 2-35Upgrading Recovery Catalog 2-36Dropping the Recovery Catalog 2-37Summary 2-38Practice Overview: Configuring RMAN 2-39

3 Backups with RMANObjectives 3-2RMAN Backups 3-3Running the BACKUP Command 3-4Backup Tags 3-6RMAN Managed Backups 3-7Parallelization of File Copies 3-8Backup Set 3-9Backup Set Example 3-10Archivelog Backup Sets 3-11Parallelization of Backup Sets 3-12Backup Pieces 3-13Backup Piece Contents 3-14Incremental Data File Backup 3-15Cumulative Incremental Backups 3-16SCN and Incremental Backups 3-17Basic Backup Algorithm 3-18Algorithm Rules 3-19Advanced Algorithm 3-21Algorithm Behavior for Standard Backup Sets 3-22Algorithm Behavior for Archivelog Backup Sets 3-24

iv

Oracle In

ternal & O

AI Use

Only

Page 5: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

v

Algorithm Behavior for File Copies 3-25Backup Optimization 3-26Backup Optimization Algorithm 3-27Duplexed Backups 3-29Mirrored Backups 3-32Proxy Copy 3-33Backup Set Backup 3-34Archived Log Backups 3-35Archivelog Backup Methods 3-36Long Term Backups 3-37Test Backups Using RMAN 3-38Restarting a Backup 3-40Default Autolocation for Oracle Real Application Clusters 3-41Summary 3-42Practice Overview: Backups With Recovery Manager 3-43

4 Restore and Recovery with RMANObjectives 4-2The RESTORE Command 4-3Steps in the RESTORE Process 4-4File Selection When Restoring 4-5Restore Optimization 4-6Restore Concepts 4-7Restoring Data Files and Tablespaces 4-8Restoring Archived Logs 4-9Restoring the Server Parameter File 4-10Parallelization of RESTORE 4-12Restoring the Database to a New Host 4-13Restoring the Database to a New Host 4-14Create Standby Database with DUPLICATE 4-16Validating Restore of Backups and Copies 4-17Restore Autolocation 4-19Restore When All Is Lost 4-20Recovery Types 4-22Recovery Concepts 4-23Basic RMAN Media Recovery 4-24RMAN Recovery Phases 4-25Parallelization of Recovery 4-27Incomplete Database Recovery 4-28Block Media Recovery 4-29Other BMR Benefits 4-30The BLOCKRECOVER Command 4-31RMAN BMR Interface 4-33Trial Recovery 4-34Tablespace Recovery Example 4-35Recover Database Example 4-36Recover a NOARCHIVELOG Database Example 4-38DBPITR Example 4-39BLOCKRECOVER Examples 4-40

Oracle In

ternal & O

AI Use

Only

Page 6: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Summary 4-42Practice Overview: Restore and Recovery with RMAN 4-43

5 RMAN MaintenanceObjectives 5-2Oracle9i Command Unification 5-3CROSSCHECK Command 5-4The LIST Command 5-5LIST Command Output 5-7The REPORT Command 5-8Report Objects Needing Backup 5-9Report Unrecoverable Backups and Copies 5-11Report Obsolete Backups and Copies 5-12Report Database Schema 5-14Show RMAN Configuration Settings 5-15The CHANGE…UNAVAILABLE and CHANGE…AVAILABLE Commands 5-16CHANGE…UNCATALOG Command 5-17Deleting Specified Backups and Copies 5-18Deleting Expired or Obsolete Backups 5-20Stored Script Information 5-21Maintenance Required When Not Using a Recovery Catalog 5-22Summary 5-23Practice Overview: RMAN Maintenance 5-24

6 Using RMAN with a Media ManagerObjectives 6-2Backups to Tape 6-3Media Manager 6-4Media Manager Prerequisites 6-5Linking a Media Manager on UNIX 6-6Linking a Media Manager on NT 6-8Testing the Media Manager Installation 6-9Perform a Test Backup to Tape 6-10Automatic Channels and Media Manager 6-11Default SBT Interface 6-13Events in a Media Manager Backup 6-14Events in a Media Manager Restore 6-16Media Manager Diagnostics 6-18Troubleshooting: Media Manager or RMAN 6-19Troubleshooting Media Manager 6-26SBTINIT and SBTINIT2 Function Errors 6-28SBTOPEN or SBTBACKUP Failures 6-30SBTOPEN or SBTRESTORE Failures 6-31SBTWRITE or SBTREAD Failures 6-32SBT API Return Codes 6-33

vi

Oracle In

ternal & O

AI Use

Only

Page 7: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Media Manager Vendor Differences 6-34Summary 6-35Practice Overview: Using RMAN with a Media Manager 6-36

7 Debugging RMANObjectives 7-2RMAN Message Output 7-3The DEBUG Option 7-4RMAN Code Layer Error Numbers 7-5Media Manager Error Numbers 7-6Interpreting RMAN Error Stacks 7-7Interpreting RMAN Errors 7-8Interpreting Server Errors 7-9The sbttest Utility 7-10Checking Backup and Restore Progress 7-11Monitoring the Media Manager 7-13Monitoring Recovery Manager Sessions 7-14Determining Which Data Files Require Recovery 7-16Insufficient Privileges 7-17UNIX Tape Backup Failure 7-19NT Tape Backup Failure 7-21RMAN Session Is Hung in Media Manager 7-22RPC Call Fails 7-24Snapshot Control File Creation Failure 7-25RMAN Cannot Locate an Archived Log 7-27Missing Log Causes Duplication Failure 7-29Summary 7-30Practice Overview: Debugging RMAN 7-31

8 RMAN Performance TuningObjectives 8-2Tuning RMAN 8-3RMAN Disk Buffer Allocation 8-4Disk Buffer Allocation Example 8-5Tape Buffer Allocation 8-6Synchronous Versus Asynchronous I/O 8-7Synchronous Versus Asynchronous I/O 8-8Setting LARGE_POOL_SIZE 8-9Performance Monitoring 8-10Asynchronous I/O Bottlenecks 8-11 Synchronous I/O Bottlenecks 8-12Tape Backup Speed 8-13Tape Subsystem Performance Rules 8-14Empty Files and Incremental Backups 8-15Control Tape Buffer Size with BLKSIZE 8-17

vii

Oracle In

ternal & O

AI Use

Only

Page 8: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Channel Tuning 8-18Tuning the BACKUP Command 8-19Summary 8-20

Appendix A

Appendix B

Appendix C

viii

Oracle In

ternal & O

AI Use

Only

Page 9: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Preface

Profile

Before You Begin This Course

Before you begin this course, you should have the following qualifications:

• Thorough knowledge of Oracle database administration and backup and recovery concepts.

• Working experience with Recovery Manager

Prerequisites

• Oracle9i Database Administration Fundamentals I and II or similar.

How This Course Is Organized

Oracle9i Release 2 Database: Supporting Recovery Manager is an instructor-led course featuring lecture and hands-on exercises. Online demonstrations and written practice sessions reinforce the concepts and skills introduced.

Copyright Oracle Corporation, 2002. All rights reserved.

Preface-1

Oracle In

ternal & O

AI Use

Only

Page 10: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Related Publications

Oracle Publications

Title Part Number

Oracle8i Online Generic Documentation CD-ROM A87860

Oracle9i Online Generic Documentation CD-ROM

Additional Publications

• System release bulletins

• Installation and user’s guides

• Selected WebIV Notes

• read.me files

• Oracle Magazine

Copyright Oracle Corporation, 2002. All rights reserved.

Preface-2

Oracle In

ternal & O

AI Use

Only

Page 11: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Typographic Conventions

Typographic Conventions in Text

Convention Element Example Bold italic Glossary term (if

there is a glossary)

The algorithm inserts the new key.

Caps and lowercase

Buttons, check boxes, triggers, windows

Click the Executable button. Select the Can’t Delete Card check box. Assign a When-Validate-Item trigger to the ORD block. Open the Master Schedule window.

Courier new, case sensitive (default is lowercase)

Code output, directory names, filenames, passwords, pathnames, URLs, user input, usernames

Code output: debug.set (‘I”, 300); Directory: bin (DOS), $FMHOME (UNIX) Filename: Locate the init.ora file. Password: User tiger as your password. Pathname: Open c:\my_docs\projects URL: Go to http://www.oracle.com User input: Enter 300 Username: Log on as scott

Initial cap Graphics labels (unless the term is a proper noun)

Customer address (but Oracle Payables)

Italic Emphasized words and phrases, titles of books and courses, variables

Do not save changes to the database. For further information, see Oracle7 Server SQL Language Reference Manual. Enter [email protected], where user_id is the name of the user.

Quotation marks

Interface elements with long names that have only initial caps; lesson and chapter titles in cross-references

Select “Include a reusable module component” and click Finish. This subject is covered in Unit II, Lesson 3, “Working with Objects.”

Uppercase SQL column names, commands, functions, schemas, table names

Use the SELECT command to view information stored in the LAST_NAME column of the EMP table.

Convention Element Example Arrow Menu paths Select File > Save.

Copyright Oracle Corporation, 2002. All rights reserved.

Preface-3

Oracle In

ternal & O

AI Use

Only

Page 12: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Brackets Key names

Press [Enter].

Commas Key sequences Press and release keys one at a time: [Alternate], [F], [D]

Plus signs Key combinations Press and hold these keys simultaneously: [Ctrl]+[Alt]+[Del]

Typographic Conventions in Code

Convention Element Example Caps and lowercase

Oracle Forms triggers

When-Validate-Item

Lowercase Column names, table names

SELECT last_name FROM s_emp;

Passwords DROP USER scott IDENTIFIED BY tiger;

PL/SQL objects OG_ACTIVATE_LAYER (OG_GET_LAYER (‘prod_pie_layer’))

Lowercase italic

Syntax variables CREATE ROLE role

Uppercase SQL commands and functions

SELECT userid FROM emp;

Typographic Conventions in Navigation Paths

This course uses simplified navigation paths, such as the following example, to direct you through Oracle Applications.

(N) Invoice > Entry > Invoice Batches Summary (M) Query > Find (B) Approve

This simplified path translates to the following:

1. (N) From the Navigator window, select Invoice > Entry > Invoice Batches Summary.

2. (M) From the menu, select Query > Find.

3. (B) Click the Approve button.

Notations :

(N) = Navigator

(M) = Menu

(T) = Tab

Copyright Oracle Corporation, 2002. All rights reserved.

Preface-4

Oracle In

ternal & O

AI Use

Only

Page 13: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

(I) = Icon

(H) = Hyperlink

(B) = Button

Typographical Conventions in Help System Paths

This course uses a “navigation path” convention to represent actions you perform to find pertinent information in the Oracle Applications Help System.

The following help navigation path, for example—

(Help) General Ledger > Journals > Enter Journals

—represents the following sequence of actions:

1. In the navigation frame of the help system window, expand the General Ledger entry.

2. Under the General Ledger entry, expand Journals.

3. Under Journals, select Enter Journals.

4. Review the Enter Journals topic that appears in the document frame of the help system window.

Getting Help

Oracle Applications provides you with a complete online help facility.

Whenever you need assistance, simply choose an item from the Help menu to pinpoint the type of information you want.

To display help for a current window:

1. Choose Window Help from the Help menu, click the Help button on the toolbar, or hold down the Control key and type 'h'.

A web browser window appears, containing search and navigation frames on the left, and a frame that displays help documents on the right.

The document frame provides information on the window containing the cursor. The navigation frame displays the top-level topics for your responsibility, arranged in a tree control.

2. If the document frame contains a list of topics associated with the window, click on a topic of interest to display more detailed information.

Copyright Oracle Corporation, 2002. All rights reserved.

Preface-5

Oracle In

ternal & O

AI Use

Only

Page 14: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

3. You can navigate to other topics of interest in the help system, or choose Close from your web browser's File menu to close help.

Searching for Help

You can perform a search to find the Oracle Applications help information you want. Simply enter your query in the text field located in the top-left frame of the browser window when viewing help, then click the adjacent Find button.

A list of titles, ranked by relevance and linked to the documents in question, is returned from your search in the right-hand document frame. Click on whichever title seems to best answer your needs to display the complete document in this frame. If the document doesn't fully answer your questions, use your browser's Back button to return to the list of titles and try another.

Copyright Oracle Corporation, 2002. All rights reserved.

Preface-6

Oracle In

ternal & O

AI Use

Only

Page 15: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Copyright © Oracle Corporation, 2002. All rights reserved.

Overview of Recovery Manager

Oracle In

ternal & O

AI Use

Only

Page 16: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-2

Copyright © Oracle Corporation, 2002. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:• Understand the fundamentals of the Recovery

Manager (RMAN) architecture and its components• Understand the features, components, and tasks

of RMAN• Understand the basic concepts of consistency

Oracle In

ternal & O

AI Use

Only

Page 17: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-3

Copyright © Oracle Corporation, 2002. All rights reserved.

Recovery Manager

• Recovery Manager (RMAN) is an Oracle utility that can back up, restore, and recover database files.

• It is a PRO*C application that translates command syntax into a series of PL/SQL calls.

• It has a command line interface.• It provides a powerful scripting language that can

be used in an interactive or batch mode.• It is operating system independent.

Recovery ManagerRMAN is a tool that manages the process of creating backups and the process of restoring and recovering 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.

Oracle In

ternal & O

AI Use

Only

Page 18: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-4

Copyright © Oracle Corporation, 2002. All rights reserved.

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 • Better performance during recovery• No generation of extra redo during open database

backups

RMAN FeaturesRMAN 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, copy them to the correct place using operating system commands, and choose which logs to apply, RMAN manages these tasks automatically.RMAN especially simplifies the backup and restore process when using Oracle Managed Files. When you use Oracle Managed Files, Oracle 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. By using RMAN, it 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 NOARCHIVELOGdatabase after a consistent shutdown. You can restore the database by using incremental backups, which means that you can restore a NOARCHIVELOG database.

Oracle In

ternal & O

AI Use

Only

Page 19: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-5

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Features

• Corrupt block detection• Handles fractured blocks• Automatic parallelization of backup, restore, and

recovery to improve performance• Backups can be restricted to limit reads per file or

per second to avoid interfering with OLTP work

RMAN Features (continued)RMAN computes checksums for each block during a backup and checks for corrupt blocks when backing up or restoring. Many of the integrity checks that are normally performed when executing SQL are also performed when backing up or restoring. RMAN also omits blocks that have never been used from data file backups so that only data blocks that have been written to are included in a backup. This is also known as null compression. When backing up online files, RMAN rereads fractured data blocks to get a consistent read. You do not need to place online tablespaces in backup mode when performing backups. In addition, RMAN can limit the number of open files to overcome O/S limits on concurrent files opened and limit the size of a backup piece. Users can limit reads per file per second so the backups effect on OLTP work can be minimized. Configuration of automatic parallelization of backup, restore, and recovery functions greatly improve performance and ease of use. This is important as a backup piece size can easily be over the maximum file size allowed by the operating system or media management software.

Oracle In

ternal & O

AI Use

Only

Page 20: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-6

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Architecture

Serversession(default)

Serversession(polling)Server

session(Catalog)

RecoveryCatalog

Enterprise Manager

Disk

Tertiary Storage

RecoveryManager

sys.dbms_rcvman

sys.dbms_backup_restore

media management layer

TargetControlfile

Media Manager

Fixedtables and

views

dbms_rcvcatdbms_rcvman

Catalogtables and

views

Target Instance

Serversession

(channel)

Serversession

(channel) Target Database

Files

RMAN ArchitectureThe 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 separate from the target. 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, which are installed when catproc.sql runs.

• One session for every allocated channel. Channels transfer the actual database data.• The control file is also stores schema, backup and recovery information. The control file

and the recovery catalog information are synchronized with RMAN.• The Media Management Library (MML) is software that connects to a particular vendor’s

tape backup system. This is linked into 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, it may reside anywhere. The MML software component ensures connectivity between RMAN and the tape subsystem. Using Oracle Enterprise Manager to control RMAN is optional.

Oracle In

ternal & O

AI Use

Only

Page 21: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-7

Copyright © Oracle Corporation, 2002. All rights reserved.

The RMAN Environment

A typical RMAN environment utilizes the following items:• RMAN executable• Target database• Recovery catalog database• Media management software

The RMAN EnvironmentThe RMAN environment consists of the utilities and databases that play a role in a backup and recovery strategy. Of the components listed above, only the RMAN executable and target database are required.RMAN automatically stores its metadata in the target database control file, so the recovery catalog database is optional. Nevertheless, maintaining a recovery catalog is strongly encouraged. If you create a catalog on a separate machine, and if the production machine fails completely, then you have all the restore and recovery information you need in the catalog.

Oracle In

ternal & O

AI Use

Only

Page 22: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-8

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Version Compatibility

• Four separate items must be compatible with one another:– The RMAN executable– The target database– The recovery catalog– The database containing the recovery catalog

• RMAN cannot be used in any way with an Oracle7 database.

RMAN Version CompatibilityThese four components listed above must be compatible. Please note that not all combinations are supported. The RMAN executable of a later Oracle database version may expect to use some feature in the target database that is not present in a lower version of the database. There are three general rules:

• The RMAN catalog schema version (meaning version of RMAN that created or updated the schema) should be equal or later than the catalog database version.

• The version RMAN catalog schema should be equal or later than the version of RMAN, that is, the RMAN catalog is backwards compatible to backup target databases. For example, a catalog created with RMAN from Oracle9i works with RMAN of Oracle8i or Oracle8.

• Use the same version of the RMAN executable as the target database.RMAN does allow you to create multiple catalog schemas in a single 9i recovery catalog to store all metadata of different releases like 8.1.5, 9.0.1, 9.0.2. Note: RMAN cannot be used in any way with an Oracle7 database.For more details, see Note 73431.1 RMAN Compatibility Matrix and Guide.Oracle

Internal &

OAI U

se O

nly

Page 23: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-9

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Components

The RMAN tool consists of the following components:• Recovery Manager executable (RMAN)

– RMAN library file: recover.bsq• Recovery Catalog

– Tables – Views

• RMAN Packages– DBMS_RCVMAN

– DBMS_RCVCAT

– DBMS_BACKUP_RESTORE

Recover Manager Executable (RMAN)The executable translates RMAN commands into a sequence of steps, which operate on 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 CatalogThe recovery catalog is a repository storing 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 file, archivelog backup sets and pieces, data file copies, archived redo logs, and stored scripts. If the recovery catalog is not used, RMAN queries the target database’s control file to decide what actions to perform.

RMAN PackagesThe DBMS_RCVMAN and DBMS_RCVCAT packages are used respectively by RMAN to query and update the recovery catalog. DBMS_BACKUP_RESTORE is the RPC interface to the code that physically performs the backup, restore, and recovery actions

The recover.bsq FileThe recover.bsq file is is also called the RMAN library file.Oracle

Internal &

OAI U

se O

nly

Page 24: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-10

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Components

• Target Database• Control file fixed tables and views• Channel (Server Sessions)• Media management interface module • Media Manager Server

Target DatabaseThe database on which the specified backup, restore, and recover actions will be executed.

Control File Fixed Tables and ViewsThe control file contains data used by RMAN to populate the recovery catalog.

ChannelFor each channel, RMAN creates an Oracle Server process on the target database to perform the backup, restore, or recovery.

Media Manager InterfaceThe media manager interface is an optional third-party media management interface module linked with Oracle Server

Media Manager ServerA non-Oracle product that communicates with the interface module to manage tertiary storage.

Oracle In

ternal & O

AI Use

Only

Page 25: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-11

Copyright © Oracle Corporation, 2002. All rights reserved.

Recovery Manager Utility Executable

The RMAN executable is responsible for:• Parsing Recovery Manager command syntax• Performing name translations relative to any time

specifications such as point-in-time recovery or user specified tags

• Generating PL/SQL programs which make remote procedure code (RPC) calls to the above packages

• Coordinating execution of PL/SQL calls on channels allocated

• Updating the recovery catalog

Recovery Manager ExecutableRMAN takes Recovery Manager command syntax, parses it for correctness, then translates these commands into one or more PL/SQL programs. Each PL/SQL program is a step, with each step having a status. For example, a backup command is broken down into steps, one per backup set. For example, if there are five sets to create, and there are five channels allocated, then each channel allocated will create a set.The RMAN executable is automatically included with the Oracle software installation. Its location is platform-specific and is typically located in the same place as the other Oracle executables. On UNIX systems, for example, the RMAN executable is located in $ORACLE_HOME/bin.To start the executable, simply enter the filename on the command line. For example, on a UNIX system, enter: $ rman

Oracle In

ternal & O

AI Use

Only

Page 26: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-12

Copyright © Oracle Corporation, 2002. All rights reserved.

Recovery Manager Executable:The recover.bsq File

• RMAN cannot function without the recover.bsqfile.

• The recover.bsq file contains a version number that must match that of the RMAN executable or the following error will result:

• The recover.bsq file location is port-specific– UNIX:

$ORACLE_HOME/rdbms/admin/recover.bsq– NT: %ORACLE_HOME%\rdbms\admin\recover.bsq

• The recover.bsq file is is also called the RMAN library file and each item it contains is called a library member.

OERR:RMAN 6035 wrong version of recover.bsq expecting %s, found %s

The recover.bsq FileThe recover.bsq file must exist in order for the RMAN executable to function correctly. This file contains the following information:

• PL/SQL code fragments• SQL statements• PL/SQL package specifications and bodies used for CREATE CATALOG• RMAN code fragments, used for recursive RMAN invocation during commands such as

DUPLICATE DATABASE and tablespace point-in-time recovery• External commands such as the export/import used by TSPITR

Many library members contain substitution variables (&args&) that are replaced with real values during compilation. Please see the example below:

define ‘kbytes’<<<sys.dbms_backup_restore.setLimit(sys.dbms_backup_restore.kbytes,&args&);>>>Oracle

Internal &

OAI U

se O

nly

Page 27: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-13

Copyright © Oracle Corporation, 2002. All rights reserved.

Recovery Catalog

• The Recovery Catalog consists of the following components:– Base tables and indexes– RC_* views– DBMS_RCVMAN package– DBMS_RCVCAT package

• All information in the recovery catalog originates in the target database control file.

Recovery CatalogThe 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 consist of several components, which include:

• Base tables and indexes: These tables and indexes should not need to be queried. • RC_* views: RC_* views can be queried. These views will be covered in more detail in a

later lesson.• 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 the views.

• DBMS_RCVCAT package: RMAN updates the recovery catalog tables via the procedures in this package. RMAN never updates the recovery catalog tables directly.

Oracle In

ternal & O

AI Use

Only

Page 28: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-14

Copyright © Oracle Corporation, 2002. All rights reserved.

Target Database:Controlfile Tables and Views

• Both the V$ views and X$ tables can be queried when the database is mounted but not open.

• All V$ control file fixed views are based on underlying X$ fixed tables.

• Use V$FIXED_VIEW_DEFINITION to see the underlying X$ tables used by the views.

Controlfile Table and ViewsThe control file data can be viewed from a collection of views. This data is the source of information used by RMAN to populate the recovery catalog. Below is a partial list of available tables and views:• 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

Oracle In

ternal & O

AI Use

Only

Page 29: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-15

Copyright © Oracle Corporation, 2002. All rights reserved.

Target Database:SYS.DBMS_RCVMAN

The SYS.DBMS_RCVMAN functions read data from thecontrol file fixed views.• This is an alternate implementation of the

DBMS_RCVMAN package.• The package specification is the same as the one

that is used to access the recovery catalog.• RMAN is insulated from having to know whether it

is accessing the control file or a recovery catalog.

Oracle In

ternal & O

AI Use

Only

Page 30: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-16

Copyright © Oracle Corporation, 2002. All rights reserved.

Target Database:DBMS_BACKUP_RESTORE

• It is a fixed package, linked into the kernel so that it can be called when the database is not open.

• It updates the target database’s control file with information as to what actions have been completed.

• The package specification is in dbmsbkrs.sql.

SYSDBMS_BACKUP_RESTORE

SYS.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 into the Oracle executable, DBMS_BACKUP_RESTORE is callable whenever an instance is started. The database does not need to be mounted or open.Note: Whenever Oracle documentation indicates to run a restore operation under circumstances such as with no recovery catalog or no control file, it indicates contacting support. What is meant by this is that support will indicate which DBMS_BACKUP_RESTORE calls to make to recover a control file and RMAN can automate the restore from that point.

Oracle In

ternal & O

AI Use

Only

Page 31: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-17

Copyright © Oracle Corporation, 2002. All rights reserved.

Target Database:DBMS_BACKUP_RESTORE

• Each DBMS_BACKUP_RESTORE call is:– Executed as an asynchronous RPC call to the target

database– Polled by RMAN, to identify the status of the call

• During job execution for each channel, RMAN initiates an RPC call, then polls to see if it has started.

• This information may be viewed by performing the following SELECT operation:

SQL> select module, action from v$session;

Oracle In

ternal & O

AI Use

Only

Page 32: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-18

Copyright © Oracle Corporation, 2002. All rights reserved.

Channels and Media Manager Server

• A channel represents one stream of data to a device type.

• For each channel, RMAN creates an Oracle Server process on the target database to perform the backup, restore, or recovery.

• The Media Manager Server communicates with the interface module to manage tertiary storage.

• Proxy copy is available through the media manager.

ChannelsAn RMAN channel represents one stream of data to a device type and corresponds to one server session. Allocation of one or more RMAN channels is necessary to execute most backup and recovery commands. Each channel establishes a connection from the RMAN executable to a target or auxiliary database instance by starting a server session on the instance. The server session performs the backup, restore, and recovery operations. Only one RMAN session communicates with the allocated server sessions. New with Oracle9i is automatic channel allocation which relieves the user from the step of explicitly allocating a channel in a backup/restore or maintenance session.Oracle has integrated proxy copy functionality into its media management API. Vendors can use this API to develop media management software that takes control of backup and restore operations. RMAN provides a list of files requiring backup or restore to the media manager, which in turn makes all decisions regarding how and when to move the data.

Oracle In

ternal & O

AI Use

Only

Page 33: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-19

Copyright © Oracle Corporation, 2002. All rights reserved.

Running RMAN Commands

• Type them into the RMAN command line interface– Individually:

– In a RUN block:

• Invoking an RMAN command file:

RMAN> run {2> allocate channel c1 type disk;3> copy datafile 10 to4> '/oracle/prod/backup/prod_10.dbf';5> }

RMAN> @copy_10.rcv

RMAN> backup database;

Running RMAN CommandsRMAN commands can be run by several methods. The commands can be typed in manually from an RMAN prompt as illustrated above. The commands can also be stored in an OS text file and invoked from the RMAN prompt. In the example, the file copy_10.rcv stores the RMAN commands..The commands can also be stored in the recovery catalog as a stored script. A stored script is only associated with one target database. Use the EXECUTE SCRIPT command to run an RMAN script that you have stored in the recovery catalog. After connecting to the recovery catalog and target database, issue a RUN command to execute the desired script. For example:RMAN> RUN { EXECUTE SCRIPT backup_full; }

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.

Oracle In

ternal & O

AI Use

Only

Page 34: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-20

Copyright © Oracle Corporation, 2002. All rights reserved.

Simple Backup and Recovery Concepts

• Crash recovery versus media recovery• Cold (offline) versus hot (online) backups• Restore and recovery• Read-only tablespaces• Offline tablespaces

Backup and Recovery ConceptsA crashed database is a database that was not shut down in an orderly fashion. Crash recovery occurs automatically when the database is reopened after an abrupt termination such as power failure or SHUTDOWN ABORT. Only the online redo log files will be used. Deferred rollback of any uncommitted transaction takes place after the database is open. Deferred rollback means that the rollback that used to take place before the database was open now takes place after and may even be done in parallel.Media recovery occurs when the RECOVER command is used. It can use archive log files and the online redo log files. The server will ask for media recovery if the data file header and control file information do not match, or if the data file headers have indicators set that the file was not closed normally. Deferred rollback of any uncommitted transaction occurs when the database is opened.A cold or offline backup is taken when the database is closed. With manual cold backups the instance can be shutdown, with RMAN offline backups the instance must be in MOUNT mode. Although you can use a backup taken of a crashed database in a recovery scenario, it is not recommended.Oracle

Internal &

OAI U

se O

nly

Page 35: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-21

Backup and Recovery Concepts (continued)A hot or online backup is taken when the database is open. ARCHIVELOG mode is a prerequisite. For manual hot backups, the involved tablespaces must be placed in backup mode. With RMAN online backups, a the re-reading of fractured blocks ensures block consistency. Thus you do not place tablespaces into any special mode for backup.There are usually two steps to a perform a media recovery: The optional first step is restore, which is a simple copying of files from the backup system to the database locations. (RMAN may need to assemble the file from several incremental RMAN backups.) The second step is the recover step, when the server applies the archive and online redo logs. Normally when people refer to recovery, they are referring to the restore phase.Read-Only TablespacesThe intention is to avoid taking repeated backups of data that does not change, and not to protect table row data against alteration. Even if you do not change any data, the data files are written to during every database open, close, and checkpoint, if the database is in normal mode. The data files of a tablespace set into read-only mode will not be written to, and are allowed to be “out of date” compared to the other data files. You do not perform media recovery on a read-only tablespace’s data files, you only restore them. Read-only tablespaces data files can be moved to a CD-ROM or WORM (Write Once, Read Many). Note: Tables in a read-only tablespace can be dropped.but keep in mind the table data is not dropped, just the table definition.Offline TablespacesThere may be reasons for only having a partial set of the database available. Offlining a tablespace causes the server to close the data files, thus freeing them for some operation (for example, moving to shelf storage). At some later time, the data files are returned to their original location and can be made online again. If the tablespace is offlined IMMEDIATE, which requires ARCHIVELOG mode, then it will require media recovery as the related files were not closed normally (the data in the buffer cache was not flushed). This occurs regardless of whether or not data was in the cache. Note that if you offline files, as opposed to offline tablespaces, you do not get a choice. The process is “immediate,” thus requiring recovery when placing the tablespace online again.

Oracle In

ternal & O

AI Use

Only

Page 36: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-22

Copyright © Oracle Corporation, 2002. All rights reserved.

Database Inconsistency

• Constraint inconsistency• Logical inconsistency• Structural inconsistency• Physical inconsistency

– At the block level– At the inter-block level

When Is the Database Inconsistent?The term “inconsistent” is often used, but can have several levels of meaning. If the data schema presumes a constraint such as a foreign key constraint, any data in the database that violates that would be a constraint inconsistency. This might happen when no constraints are used, only implied. This is called a logical inconsistency. It might happen if an older version of a table (that participates in a relation with other tables) is imported. If the database does not contain the files the dictionary says it should, then there is a gross structural inconsistency. Normally the database will refuse to start until the fault is remedied.Inside each block there are many structures, apart from the row data of a table. There are number of pointers between these structures. If these pointers are incorrect, this can be described as physical inconsistency. Some pointers refer to another block. If they point to the wrong block, or if the other block does not have the content it should have, then there is physical inconsistency between blocks.

Oracle In

ternal & O

AI Use

Only

Page 37: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-23

When Is the Database Inconsistent? (continued)Many of the algorithms implemented for processing capabilities mean that at any stage during normal database operation, different portions of the database (and the memory structures used to access it) are inconsistent with regard to one another.Consider that the database is the physical files in which you store data, and the instance is the memory structures. You know that database blocks are read from the disk into memory buffers and are then modified while resident in these buffers. Many changes can occur before the blocks are written back into the data files by the LRU algorithm. These blocks are therefore from a later state in time than blocks on disk, and perhaps than other blocks in memory. The database is therefore inconsistent, and anything other than a controlled (graceful) shutdown will leave the database inconsistent.Another way of defining physical inconsistency is the following: if not all the blocks in a data file or database are from the same point in time (that is, assuming all blocks have been flushed from the cache), then the data file or database, respectively, is physically inconsistent.

Oracle In

ternal & O

AI Use

Only

Page 38: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-24

Copyright © Oracle Corporation, 2002. All rights reserved.

Comparing Redo and Undo

• The redo after image is used to repeat a data modification, when the result has been lost.

• The undo (or rollback) before image is used to get the original data back after a change has overwritten it.

• Redo and undo are handled and stored separately in the Oracle server architecture, but they are created simultaneously by any data change.

Redo and UndoIt is imperative for understanding the recovery architecture to distinguish between undo and redo. In the Oracle server, the primary use of undo is to ensure isolation, and the primary use of redo is to ensure durability.Only undo is directly associated to a transaction, while redo is implicitly associated to a transaction. Some redo is not part of the transaction with which it appears to be associated, for example delayed block cleanout changes. Undo can be discarded after the transaction commits; redo can be discarded after the buffer cache is flushed or checkpointed.Redo is stored in separate files in Oracle, the online redo log files, while undo is stored inside normal data files in the special undo tablespace or the special (rollback) segments.The words “rollback” and “undo” are synonyms. For more information on the generation, use, and analysis of undo data, see the courses DSI402e: Data Types and Block Structures andDSI402: Space and Transaction Management. Redo is the heart of the recovery system and is covered in more detail in the course DSI403: Backup and Recovery Processes.Oracle

Internal &

OAI U

se O

nly

Page 39: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-25

Copyright © Oracle Corporation, 2002. All rights reserved.

Redo and Undo Generation

• Redo is generated whenever any data file changes:– Table data, LOBs, and associated indexes,

including the data dictionary– Undo data– Internal data block structures, pointers, or data file

headers– Control file changes– Can be partially suppressed (NOLOGGING)

• Undo is generated whenever user or data dictionary data changes:– Table data and associated indexes– LOBs do not generate undo

Redo GenerationRedo 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).As 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 GenerationUndo 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.

Oracle In

ternal & O

AI Use

Only

Page 40: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-26

Copyright © Oracle Corporation, 2002. All rights reserved.

Recovery Concepts

• Recovery for a thread starts at the last checkpoint.• Recovery progresses, redo record by redo record,

until all available redo has been applied.– Find the block– Block time > Redo record time: Skip block– Block time = Redo record time: Apply changes– Block time < Redo record time: Stuck recovery

• No generation of redo

Recovery ConceptsFor all redo vectors:

• The block (DBA) specified in the vector is read into the cache.• If the block has the same time as the redo record (SCN and SEQ fields match), 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 normal 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 allows for recovery being reapplied repeatedly, or restarted after a crash while applying redo. Only if the redo and block match in time will the redo be applied. Note that the word “time” refers to the logical time line as given by the SCN and SEQ 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.Oracle

Internal &

OAI U

se O

nly

Page 41: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-27

Copyright © Oracle Corporation, 2002. All rights reserved.

Crash and Media Recovery Differences

Crash recovery:• Two pass reading

– Scan BWR records in redo stream– Reread redo stream and apply only required redo

• Database consistent and completeMedia recovery:• Recovery checkpoints• Incomplete or complete, but consistent

Differences Between Crash and Media RecoveryCrash recovery is automatic and uses the online redo logs that are CURRENT or ACTIVE. Media recovery is manual. Media recovery can be performed even without ARCHIVELOG mode provided there is enough information in the online redo logs. Crash recovery can only occur on one thread. For media recovery the redo records of all threads are taken in SCN/SEQ order as the data file(s) may have been modified by several instances.Two Pass Recovery in Crash RecoveryThe ordinary cache aging and the incremental checkpoint system have probably written a number of blocks to disk, without the file headers being updated. When the DBWn completes a data block write operation, it also adds a redo record that states that the block has been written. This is called a Block Written Record (BWR). During crash recovery, the online redo log is read twice.The first read of the redo builds a list of blocks that are mentioned in the redo. Some of the redo records are the BWR entries which signify that the block mentioned is up to date until that point in the redo. The block is removed from the list. The resultant list of this first pass is a list of blocks which have redo that were not written to disk.Oracle

Internal &

OAI U

se O

nly

Page 42: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-28

Differences Between Crash and Media Recovery (continued)Two Pass Recovery in Crash Recovery (continued)The second read of the redo now only processes block from this list, which should be much smaller than all the blocks touched in the redo stream. Many fewer data blocks are read and written, thus offsetting the cost of reading the online redo log files twice.If the system is unable to perform two pass recovery, then it will fall back to the single pass. The alert file states the result from two pass recovery. You can suppress two pass crash recovery with _TWO_PASS=FALSE.Media RecoveryDuring media recovery, the blocks are in the buffer cache waiting to be written out to the data file(s). The blocks are recovery checkpointed at log switches. Recovery checkpoints are noted in the control file, so that the server does not need to reprocess the same redo data in case recovery is restarted. The recovery checkpoints also update the data file headers.Media recovery can be complete or incomplete. An incomplete recovery will require the use of RESETLOGS. Before Oracle9i, if a media recovery got stuck or crashed, then the database was possibly left in a physically inconsistent state. To open the database, data files had to be restored and then an incomplete recovery done. Since Oracle9i the data block writing during recovery is modified, such that at an aborted recovery, the database is in a consistent state.

Oracle In

ternal & O

AI Use

Only

Page 43: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-29

Copyright © Oracle Corporation, 2002. All rights reserved.

Stuck Recovery

• A block is older than the redo you are trying to apply.– Recovery was not started early enough

in the redo stream.– Some redo is lost.– There is block corruption in data or redo.

• Possible recovery from stuck recovery:– Retry recovery with older data and archive log files.– Corrupt the block.

Stuck RecoveryStuck 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.The hidden parameter _CORRUPT_BLOCKS_ON_STUCK_RECOVERY was needed to accomplish this Before Oracle9i,

Test RecoveryOracle9i 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 the recovery will stop. After correcting the error, recovery is attempted again, only to fail 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.Oracle

Internal &

OAI U

se O

nly

Page 44: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-30

Copyright © Oracle Corporation, 2002. All rights reserved.

NOLOGGING and Recovery

• Data manipulated in NOLOGGING mode cannot be crash or media recovered.

• Blocks that do not have complete redo are marked invalid on recovery.

• Temporary tables, sort segments are always “NOLOGGING”.

NOLOGGING and RecoveryData manipulated in NOLOGGING mode cannot be crash or media recovered. When a bulk data operation is performed on an object marked NOLOGGING, the range of blocks affected will be noted as invalidated in the redo record. On recovery the data blocks will be marked as soft corrupt in the data file. This avoids issues with old blocks in the data file, perhaps being reused as segments are dropped and the space allocated to other objects seeing “old data,” or determine which blocks lack redo due to repeatedly switching between LOGGING and NOLOGGING.When a user attempts to retrieve data from such a table or index they receive:ORA-26040: Data block was loaded using the NOLOGGING option

Versions before Oracle8i may report:ORA-1578: ORACLE data block corrupted (file nn, block nn)

Blocks belonging to sort segments, temporary tables and any block in a temporary tablespace will not generate any redo. As these blocks contain data that only has a lifetime of a statement or session, then the data is not needed if there is a crash which either aborts the statement or the session.Oracle

Internal &

OAI U

se O

nly

Page 45: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 1-31

Copyright © Oracle Corporation, 2002. All rights reserved.

Summary

In this lesson, you should have learned how to:• Understand the fundamentals of the RMAN

architecture and its components• Understand basic backup structures• Identify the features, components, and tasks of

RMAN

Oracle In

ternal & O

AI Use

Only

Page 46: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 47: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Copyright © Oracle Corporation, 2002. All rights reserved.

Configuring RMAN

Oracle In

ternal & O

AI Use

Only

Page 48: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-2

Copyright © Oracle Corporation, 2002. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:• Understand RMAN configuration decisions • Outline the steps taken in creating a recovery

catalog• Create/grant privileges to a 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

• Upgrade and drop a recovery catalog

Oracle In

ternal & O

AI Use

Only

Page 49: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-3

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Configuration Decisions

Decisions to be made prior to configuring RMAN: • Whether to use a recovery catalog• Whether Oracle password files will be used• How and when to backup O/S files• The name for the snapshot control file

RMAN Configuration DecisionsAlthough RMAN can conduct all major backup and recovery operations using just the control file, note these advantages of using the catalog:

• Some RMAN commands and operations function only with a catalog.• The recovery catalog retains historical backup information that can get overwritten in the

control file.• The recovery catalog stores information about backups from different incarnations of the

database.RMAN automatically propagates information about the database structure, archived redo logs, backup sets, and data file copies into the recovery catalog from the target database's control file. When you use a recovery catalog, RMAN requires that you maintain a recovery catalog schema. The recovery catalog is stored in the default tablespace of the schema. Note that SYS cannot be the owner of the recovery catalog.Decide which database you will use to install the recovery catalog schema, and also how you will back up this database. You should not install the catalog in the target database: this tactic defeats the purpose of the catalog. Also, decide whether to operate the catalog database in ARCHIVELOG mode, which is recommended.Oracle

Internal &

OAI U

se O

nly

Page 50: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-4

Copyright © Oracle Corporation, 2002. All rights reserved.

Issues to Consider

Some issues to ponder when deciding whether or not to use a Recovery Catalog:• If the control file is lost and a need to restore and

recover the database (Oracle8i) arises, the customer will require the assistance of Oracle Worldwide Customer Support Services

• Point-in-time recovery (PITR) can be difficult or impossible

• The overhead of a recovery catalog

Issues to Consider RMAN can be configured to use a recovery catalog in addition to the target database’s control file. Some implications of not using a recovery catalog include:

• Losing a control file with a need to restore and recover. If the database is pre Oracle9i, Support can only help if the user maintains excellent records (that is, RMAN message log files) of which files were backed up, the date 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.

Oracle In

ternal & O

AI Use

Only

Page 51: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-5

Copyright © Oracle Corporation, 2002. All rights reserved.

Using RMAN Without a Recovery Catalog

If you choose to operate without a recovery catalog, the following commands will not be available:

CREATE, UPGRADE, or DROP CATALOGCREATE SCRIPT, DELETE SCRIPT, REPLACE SCRIPT, PRINT SCRIPTLIST INCARNATION REGISTER DATABASEREPORT SCHEMA AT TIMERESET DATABASERESYNC CATALOG

Using RMAN Without a Recovery CatalogIf you choose not to use a recovery catalog, then you can still use RMAN effectively. Remember, RMAN obtains the information it needs from the control file of the target database. Nevertheless, some commands are not available when you use the control file as the sole repository of RMAN metadata.With the advent of Oracle9i, the importance of the recovery catalog is diminished. The needed functionality is provided with the control file store except when dealing with environments containing many databases.Note: LIST INCARNATION is supported in Oracle9i Release 2 databases running in nocatalog mode.

Oracle In

ternal & O

AI Use

Only

Page 52: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-6

Copyright © Oracle Corporation, 2002. All rights reserved.

Steps to Create the Recovery Catalog

1. Decide in which database to create the catalog.2. Decide the frequency of backup and resync.3. Create a RMAN tablespace.4. Create and grant privileges to a RMAN user.5. Connect as the RMAN user.6. Create the repository with the CREATE CATALOG

command.

Oracle In

ternal & O

AI Use

Only

Page 53: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-7

Copyright © Oracle Corporation, 2002. All rights reserved.

Creating an RMAN User

• Create RMAN user.

• Grant a role to maintain and query the recovery catalog to the RMAN user.

• Grant other roles as needed.

SQL> create user RMAN identified by RMAN2> temporary tablespace TEMP3> default tablespace RCVCAT4> quota unlimited on RCVCAT;

Create the RMAN User and SchemaAt this point, you are ready to create the RMAN user and schema. In this example, the user RMAN is created and the default tablespace that will store the user’s schema is assigned. Next, grant the RECOVERY_CATALOG_OWNER role to the schema owner. This role provides the user with privileges to maintain and query the recovery catalog.SQL> GRANT RECOVERY_CATALOG_OWNER TO rman;

Grant other desired privileges to the RMAN user as needed.SQL> connect / as sysdba

SQL> grant dba, connect, resource, sysdba TO rman;

Oracle In

ternal & O

AI Use

Only

Page 54: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-8

Copyright © Oracle Corporation, 2002. All rights reserved.

Creating the Repository

Connect as RMAN user and create the recovery catalog repository by issuing the create catalogcommand:$ rman catalog RMAN/RMANRecovery Manager: Release 9.2.0.0.0 - Beta(c) Copyright 2001 Oracle Corporation. connected to recovery catalog databaseRMAN> create catalog

Creating the RepositoryThe recovery catalog is created by issuing the RMAN command and connecting to the RMAN database (if you chose to create a separate database for the recovery catalog) as user RMAN and issuing the CREATE CATALOG command.$ rman catalog rman/rmanRecovery Manager: Release 9.2.0.0.0(c) Copyright 2001 Oracle Corporation. All rights reserved.connected to recovery catalog databaserecovery catalog is not installedRMAN>RMAN> create catalogrecovery catalog created

Oracle In

ternal & O

AI Use

Only

Page 55: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-9

Copyright © Oracle Corporation, 2002. All rights reserved.

Recovery Catalog Strategy

When using a recovery catalog, the following decisions on backup and resyncs must be made: • How the recovery catalog will be backed up • How often the recovery catlog will be backed up• How often to resync the recovery catalog• How to automate catalog resyncs

Recovery Catalog StrategyInclude the recovery catalog in your backup and recovery strategy. If you do not back up the recovery catalog and a disk failure occurs that destroys the recovery catalog database, then you may lose the metadata in the catalog. Avoid this unpleasant scenario by deciding how to back up and recover the recovery catalog.Back up the recovery catalog with the same frequency that the target database is backed up. If you make a weekly whole database backup of the target database, then back up the recovery catalog immediately after all target database backups. The backed up catalog contains a record of the target backup preceding it, so if you need to restore the catalog you can use it to restore a target backup.When the RMAN resync catalog command is issued, the tables in the catalog database will be updated with any new information stored in the control file such as the new backup sets created or new stored scripts.

Oracle In

ternal & O

AI Use

Only

Page 56: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-10

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Backup Strategy Guidelines

• Run the recovery catalog database in ARCHIVELOGmode.

• Back up the database onto two separate media such as disk and tape.

• Back up the database and archived logs at regular intervals.

• Do not use another recovery catalog as the repository for the backups.

• Configure the backup so that the control file is automatically backed up too.

RMAN Backup StrategiesWhen backing up the recovery catalog database, you can use RMAN to make the backups. RMAN should be started in this circumstance with the NOCATALOG option so that the repository for the recovery catalog is the control file in the catalog database. With this strategy, the control file autobackup feature ensures that the recovery catalog database can always be recovered.

Oracle In

ternal & O

AI Use

Only

Page 57: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-11

Copyright © Oracle Corporation, 2002. All rights reserved.

Ways to Start RMAN

• No recovery catalog and no username/password.

• No recovery catalog, HR has SYSDBA privileges.

• Using a recovery catalog.

$ ORACLE_SID=U01;export ORACLE_SID$ rman nocatalogRMAN> connect target

$ rman target hr/hr nocatalog

$ rman rcvcat rman/rman@rcatRMAN> connect target

Starting RMANThere are many ways that a user can start RMAN depending on how RMAN was configured and of course the user’s current needs. In addition to the methods demonstrated above, RMAN can additionally be started in the following ways:

• By connecting to a target instance (either locally or remotely) when using a password file and specifying a TNS alias in the target connect string while 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 TNS alias in the target connect string, no recovery catalog:$ rman target scott/tiger@prod nocatalog

Oracle In

ternal & O

AI Use

Only

Page 58: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-12

Copyright © Oracle Corporation, 2002. All rights reserved.

Oracle Real Application Clusters

• RMAN can connect to only one Real Application Clusters instance at a time.

• Net service names that distribute connections to more than one database cannot be used with RMAN.

• Automatic channels can be configured for each Oracle Real Application Clusters instance.– This method allows the entire database to be

backed up with one command.

Connecting to Oracle Real Application Cluster DatabasesRMAN can connect initially to only one instance at a time in an Oracle Real Application Clusters configuration. Assume that RAC1, RAC2, and RAC3 are net service names for three instances in an Oracle Real Application Clusters configuration. You can connect to the target database using only one of these net service names. For example, you can connect as follows:$ rman TARGET SYS/oracle@RAC2 CATALOG rman/rman@catdb

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.

Oracle In

ternal & O

AI Use

Only

Page 59: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-13

Copyright © Oracle Corporation, 2002. All rights reserved.

Connecting to an Auxiliary Database

• Connect to an auxiliary instance from the operating system command line:

• Connect to the target database, auxiliary database and recovery catalog database at the same time:

$ rman AUXILIARY SYS/aux_passwd@auxiliarydb

$ rman TARGET SYS/oracle@trgt \

CATALOG rman/cat@catdb AUXILIARY SYS/aux@auxdb

Connecting to an Auxiliary DatabaseTo use the DUPLICATE command or to perform tablespace point-in-time recovery with RMAN, you need to connect to an auxiliary instance. If the auxiliary database uses password files for authentication, then you can connect using a password for either local or remote access. If you are connecting remotely through a net service name, then authentication through a password file is mandatory. The examples above demonstrate the command syntax necessary to connect to an auxiliary database and simultaneously a target, catalog, and auxiliary database respectively. Alternatively, you can start RMAN and connect to the databases individually from the RMAN prompt:$ rmanRMAN> CONNECT TARGET SYS/oracle@trgtRMAN> CONNECT CATALOG rman/cat@catdbRMAN> CONNECT AUXILIARY SYS/aux@auxdb

Oracle In

ternal & O

AI Use

Only

Page 60: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-14

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN and Pipes

• RMAN can use pipes to connect and execute RMAN commands.

• By interfacing with the DBMS_PIPE package, RMAN can avoid using an operating system shell.

• The use of public pipes with RMAN is not permitted for security reasons.

• To use RMAN in pipe mode, connect to the target database and specify the PIPE option.

$ rman PIPE pipe_name TARGET SYS/oracle@trgt

Using Pipes with RMANThe RMAN pipe interface is an alternative method for issuing commands to RMAN and receiving the output. By using a pipe, RMAN can interface with the DBMS_PIPE PL/SQL package and avoid using an operating system command shell altogether.RMAN does not permit the pipe interface to be used with public pipes as they are a potential security problem. With a public pipe, any user who knows the name of the pipe can send commands to RMAN and intercept its output. If the pipes are not already initialized, then RMAN creates them as private pipes. If you want to put commands on the input pipe before starting RMAN, be careful to first create the pipe by calling DBMS_PIPE.CREATE_PIPE. Whenever a pipe is not explicitly created as a private pipe, the first access to the pipe automatically creates it as a public pipe, and RMAN returns an error if it is told to use a public pipe.If multiple RMAN sessions can run against the target database, then use unique pipe names for each session of RMAN. The DBMS_PIPE.UNIQUE_SESSION_NAME function is one method that can be used to generate unique pipe names.

Oracle In

ternal & O

AI Use

Only

Page 61: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-15

Copyright © Oracle Corporation, 2002. All rights reserved.

Registering a Database in a Recovery Catalog

• When using a recovery catalog you must register the database with the recovery catalog before using RMAN to perform backups.

• The target database you connect to will be the database registered in the catalog.

• The register command identifies the database to the recovery catalog.

• Information about the target database’s structure is propagated from the target database’s control file.

RMAN> register database;

Registering a Database in a Recovery CatalogThe enrolling of a database in a recovery catalog is called registration. You can register more than one target database in the same recovery catalog. You can register a database only once in a given catalog schema. Because RMAN distinguishes databases by unique database identifier (DBID), each database registered in a given catalog must have a DBID. You cannot register two databases with the same DBID in the same catalog. However, each database does not have to have a unique database name. If you use operating system commands to copy a database, then the copied database has the same DBID as the original database. Thus, you cannot copy a database manually and then register it in the same catalog with its parent unless you change the DBID of the copied database. For this reason, it is easiest to use the DUPLICATE command to create a copied database because RMAN automatically gives the copied database a different DBID. You can also use the DBNEWID utility to change the DBID (or the database name) of any Oracle database. DBNEWID is useful when you have already created multiple databases with the same DBID and you now want to register them all in the same recovery catalog.

Oracle In

ternal & O

AI Use

Only

Page 62: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-16

Copyright © Oracle Corporation, 2002. All rights reserved.

Catalog Maintenance Commands

• The RESYNC CATALOG command synchronizes the recovery catalog with the target database’s control file.

• The CONFIGURE command allows the user to adjust persistent configuration parameters in Oracle9i.

• The CATALOG command allows user-managed backups to be managed by RMAN.

Catalog Maintenance CommandsThere are a number of RMAN commands provided that allow maintenance of information in the recovery catalog. The RESYNC command compares the catalog and target control file and bringsthem back to a state of “agreement.” The CONFIGURE command is a new feature of Oracle9iand allows the user to create and manage a set of configuration parameters that greatly enhance the useability of RMAN. The CATALOG command allows user-managed data file and archived log file backups to be cataloged in the RMAN repository.

Oracle In

ternal & O

AI Use

Only

Page 63: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-17

Copyright © Oracle Corporation, 2002. All rights reserved.

RESYNC CATALOG Command

• The RESYNC CATALOG command causes RMAN to compare the recovery catalog to the target database’s control file.

• RMAN copies data from the V$ views in the target database control file to the recovery catalog.

• Resyncs are initiated in two ways:– Manual resyncs happen when requested by the

user, with the resync catalog command.– Automatic resyncs happen when needed, at the

start and/or end of an RMAN command.

RMAN> resync catalog;

RESYNC CATALOG CommandThe RESYNC CATALOG catalog command causes RMAN to compare the recovery catalog to either the current control file of the target database, or a control file copy, if the keyword from control file copy is specified. RMAN automatically detects what information has been updated in the control file, and updates the recovery catalog with information that is missing or changed. If the target database is open, it also registers information about which tablespaces contain rollback segments. This is used for tablespace point-in-time-recovery (TSPITR), to ensure all tablespaces with rollback segments in them are restored for the TSPITR to be successful. Because the control file employs a circular reuse system, backup and copy records eventually get overwritten. Resynchronizing the catalog ensures that these records are stored in the catalog and so are not lost.Following is a list of records that are resynced:

• Log history archivelog copy (archivelog copy, or archivelog backupset restore)• Backup history (backup or copy performed not already in the catalog)• Physical schema (MUST have current control file mounted)

If syncing from control file copy, resync does not validate that backup pieces, file copies, and archive logs exist.Oracle

Internal &

OAI U

se O

nly

Page 64: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-18

Copyright © Oracle Corporation, 2002. All rights reserved.

Control File Record Types

Two types of control file records exist:• Circular reuse

– Resync is possible without a read-consistent image of the control file.

• Non-circular reuse– Resync requires a read-consistent image of the

control file, thus a need for snapshot.

Circular ReuseThis record type is suited for information that is continuously generated by the server and can be overwritten if need be, because it is not critical for production operation. Records are arranged in a logical ring. When all available slots are full, the control file is either expanded to make room for the new record or the oldest record is overwritten. The parameter that determines which of these two options will be used is CONTROLFILE_RECORD_KEEP_TIME. Examples include log history, archived log, backup record, offline ranges.

Noncircular ReuseFor information that is not changed often and because be overwritten, because it is critical for production operation. Examples include data files, redo threads, online redo logs.

Oracle In

ternal & O

AI Use

Only

Page 65: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-19

Copyright © Oracle Corporation, 2002. All rights reserved.

Recovery Catalog Resync Types

There are two types of recovery catalog resync:• Partial resync

– Used when only circular reuse records need to be resynced

• Full resync– Used when some noncircular reuse records need to

be resynced– The RESYNC CATALOG command always does a full

resync

Partial ResyncPartial resyncs are used when only circular reuse records need to be resynced and as such does not require a read-consistent image of the control file. Partial resyncs are only done during an RMAN automatic resync, and when RMAN detects that a full resync is not needed.

Full ResyncBecause full resyncs are used when some noncircular reuse records need to be resynced, a read-consistent image of the control file is needed. A full resync reads from the snapshot control file, not from the current control file. Whenever the RESYNC CATALOG command is issued, a full resync is always performed. An RMAN automatic resync will only be a full resync when a noncircular reuse record has changed to avoid creating the snapshot control file if not necessary.RMAN automatically detects when it needs to perform a full or partial resynchronization and executes the operation as needed. You can also force a full resynchronization by issuing a RESYNC CATALOG command.

Oracle In

ternal & O

AI Use

Only

Page 66: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-20

Copyright © Oracle Corporation, 2002. All rights reserved.

When to Run a RESYNC CATALOG

The RESYNC CATALOG command should be performed:• Each time the physical database structure

changes• When data files are added or resized• When a tablespace is dropped• When rollback segments are created or dropped• At least once per each ten archived logs

When to Run the RESYNC CATALOG CommandThe recovery catalog should be resynced regularly, because it is not automatically updated when a redo log is archived; instead this information is cached in the control file, and should be periodically propagated to the recovery catalog. To ensure that the catalog stays current, run the RESYNC CATALOG command periodically. A good rule of thumb is to run it at least once per each 10 archived logs. The cost of this operation is related to the number of new or changed records in the control file since the previous resync. So, the more often you resync, the quicker the operation will complete.

Oracle In

ternal & O

AI Use

Only

Page 67: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-21

Copyright © Oracle Corporation, 2002. All rights reserved.

Resync and Snapshot Control Files

• When RMAN needs to resynchronize from a read-consistent 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.

• Created the same way as ALTER DATABASE BACKUP CONTROLFILE.

Resync and Snapshot Control FilesRMAN generates a snapshot control file, which is a temporary backup control file, each time it performs a full resynchronization. This snapshot control file ensures that RMAN has a consistent view of the control file. Because the snapshot control file is intended for RMAN's short-term use, it is not registered in the recovery catalog. RMAN records the snapshot control file checkpoint in the recovery catalog to indicate the currency of the recovery catalog.The Oracle9i server ensures that only one RMAN session accesses a snapshot control file at any point in time. This safeguard is necessary to ensure that two RMAN sessions do not interfere with each other’s use of the snapshot control file.The default value for the snapshot control file is platform specific. The default filename on some UNIX platforms in Oracle9i is $ORACLE_HOME/dbs/[email protected] the CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'filename' command to change the name or location of the snapshot control file to a nondefault value. Subsequent snapshot control files that RMAN creates use the specified filename.

Oracle In

ternal & O

AI Use

Only

Page 68: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-22

Resync and Snapshot Control Files (continued)The snapshot control file can be written to a raw device. An Oracle Real Application Clusters configuration does not require the snapshot control file to be shared across all instances, but the snapshot control file name must be set to a location where any instance can create one. Each instance is permitted to create the snapshot control file in its own file system as it needs one. The following example sets the snapshot control file name to a raw device:

RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/dev/vgd_1_0/rlvt5';

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.

Oracle In

ternal & O

AI Use

Only

Page 69: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-23

Copyright © Oracle Corporation, 2002. All rights reserved.

Persistent RMAN Configuration Parameters

• Customizable configuration parameters simplify formerly complicated RMAN operations.

• Default settings are set once and reused for subsequent jobs.

• The default parameters can be overridden with the new Oracle9i CONFIGURE command.

• The configuration values are stored in the control file and written to the recovery catalog when resynced.

Persistent RMAN Configuration ParametersIt is possible to create a persistent backup configuration. Once these parameters are configured RMAN will continue to reuse the configured options for subsequent backups unless you override the option within your script or disable it. With 9i RMAN you use the show command to see the currently configured options. RMAN> show all;RMAN configuration parameters are:CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # defaultCONFIGURE BACKUP OPTIMIZATION OFF; # defaultCONFIGURE DEFAULT DEVICE TYPE TO DISK; # defaultCONFIGURE CONTROLFILE AUTOBACKUP OFF; # defaultCONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR TYPE DISK TO '%F'; # defaultCONFIGURE DEVICE TYPE DISK PARALLELISM 1; # defaultCONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE MAXSETSIZE TO UNLIMITED; # defaultCONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/9.0.2/dbs/snapcf_U02.f'; # default

Oracle In

ternal & O

AI Use

Only

Page 70: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-24

Copyright © Oracle Corporation, 2002. All rights reserved.

Retention Policies

• A retention policy describes which backups will be kept and for how long.

• There are two types of retention policy: – Recovery window: Establishes a period of time

within which point-in-time recovery must be possible

– Redundancy: Establishes a fixed number of backups that must be kept. Backups in excess of this can be deleted

• These policies are mutually exclusive and can be set with the CONFIGURE command.

Retention PoliciesA retention policy describes which backups will be kept and for how long. The value of the retention policy is set by the new 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 set as follows:CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

Then for each file there must be a backup that satisfies:SYSDATE - (SELECT CHECKPOINT_TIME FROM V$DATAFILE) >= 7

For DBAs who require the exact number of backups, they may set the retention policy based on the redundancy option. This option requires a specified number of backups to be cataloged before any backup is identified as obsolete. This policy is specified as number of backups.The default retention policy is redundancy 1. A backup is deemed obsolete when a more recent version of the same files has been backed up. Oracle

Internal &

OAI U

se O

nly

Page 71: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-25

Copyright © Oracle Corporation, 2002. All rights reserved.

CONFIGURE RETENTION POLICY Command

• Setting a recovery window policy

• Setting a redundancy policy

• Setting no retention policy

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 5 DAYS;

RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 5;

RMAN> CONFIGURE RETENTION POLICY TO NONE;

CONFIGURE RETENTION POLICY CommandThe CONTROL_FILE_RECORD_KEEP_TIME parameter determines when the records or entries in the control file will be reused with new information. When the data is replaced, RMAN is no longer able to reconstruct a list of backup files required to do a valid restore. If the value specified for the recovery window is greater than the CONTROL_FILE_RECORD_KEEP_TIMEparameter, a recovery catalog is required. The DELETE OBSOLETE command is used to delete obsolete backup sets based on the retention policy. Backup sets that are identified to never expire are not affected by the retention policy or DELETE OBSOLETE command. RMAN cannot implement an automatic retention policy if backups are deleted using non-RMAN methods. One such method is the media manager’s tape retention policy. Ideally, the media manager will never expire a tape until all RMAN backups residing on that tape have been removed from the media manager’s repository.There is a difference between CONFIGURE RETENTION POLICY TO NONE and CONFIGURE RETENTION POLICY TO DEFAULT. The first means that there is no retention policy: backups will never expire, and DELETE OBSOLETE will give an error. The second means that the default retention policy (REDUNDANCY 1) will be in effect.Oracle

Internal &

OAI U

se O

nly

Page 72: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-26

Copyright © Oracle Corporation, 2002. All rights reserved.

Automatic Channel Allocation

• Channels can now be allocated automatically for BACKUP, COPY, RESTORE, and assorted maintenance commands.

• A channel is automatically allocated if not explicitly specified in the RMAN command.

• Default values are specified with the CONFIGUREcommand.

Automatic Channel AllocationWhen a channel is automatically allocated, the channel name is in the format ORA_devicetype_n where devicetype refers to a disk or tape device and n refers to the channel number. RMAN is aware of the command being run and allocates the proper channel type. For example: ORA_DISK_1ORA_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_2RMAN 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, allocating all necessary channels.Oracle

Internal &

OAI U

se O

nly

Page 73: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-27

Copyright © Oracle Corporation, 2002. All rights reserved.

The CONFIGURE CHANNEL Command

The CONFIGURE CHANNEL command is used to configure channel settings.

CONFIGURE CHANNEL [n] <channel_option_list> ;channel_option_list:=TYPE, NAME, PARMS,

CONNECT, DEBUG,FORMAT, TRACE,MAXPIECESIZE, RATE,MAXOPENFILES, SEND

The CONFIGURE CHANNEL CommandThe CONFIGURE CHANNEL command gives the DBA the capability to substitute parameter option values automatically such as NAME, PARMS, CONNECT STRING, DEBUG, FORMAT, MAXPIECESIZE, and SEND to be used when RMAN needs I/O. When parallelizing channels, it may be necessary for each channel to be uniquely identified. An example of this is in a Oracle Real Application Clusters architecture. In this environment, online redo logs are archived to different nodes in a cluster. It is necessary for RMAN to connect to each node to backup the archived logs.If the channel number [n] is specified, the settings apply just to the channel. Otherwise, the settings apply to all channels of the specified type. Example of settings for all channels:

CONFIGURE CHANNEL TYPE SBT;

Example of settings for a specific channel:CONFIGURE CHANNEL 1 TYPE SBT CONNECT 'node1';

In this example the channel is set to make backups in a particular directory:CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/u01/backup/U01_%U';

FORMAT Substitution VariablesThe following substitution variables are available in FORMAT strings to aid in generating unique filenames. The formatting of this information varies by platform.

Oracle In

ternal & O

AI Use

Only

Page 74: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-28

Copyright © Oracle Corporation, 2002. All rights reserved.

CONFIGURE CONTROLFILE AUTOBACKUP

• Under Oracle9i Release 2, CONFIGURECONTROLFILE AUTOBACKUP causes RMAN to back up the control file and the current server parameter file automatically:– After every RMAN BACKUP or COPY command– Whenever a BACKUP or COPY command within a

RUN block is followed by a command that is neither BACKUP nor COPY

– After database structural changes such as adding a new tablespace

• To enable control file autobackups:RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP

RMAN can automatically back up the control file and server parameter file whenever the database structure metadata in the control file changes and whenever a backup or copy record is added. This behavior is new to Oracle9i Release 2. The purpose of the control file autobackup is to provide a way to restore the backup repository contained in the control file when the control file is lost and the recovery catalog is either lost or was never used. You do not need a recovery catalog or target control file to restore the control file autobackup. For example, you can issue:RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;

If CONFIGURE CONTROLFILE AUTOBACKUP is ON then RMAN automatically backs up the control file and the current server parameter file in the following circumstances:

• After every BACKUP or COPY command issued at the RMAN prompt• Whenever a BACKUP or COPY command within a RUN block is followed by a

command that is neither BACKUP nor COPY• After database structural changes such as dropping a table

Note: When autobackups are ON and the backup includes data file 1, then RMAN does not automatically include the current control file in the data file backup set. Instead, RMAN writes the control file and server parameter file to a separate autobackup piece.Oracle

Internal &

OAI U

se O

nly

Page 75: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-29

Copyright © Oracle Corporation, 2002. All rights reserved.

CONFIGURE SNAPSHOT CONTROLFILEand CONFIGURE AUXNAME

For consistency, two old commands have been renamed in Oracle9i:• SET SNAPSHOT CONTROLFILE has been renamed

as CONFIGURE SNAPSHOT CONTROLFILE

• SET AUXNAME has been renamed as CONFIGUREAUXNAME

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '$HOME/snapcf_c82.f';

CONFIGURE AUXNAME FOR DATAFILE 2 TO '$HOME/df2.dbf';

CONFIGURE SNAPSHOT CONTROLFILE

These command name changes are consistent with the rule that CONFIGURE sets persistent options that last across RMAN sessions and SET controls options for a single RMAN session. The old syntax is still supported for backward compatibility.When RMAN needs to resynchronize from a read-consistent 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 making a backup of the current control file. The default value for the snapshot control file is platform-specific and depends on the Oracle home. For example, the default filename on some UNIX platforms in Oracle9i is $ORACLE_HOME/dbs/[email protected]. In general, you should only need to set the control file location in these situations:

• In an Oracle Real Application Clusters configuration and need a snapshot control file accessible by each node

• You are upgrading from a pre-8.1.7 release. In pre-8.1.7 releases, the default location for the snapshot control file was not dependent on the Oracle home

If you are performing TSPITR or using the DUPLICATE command, setting AUXNAME allows you to preconfigure the filenames for use on the auxiliary database without manually specifying the auxiliary filenames during the procedure.

Oracle In

ternal & O

AI Use

Only

Page 76: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-30

Copyright © Oracle Corporation, 2002. All rights reserved.

Other Configuration Commands

Other useful persistent configuration parameters that can be modified with the CONFIGURE command include:

CONFIGURE EXCLUDE FOR TABLESPACE <tablespace> [CLEAR];

CONFIGURE <DATAFILE|ARCHIVELOG> BACKUP COPIESFOR DEVICE TYPE <device_type_spec> TO <n>;

CONFIGURE DEFAULT DEVICE TYPE TO<device_type_spec> | CLEAR;

CONFIGURE DEVICE TYPE <device type> PARALLELISM <n>;

Other Configuration CommandsThe CONFIGURE BACKUP COPIES command provides additional database file protection by allowing the use to specify how many identical copies of each backup are created. The number of copies for data files, and archive logs can be set independently. For example:RMAN> CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT TO 3;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;The CONFIGURE command allows the user to 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.

Oracle In

ternal & O

AI Use

Only

Page 77: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-31

Copyright © Oracle Corporation, 2002. All rights reserved.

Calling Configuration Sets

run {CONFIGURE RETENTION POLICY TO REDUNDANCY 3;CONFIGURE BACKUP OPTIMIZATION OFF;CONFIGURE DEFAULT DEVICE TYPE TO DISK;CONFIGURE CONTROLFILE AUTOBACKUP ON;CONFIGURE DEVICE TYPE DISK PARALLELISM 2;CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;CONFIGURE MAXSETSIZE TO UNLIMITED;CONFIGURE SNAPSHOT CONTROLFILE NAME TO

'$HOME/back/snapf_U01.f';}

Create specialized configuration sets by including CONFIGURE commands in a run block:

Calling Configuration SetsObviously, a fixed set of configuration parameters will not suffice for all backup operations. Use the CONFIGURE command to make these changes.You can script the CONFIGURE commands within a run block to change more then one parameter or just change a single parameter at a time from the RMAN prompt not using the run block. You can save the configuration to a script and call it when performing a backup that requires the configuration changes.

Oracle In

ternal & O

AI Use

Only

Page 78: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-32

Copyright © Oracle Corporation, 2002. All rights reserved.

CATALOG Command

• The CATALOG command allows user-managed backups to be registered with RMAN.

• Works on archived redo logs data file copies, control file copies, and so on.

RMAN> catalog archivelog '/U01/archlog/al_U01_1234.rdo';

CATALOG CommandThe control file keeps records of all archived logs generated by the target database. If you use a recovery catalog, then RMAN propagates the archived log information from the control file to the catalog. If you have to restore a control file backup, and if you change the archiving destination or format during recovery, then the repository will not have information about archived logs needed for recovery. Hence, you must catalog these logs if you want to use them for recovery.When you make user-managed copies, the repository has no record of them. You must manually notify RMAN when you make copies with an operating system utility such as the UNIX cpcommand. Run the RMAN CATALOG command when:

• Adding information about a user-managed data file copy, archived redo log copy, or control file copy to the recovery catalog and control file

• Cataloging a data file copy as a level 0 backup, thus enabling you to perform an incremental backup later by using the data file copy as the base of an incremental backup strategy

• Recording the existence of user-managed copies of Oracle release 8.0 and later databases created before RMAN was used

• Recording the existence of Oracle7 backups before migrating to Oracle 8.0 or laterOracle

Internal &

OAI U

se O

nly

Page 79: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-33

Copyright © Oracle Corporation, 2002. All rights reserved.

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

archived redo log copy

Cataloging Consistent and Inconsistent CopiesWhenever you make a user-managed copy, make sure to catalog it. When making user-managed copies, you can use the ALTER TABLESPACE ... BEGIN/END BACKUP statement in conjunction with an OS copy command to make data file copies of an online tablespace. Although RMAN does not create such data file copies, you can use the CATALOG command to add them to the recovery catalog so that RMAN is aware of them.For example, if you store data files on mirrored disk drives then you can create a user-managed copy by breaking the mirror. In this scenario, use the CATALOG command to notify RMAN of the existence of the user-managed copy after breaking the mirror. Before reforming the mirror, run a CHANGE...UNCATALOG command to notify RMAN that the file copy no longer exists.

Oracle In

ternal & O

AI Use

Only

Page 80: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-34

Copyright © Oracle Corporation, 2002. All rights reserved.

Recovery Catalog Compatibility

The rules of RMAN compatibility are as follows:• The recovery catalog schema can be created with

any current Oracle release.• The recovery catalog schema version must be

greater than or equal to the RMAN executable version.

• The versions of the RMAN executable and the target database should be the same.

Recovery Catalog CompatibilityThe RMAN environment can contain the following components:

• RMAN executable• Recovery catalog database• Recovery catalog schema in the recovery catalog database• Target database• Auxiliary database (that is, a duplicate or standby database)

Each component has a release number. For example, you can use a release 9.0.1 RMAN executable with:

• A release 9.0.1 target database• A release 9.0.1 duplicate database• A release 8.1.5 recovery catalog database whose catalog tables were created with RMAN

release 9.0.1If you use a version of the recovery catalog that is older than that required by the RMAN executable, then you must upgrade it. For example, you must upgrade the catalog if you use a release 9i version of the RMAN executable with a release 8i. version of the recovery catalog.Oracle

Internal &

OAI U

se O

nly

Page 81: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-35

Copyright © Oracle Corporation, 2002. All rights reserved.

Determine the Schema Version of the Recovery Catalog

1. Start SQL*Plus and connect to the recovery catalog database as the catalog owner :

2. Query the RCVER table to obtain the schema version:

$ sqlplus rman/cat@catdb

SQL> SELECT * FROM RCVER;VERSION------------09.02.00

Determining the Schema Version of the Recovery CatalogIn the example above, the select on the RCVER table retrieves a single row. If the table displays multiple rows however, then the highest version in the RCVER table is the current catalog schema version. The table stores only the major version numbers and not the patch numbers. For example, assume that the SELECT operation on the RCVER table displays the following rows:VERSION------------08.01.0709.00.0109.02.00

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.

Oracle In

ternal & O

AI Use

Only

Page 82: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-36

Copyright © Oracle Corporation, 2002. All rights reserved.

Upgrading Recovery Catalog

To upgrade the catalog, start RMAN.• An error will occur if the catalog needs to be

upgraded.

• Use the UPGRADE CATALOG command to upgrade the catalog to the release required by this version of the RMAN executable.

$ rman TARGET / CATALOG rman/cat@catdbconnected to recovery catalog databasePL/SQL package rcat.DBMS_RCVCAT version 08.01.01 in RCVCAT database is too old

RMAN> UPGRADE CATALOG;recovery catalog owner is rmanenter UPGRADE CATALOG command again to confirm catalog upgrade

Upgrading Recovery CatalogYou will receive an error when issuing UPGRADE CATALOG if the recovery catalog is already at a version greater than that required by the RMAN executable. RMAN permits the UPGRADECATALOG command to be run if the recovery catalog is current and does not require upgrading, however, so that you can re-create packages at any time if necessary. Check the message log for error messages generated during the upgrade. After issuing the UPGRADE CATALOG command, the user will be prompted to run the UPGRADE CATALOG once again to confirm that the upgrade was successful:RMAN> UPGRADE CATALOG;

recovery catalog upgraded to version 09.02.00

DBMS_RCVMAN package upgraded to version 09.02.00

DBMS_RCVCAT package upgraded to version 09.02.00

Oracle In

ternal & O

AI Use

Only

Page 83: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-37

Copyright © Oracle Corporation, 2002. All rights reserved.

Dropping the Recovery Catalog

• Use RMAN to connect to the target and recovery catalog databases.

• Run DROP CATALOG command twice to confirm:RMAN> DROP CATALOG;recovery catalog owner is rmanenter DROP CATALOG command again to confirm catalog removalRMAN> DROP CATALOG;

$ rman TARGET / CATALOG rman/cat@catdb

Dropping Recovery CatalogThe DROP CATALOG command must be entered twice to confirm that it is what you really want to do. All backups for all target databases managed by this catalog will become unusable. Removing the catalog does not remove the copies from disk or backup sets from the media they are stored on. Just the catalog tables are removed.If you do not want to maintain a recovery catalog, then you can drop the recovery catalog schema from the tablespace. The DROP CATALOG command deletes all information from the recovery catalog. Hence, if you have no backups of the recovery catalog schema, then all backups of all target databases managed by this catalog become unusable.The DROP CATALOG command is not appropriate for “unregistering” a single database from a catalog that has multiple target databases registered. If you try to delete the metadata for one target database by dropping the catalog, then you delete the metadata for all target databases.

Oracle In

ternal & O

AI Use

Only

Page 84: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-38

Copyright © Oracle Corporation, 2002. All rights reserved.

Summary

In this lesson, you should have learned how to:• Understand RMAN configuration decisions • Outline the steps taken in creating a recovery

catalog• Create/grant privileges to a RMAN user• Start RMAN and register a database in a recovery

catalog• Demonstrate the use of recovery catalog

maintenance commands like RESYNC, CONFIGURE, and CATALOG

• Upgrade and drop a recovery catalog

Oracle In

ternal & O

AI Use

Only

Page 85: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 2-39

Copyright © Oracle Corporation, 2002. All rights reserved.

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• Query relevant views in the repository

Oracle In

ternal & O

AI Use

Only

Page 86: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 87: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Copyright © Oracle Corporation, 2002. All rights reserved.

Backups with RMAN

Oracle In

ternal & O

AI Use

Only

Page 88: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-2

Copyright © Oracle Corporation, 2002. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:• Identify the types of backups 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 and

cumulative incremental backup• Outline the Recovery Manager backup algorithm• Demonstrate a working knowledge of the BACKUP

command functionality

Oracle In

ternal & O

AI Use

Only

Page 89: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-3

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Backups

• RMAN allows a whole database backup, or any of the following subsets, whether the database is open or closed:– Database, tablespaces, data files and data file

copies, control file, archived logs• RMAN automatically updates changes in database

structure to the recovery catalog before executing certain commands such as BACKUP– The information updated includes new data files,

resized data files, dropped tablespaces, new archivelogs

RMAN BackupsRun 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 only)• 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 non-incremental; that is, every used block is backed up.Oracle

Internal &

OAI U

se O

nly

Page 90: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-4

Copyright © Oracle Corporation, 2002. All rights reserved.

Running the BACKUP Command

The BACKUP command can be run:• Interactively:

• From a stored script:

• From an OS command file:

RMAN> backup database;

RMAN> RUN { EXECUTE SCRIPT backup_whole_db };

$ rman TARGET / @backup_db.rman # From a command line RMAN> @backup_db.rman # From RMAN promptRMAN> RUN { @backup_db.rman } # From a RUN command

Running the BACKUP CommandInteractive ModeTo run RMAN commands interactively, start RMAN and then enter commands into the command-line interface.$ rman TARGET SYS/oracle@prod1 CATALOG rman/cat@catdb

After the RMAN prompt is displayed, you can enter commands such as the following:RMAN> BACKUP DATABASE;

Stored ScriptsA 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. Below is an example of stored script creation and execution:CREATE SCRIPT backup_whole_db{# back up whole database and archived logsBACKUPTAG backup_wholeDATABASE PLUS ARCHIVELOG;}

Oracle In

ternal & O

AI Use

Only

Page 91: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-5

Running the BACKUP Command (continued)Stored Scripts (continued)You can execute this stored script from the RMAN prompt as follows:RMAN> RUN { EXECUTE SCRIPT b_whole_10 };

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

Running a Command FileYou can run an operating system stored command file from a shell prompt, RMAN prompt or a RUN block by preceding the command file name by the @ character. If the command file is not found in your current path, you must furnish the correct relative or absolute path as part of the command file name. This example creates a command file and then runs it from the operating system command line:$ echo "BACKUP DATABASE;" > /u01/backups/cmd_files/backup_db.rman

$ rman TARGET / @/u01/backups/cmd_files/backup_db.rman

The example below runs a command file from the RMAN prompt:RMAN> @/u01/backups/cmd_files/backup_db.rman

Oracle In

ternal & O

AI Use

Only

Page 92: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-6

Copyright © Oracle Corporation, 2002. All rights reserved.

Backup Tags

• A tag is a name or identifier given to a backup.• Tags can be up to 30 characters in length and do

not need to be unique.

• Under Oracle9i Release 2, RMAN will automatically provide a name if one is not specified.– Control file autobackups are the exception.

• A tag applies to each backup piece in a given copy of a backup set.

BACKUP DEVICE TYPE DISK DATAFILE 1 TAG "wkly_bkup";

Backup TagsA character string called a tag may be assigned to backup sets and image copies. A tag is a case-insensitive 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 CHANGEcommand. The maximum length of a tag is 30 characters.If you are using Oracle9i Release 2, RMAN will create 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.Oracle

Internal &

OAI U

se O

nly

Page 93: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-7

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Managed Backups

RMAN managed backups:• File copy

– A file copy is an exact image copy of the original file created by the COPY command.

– A file copy can only be written to 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.

File CopiesFile copies can be done through RMAN or the host operating system. Operating system backups on disk can be cataloged in the recovery catalog for immediate use. Once the O/S backups have been cataloged, they can then be backed up by RMAN to disk or via the Media Management Layer. The LEVEL 0 option to the CATALOG command allows O/S 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 SetsA backup set consists of one or more physical output files called backup pieces. Backup sets usually contain multiple source files that are multiplexed in the output. It can be written to disk or tertiary storage, which requires media manager support. A restore operation is required to extract files from a backup set.Oracle

Internal &

OAI U

se O

nly

Page 94: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-8

Copyright © Oracle Corporation, 2002. All rights reserved.

Parallelization of File Copies

Parallelization of file copies is achieved by copying multiple files within one copy command, as well as allocating multiple channels.

run {allocate channel d1 type disk;allocate channel d2 type disk;allocate channel d3 type disk;

copy # firstdatafile 1 to ‘$HOME/prd1.dbf’,datafile 2 to ‘$HOME/prd2.dbf’;copy # seconddatafile 3 to ‘$HOME/prd3.dbf’;

sql ‘alter system archive log current’; }

Parallelization of File Copies RMAN executes commands serially. The previous command must finish before the next command is started. In this example, the first copy command will perform in parallel. The second copy command is not executed until the command before it completes. Therefore you should always attempt to increase parallelism to speed backups. The example in the slide shows manual channel allocation to achieve the desired level of parallelization. With Oracle9i the channels can be configured and stored in the persistent configuration along with the default level of parallelization. These settings will be used whenever a backup is executed unless overridden manually with a series of allocate channel commandsNote: The greater the degree of parallelism, the higher the machine resource but the shorter the duration.

Oracle In

ternal & O

AI Use

Only

Page 95: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-9

Copyright © Oracle Corporation, 2002. All rights reserved.

Backup Set

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

• Archivelog backup sets– Contain archived log files only

Backup SetsYou can back up data files, control files, archived redo logs, and the current server parameter file (Oracle9i only). 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 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, it is still backed up because the backup process does not have access to space management information. This is a source of some confusion as some think that RMAN will omit blocks that do not currently contain data. For example if a table is dropped, RMAN will continue to back up the blocks even though the extents used by that table are now free.Oracle

Internal &

OAI U

se O

nly

Page 96: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-10

Copyright © Oracle Corporation, 2002. All rights reserved.

Backup Set Example

Full database backup, five backup sets, two files per set.

run { allocate channel t1 type ‘SBT_TAPE’; allocate channel t2 type ‘SBT_TAPE’; backup filesperset 2 format ‘df_%t_%s_%p’ database; }

Data File Backup Set ExampleThe syntax in the example above illustrates a full database backup of a database with 10 files, including the control file, to two tape drives. The number of files per backup set has been restricted to two, which means that five sets will be created, each with two files multiplexed. If two channels are allocated, two sets can be created in parallel. RMAN will automatically perform the partitioning of files to channels, multiplex the files, and skip any unused blocks. The format string determines the output file name that is passed to sbtopen(). Some common format identifiers include:• %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 elapsed since a fixed reference time. This is a partial list of format identifiers. For a more complete treatment, see Oracle9i Recovery Manager Reference.Oracle

Internal &

OAI U

se O

nly

Page 97: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-11

Copyright © Oracle Corporation, 2002. All rights reserved.

Archivelog Backup Sets

• Archivelog Backup Sets only include archivelogs.• Archivelog Backup Sets are always full backups

unless backup optimization is enabled.• RMAN has access to control file information so it

knows what logs have been archived.• As with data file backup sets, archivelog backups

are automatically distributed across the number of channels specified.

allocate channel t1 type ‘SBT_TAPE’;allocate channel t2 type ‘SBT_TAPE’;backup format ‘al_%t_%s’ archivelog all delete input;

Archive Log Backup SetsAs RMAN has access to control file information, it knows what logs have been archived. This prevents a common problem experienced by users, of not knowing whether an archive log has been completely copied out to the archive log destination before attempting to back it up.

Oracle In

ternal & O

AI Use

Only

Page 98: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-12

Copyright © Oracle Corporation, 2002. All rights reserved.

Parallelization of Backup Sets

Parallelization of backup sets can be done by allocating multiple channels or using the configure command for automatic channel allocation. • Manual allocation:

• Automatic allocation:

run {allocate channel t1 type ‘sbt_tape’; allocate channel t2 type ‘sbt_tape’; backup...

}

CONFIGURE DEVICE TYPE DISK PARALLELISM 2; CONFIGURE DEFAULT DEVICE TYPE TO DISK;

Parallelization of Backup Sets Parallelization of backup sets is achieved by allocating multiple channels. Each channel gets enough data files to make each backup set roughly the same size.The CONFIGURE DEVICE TYPE ... PARALLELISM command specifies the number of channels that RMAN uses when allocating automatic channels for a specified device type. For example, if you configure parallelism to 3, then RMAN allocates three channels of the default device type whenever it uses automatic channels.When parallelizing backups, RMAN always allocates channels in numerical order beginning with 1 and ending with the parallelism setting. For example, if the device type is sbt and parallelization is set to 4, then RMAN allocates as follows:ORA_SBT_TAPE_1

ORA_SBT_TAPE_2

ORA_SBT_TAPE_3

ORA_SBT_TAPE_4

You can change a parallelism setting by issuing another CONFIGURE DEVICE TYPE...PARALLELISM command.Oracle

Internal &

OAI U

se O

nly

Page 99: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-13

Copyright © Oracle Corporation, 2002. All rights reserved.

Backup Pieces

• A backup piece consists of one or more physical output files contained within a backup set.

• A backup set usually has only one backup piece.• The only time a backup set has more than one

piece is when the maximum piece size is limited by the user.

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE = 2G;RMAN> BACKUP DATAFILE 1;

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 specifiednumber of bytes. 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 FORMATparameter provides substitution variables that you can use to generate unique filenames. For example, you can run a command as follows:BACKUP TABLESPACE users FORMAT = ’/tmp/users_%u%p%c’;

Format can be specified in three places, and will be used in the following precedence:• BACKUP OBJECT• BACKUP COMMAND• ALLOCATE/CONFIGURE CHANNELOracle

Internal &

OAI U

se O

nly

Page 100: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-14

Copyright © Oracle Corporation, 2002. All rights reserved.

Backup Piece Contents

• Each piece in a set has a piece header located in the first block.

• The first block in the piece header includes:– Database ID– Piece number– Set stamp, set count– Type of backup– How many directory blocks follow the piece header

Backup Piece ContentsThe directory contains metadata about each file in the backup set. A directory entry contains different information, depending on whether it is a data file or archivelog backup set. All blocks in the backup set, including the directory, have a logical block size equal to the block size of the files being backed up. Data file directory entries include:

• Absolute and relative file number for the file• Creation SCN• Resetlogs SCN• Checkpoint SCN• Incremental-start SCN

Archivelog directory entries include:• Thread• Sequence• Low SCN• Next SCN• Resetlogs SCN

Following the header and directory are the blocks for the files being backed up. For each file, block 2 is the first block in the backup, and the header is the last block.Oracle

Internal &

OAI U

se O

nly

Page 101: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-15

Copyright © Oracle Corporation, 2002. All rights reserved.

Incremental Data File Backup

• Incremental data file backups are by default noncumulative.

• Incremental data file backups are available only with Enterprise Edition.

Changedblocks

Level 0 2 2 1 2 2 2 0Day Sun Mon Tue Wed Thu Fri Sat Sun

All non-emptyblocks

Incremental Data File BackupAn incremental data file backup is a backup of a data file that only copies out Oracle blocks that have been modified since a previous incremental backup.An incremental backup at level N, where N is greater than zero, backs up all blocks modified since the previous incremental at all levels that are less than or equal to N. Incremental backups are initially based on a level 0 backup set, or a level 0 file copy. Incremental backups write out fewer blocks than full (or level 0) backups, and therefore can be faster.

Oracle In

ternal & O

AI Use

Only

Page 102: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-16

Copyright © Oracle Corporation, 2002. All rights reserved.

Cumulative Incremental Backups

• A cumulative incremental backup at level N (where N is greater than 0) backs up all blocks modified since the previous incremental at a level less than N.

• Cumulative incremental backups are provided for recovery speed.

Changedblocks

Level 0 2 2C 1 2 2C 2C 0Day Sun Mon Tue Wed Thu Fri Sat Sun

All non-emptyblocks

Cumulative Incremental BackupsCumulative incremental backups duplicate work performed by other cumulative incremental backups at the same level. This means that the cumulative backup may take longer and will be larger than if it were not cumulative. Because cumulative incrementals back up blocks previously backed up at the same level, they may take longer and will write more blocks than non-cumulative. Fewer backups at each level must be applied when recovering. Basically, a cumulative incremental backups supersede incremental backups at the same level as itself. If you took a level 2, then a cumulative level 2, the second level 2 would backup all the blocks modified, including those backed up by the first level 2. This means that only one incremental backup of any level is needed to completely recover.

Oracle In

ternal & O

AI Use

Only

Page 103: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-17

Copyright © Oracle Corporation, 2002. All rights reserved.

SCN and Incremental Backups

• There are two important SCNs:– CHECKPOINT_CHANGE#

– INCREMENTAL_CHANGE#

• Incremental level equal to 0– Backs up all blocks with data

• Incremental level greater than 0– Backs up all blocks with SCN's greater than or

equal to the INCREMENTAL_CHANGE#

SCN and Incremental BackupsCHECKPOINT_CHANGE#

The data file’s checkpoint SCN at the time the backup began. This is the checkpoint that the file will have after this incremental is applied.INCREMENTAL_CHANGE#

The checkpoint SCN for the data file as it was in the backup this one is based on. The INCREMENTAL_CHANGE# is also known as the incremental-start SCN. Incremental level greater than 0All blocks with SCN’s greater than or equal to the INCREMENTAL_CHANGE# are backed up when the incremental level is greater than 0. That is, all blocks which were modified since the first file was checkpointed and blocks at the same checkpoint as the file (as they may have been modified more than once at the same SCN in between being written out).It is better to do a level 0 if there are many updates to different blocks. It is better to do an incremental greater than 0 if there are many updates to fewer blocks.

Oracle In

ternal & O

AI Use

Only

Page 104: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-18

Copyright © Oracle Corporation, 2002. All rights reserved.

Basic Backup Algorithm

In determining the characteristics of the backup sets, the basic algorithm is influenced by the following:• The number of backupSpec clauses that you

specify• The number of channels that you allocate• The FILESPERSET parameter, which limits the

number of files for a backup set• The MAXSETSIZE parameter (specified on the

CONFIGURE and BACKUP commands), which specifies a maximum backup set size

Basic Backup AlgorithmThe total number and size of backup sets depends on which algorithm RMAN uses: the basic algorithm or the advanced algorithm. Each backupSpec clause produces at least one backup set. RMAN uses the basic algorithm when any of the following conditions are true:

• You are backing up files other than data files or control files.• The operating system does not provide data about which files are located on which

disks, or which nodes in a cluster have affinity with which disks.• You manually set the DISKRATIO parameter of the BACKUP command to 0.

If all of these conditions are false, then RMAN uses the advanced algorithm. You can always force RMAN to use the basic algorithm by setting DISKRATIO=0.

Oracle In

ternal & O

AI Use

Only

Page 105: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-19

Copyright © Oracle Corporation, 2002. All rights reserved.

Algorithm Rules

The most important rules in the algorithm for backup set creation 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 not set.

• RMAN detects which physical drives a data file is located on, and tries to make each backup set read from about the same number of disk drives.

Algorithm RulesThe basic backup algorithm follows several important tenants when creating backup sets. Each allocated channel that performs work in the backup job—that 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 2 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.Oracle

Internal &

OAI U

se O

nly

Page 106: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-20

Algorithm Rules (continued)When both parameters are being used, the number of backup sets is the greater of the following ratios:

• Total number of blocks divided by MAXSETSIZE• Total number of data files divided by FILESPERSET

RMAN will enforce both the FILESPERSET and MAXSETSIZE limits. If necessary, then RMAN creates more backup sets than are calculated in the preceding comparison. RMAN uses the algorithm of best fit so that the majority of backup sets have a size as close to the MAXSETSIZE limit with the number of files as close to the FILESPERSET limit as possible.

Oracle In

ternal & O

AI Use

Only

Page 107: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-21

Copyright © Oracle Corporation, 2002. All rights reserved.

Advanced Algorithm

• The advanced algorithm considers DISKRATIO in addition to FILESPERSET and MAXSETSIZE

• If DISKRATIO is not set, it defaults to the same value of FILESPERSET.

• If neither DISKRATIO or FILESPERSET not set, the value of DISKRATIO defaults to 4.

Advanced AlgorithmThe 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 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 6 disks, and the operating system is able to deliver this disk contention information to the server. You configure a single sbtchannel and then run BACKUP DATABASE.RMAN will use the advanced algorithm because 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.

Oracle In

ternal & O

AI Use

Only

Page 108: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-22

Copyright © Oracle Corporation, 2002. All rights reserved.

Algorithm Behavior for Standard Backup Sets

• Allocates memory structures and I/O buffers for each file in the set

• Orders the files to be backed up in a channel in descending size order

• Files in the set are checkpointed at the same SCN• Read, validate, and save each file’s header block• Multiplex the files together

Algorithm Behavior for Standard Backup SetsThe algorithm allocates memory structures and I/O buffers for each file in the set. Input buffers and output buffers do not necessarily need to be in sync. Many input buffers may be processed before an output buffer is filled. This may be the case for incremental backups with a level greater than 0. The files to be backed up are inspected and arranged in the channel based on size in descending order.At this time all the files in the backup set are checkpointed at the same SCN and the file header blocks are validated.

Oracle In

ternal & O

AI Use

Only

Page 109: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-23

Copyright © Oracle Corporation, 2002. All rights reserved.

Algorithm Behavior for Standard Backup Sets

• For each buffer, it is decided whether to include blocks.– If incremental, check SCN in block to see if it

qualifies for inclusion– If full or level 0, check to see whether the block has

ever contained data• Check for physical and logical corruption and

calculate checksum. • Replace the file number in RDBA with a backup

set relative file number.

Algorithm Behavior for Standard Backup Sets (continued)While processing the buffer contents, decisions are made as to the inclusion of the blocks. If an incremental backup is being performed, the block SCN is queried. If a full backup is performed, the block is checked to see if it is empty. If a file contains many empty blocks, for each total_number_of_input_blocks (four times the number of blocks per buffer) in the buffer, only one empty block is actually copied out. This specifically addresses restore performance.During this process, the blocks are checked for physical and logical corruption. It is possible for the user to allow a certain number of corrupt blocks per file.The file number in the data block address (DBA) is replaced with a unique number that is the absolute file number within the set. This number is stored in the file’s directory entry. When restoring files from backup sets, the file header is written last to ensure that the file has not been truncated before the restore completed.When the output buffer is filled, it is sent to the output device. When the input buffer is empty, a read ahead is performed. Finally, the file header is written into the backup set and the control file is updated.Oracle

Internal &

OAI U

se O

nly

Page 110: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-24

Copyright © Oracle Corporation, 2002. All rights reserved.

Algorithm Behavior for Archivelog Backup Sets

• Archived logs are included in a backup set ordered by descending size

• Similar process to the data file backup algorithm• Sequence number is converted to a backup-set

relative file number• No blocks are skipped• Any corruptions detected causes the backup to be

terminated• When the backup is complete, control file is

updated

Algorithm Behavior for Archivelog Backup SetsWhen RMAN is creating archivelog backup sets all blocks are copied out. There is no provision to skip “empty” blocks. All blocks are multiplexed, similar to data file backups. The input and output buffers are in sync, as all blocks are included. Any corruptions encountered during an archivelog backup will cause the backup to be terminated.

Oracle In

ternal & O

AI Use

Only

Page 111: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-25

Copyright © Oracle Corporation, 2002. All rights reserved.

Algorithm Behavior for File Copies

• A single server process operates on one file at a time.

• No blocks are skipped.• Checks for physical and logical corruption and

calculates checksum.• File header is written last.• The control file is updated when the copy is

complete.

Algorithm Behavior for File CopiesWhen RMAN performs a file copy, no data movement takes place; the buffers are shared. A single server process works on one file at a time. As with the archivelog backup sets, no blocks are skipped.

Oracle In

ternal & O

AI Use

Only

Page 112: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-26

Copyright © Oracle Corporation, 2002. All rights reserved.

Backup Optimization

• The BACKUP command will skip a file if an identical copy already exists.

• Enabled by running the CONFIGURE BACKUP OPTIMIZATION ON command.

• The default behavior is OFF.• Only one channel type may be allocated, channels

of type DISK and SBT may not be mixed.

CONFIGURE BACKUP OPTIMIZATION [ON | OFF | CLEAR];

Backup OptimizationIf 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 or not they have changed, specify the FORCE option on the BACKUP command. To enable or disable backup optimization, specify ON or OFF with the CONFIGURE BACKUP OPTIMIZATION command.

Oracle In

ternal & O

AI Use

Only

Page 113: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-27

Copyright © Oracle Corporation, 2002. All rights reserved.

Backup Optimization Algorithm

Algorithm criteria used to determine identical files:• Data file

– Same DBID, checkpoint SCN, RESETLOGS SCN and time

– The data file must be offline-normal, read-only, or closed normally

• Archived redo log – Same thread, sequence number, and RESETLOGS

SCN and time• Backup set

– Same backup set record id and stamp

Backup Optimization AlgorithmData File BackupsIf you have a retention policy, then RMAN skips a data file backup only if the latest backup of a file is earlier than the earliest point in the window. If you did not configure a recovery window, then RMAN sets n = 1 and searches for values of n in this order of precedence:

• If CONFIGURE RETENTION POLICY TO REDUNDANCY r is enabled, then RMAN only skips data files when n = r + 1 backups exist.

• BACKUP ... COPIES n• SET BACKUP COPIES n• CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE ... TO n

RMAN skips backup only if at least n backups of an identical file exist on the specified device. If RMAN does not skip the backup, then it makes the backup exactly as specified.Archived LogBy default, n = 1. RMAN searches for values of n in this order of precedence (that is, values higher on the list override values lower on the list):• BACKUP ... COPIES n• SET BACKUP COPIES n.Oracle

Internal &

OAI U

se O

nly

Page 114: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-28

Backup Optimization Algorithm (continued)Archived Log (continued)• CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE ...

TO nRMAN skips backup only if at least n backups of an identical file exist on the specified device. If RMAN does not skip the backup, then it makes the backup exactly as specified.Backup SetBy default, n = 1. RMAN searches for other values of n in this order of precedence (that is, values higher on the list override values lower on the list):• BACKUP ... COPIES n• SET BACKUP COPIES n

RMAN skips backup only if at least n backups of an identical file exist on the specified device. If RMAN does not skip the backup, then it makes the backup exactly as specified. ExampleTo see how these rules work in practice, consider the following scenario:Assume that at 9 a.m. you back up three copies of all existing archived logs to tape:BACKUP DEVICE TYPE sbt COPIES 3 ARCHIVELOG ALL;

Later, you enable the following configuration setting:CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE sbt TO 4;CONFIGURE BACKUP OPTIMIZATION ON;

Then, you run the following archived log backup at noon:BACKUP DEVICE TYPE sbt COPIES 2 ARCHIVELOG ALL;

In this case, the BACKUP...COPIES setting overrides the CONFIGURE...COPIESsetting, so RMAN sets n = 2. RMAN skips the backup of a log only if at least two copies of the log exist on the sbt device. Because three copies of each log exist on sbt of all the logs generated before 9 a.m., RMAN skips the backups of these logs. However, RMAN backs up two copies of all logs generated after 9 a.m. because these logs have not yet been backed up to tape.At this point, three copies of the logs created before 9 a.m. exist on tape, and two copies of the logs created after 9 a.m. exist on tape. Assume that you run the following backup command at 3 p.m.:RUN{SET BACKUP COPIES 3;BACKUP DEVICE TYPE sbt ARCHIVELOG ALL;}

In this case, RMAN sets n = 3 and so will not back up the logs created before 9 a.m. because three copies already exist on tape. However, only two copies of the logs 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 created after 9 a.m.Oracle

Internal &

OAI U

se O

nly

Page 115: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-29

Copyright © Oracle Corporation, 2002. All rights reserved.

Duplexed Backups

• Duplexed backups can create up to four identical copies of each backup piece.

• Duplexed backups require a FORMAT specification that guarantees uniqueness.– %c - copy number (1-4)– %U - new default format; equivalent to %u_%p_%c

• Duplexed backups require setting the parameter BACKUP_IO_SLAVES = TRUE.

• Backup duplexing works with any media manager.

Duplexed BackupsMultiple or duplexed backup copies can be made by using the SET DUPLEX command when running your backup. Use the SET DUPLEX command before allocating any channels. The SET DUPLEX command affects all channels allocated after issuing the command.Backup duplexing can be used with the DELETE INPUT option to make sure more than one backup of an archived log exists before the log is deleted from disk.

Oracle In

ternal & O

AI Use

Only

Page 116: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-30

Copyright © Oracle Corporation, 2002. All rights reserved.

Duplexed Backups

Backup duplexing provides an efficient way to produce multiple copies of each backup piece.• Duplexing under Oracle9i using the COPIES

option:

• Duplexing under Oracle8i is done using the SET DUPLEX command– The SET DUPLEX command must occur before

channels are allocated• Duplexed backups require setting the parameter

BACKUP_IO_SLAVES = TRUE

BACKUP DEVICE TYPE DISK COPIES 3 DATAFILE 7 FORMAT ’/tmp/%U’,’?/oradata/%U’,’?/%U’;

Duplexed BackupsRMAN provides an efficient way to produce multiple copies of each backup piece in a backup set. This functionality is also known as duplexing a backup set. You can create up to four identical copies of each piece in a backup set. If multiple commands are in effect simultaneously, then commands higher on the list override commands that are lower on the list. Duplexing under Oracle9i is done using the COPIES option while Oracle8irequires the use of the SET DUPLEX command. Duplexing can be used with the DELETE INPUT option to make sure more than one backup of an archived log exists before the log is deleted from disk. Duplexed backups require a FORMAT specification that guarantees uniqueness.• %c - copy number (1-4)• %U – This is the default format; and is equivalent to %u_%p_%c

In the slide example, observe that RMAN places the first copy of each backup piece in /tmp, the second in ?/oradata, and the third in the Oracle home. Note that RMAN does not produce three backup sets, each with a different unique backup set key.

Oracle In

ternal & O

AI Use

Only

Page 117: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-31

Duplexed Backups (continued)Rather, RMAN produces one backup set with a unique key, and generates three identical copies of each backup piece in the set, as shown in this sample LIST output:RMAN> list backup;

List of Backup Sets===================BS Key Type LV Size------ ---- -- ----------1 Full 64KList of Datafiles in backup set 1File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- --------- ----7 Full 98410 08-MAR-02 /oracle/oradata/trgt/tools01.dbf

Backup Set Copy #1 of backup set 1

Device Type Elapsed Time Completion Time Tag

----------- ------------ --------------- ---

DISK 00:00:01 08-MAR-02 TAG20020208T152314List of Backup Pieces for backup set 1 Copy #1BP Key Pc# Status Piece Name------- --- ----------- ----------1 1 AVAILABLE /tmp/01dg9tb2_1_1

Backup Set Copy #2 of backup set 1

Device Type Elapsed Time Completion Time Tag

----------- ------------ --------------- ---

DISK 00:00:01 08-MAR-02 TAG20020208T152314List of Backup Pieces for backup set 1 Copy #2BP Key Pc# Status Piece Name------- --- ----------- ----------2 1 AVAILABLE /oracle/oradata/01dg9tb2_1_2

Backup Set Copy #3 of backup set 1

Device Type Elapsed Time Completion Time Tag

----------- ------------ --------------- ---

DISK 00:00:01 08-MAR-02 TAG20020208T152314List of Backup Pieces for backup set 1 Copy #3BP Key Pc# Status Piece Name------- --- ----------- ----------3 1 AVAILABLE /oracle/01dg9tb2_1_3

Oracle In

ternal & O

AI Use

Only

Page 118: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-32

Copyright © Oracle Corporation, 2002. All rights reserved.

Mirrored Backups

• Mirrored backups are created by using the SET DUPLEX command.

• Oracle9i provides extra functionality by:– Allowing a default duplex value– Supporting a multivalued option for duplexed

backups stored on diskRUN {

SET BACKUP COPIES 3;BACKUP DATABASEFORMAT '/u01/backups/%U',FORMAT '/u02/backups/%U',FORMAT '/u03/backups/%U';}

Mirrored BackupsWhen 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 SETBACKUP 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, 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 example below illustrates this concept:SET BACKUP COPIES 3

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.

Oracle In

ternal & O

AI Use

Only

Page 119: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-33

Copyright © Oracle Corporation, 2002. All rights reserved.

Proxy Copy

• A proxy copy shifts the backup and restore overhead away from the Oracle server.

• Proxy copies require support from the media manager as it will take over the entire backup job.

• Files must be placed in backup mode, because an external utility is reading data files during backup.

• Query the V$PROXY_DATAFILE view to look at proxy copy information.

• If a crash leaves some files in backup mode, they will automatically be taken out of backup mode.

Proxy CopyA 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 BACKUPcommand specifies that a backup should be a proxy copy. For each file that you attempt to back up 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 Oracle to issue an error message when it cannot proxy copy.Oracle 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.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 being processed by one job step, while aggregate rows describe the files processed by all job steps in an RMAN command.Oracle

Internal &

OAI U

se O

nly

Page 120: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-34

Copyright © Oracle Corporation, 2002. All rights reserved.

Backup Set Backup

• This Oracle9i feature allows RMAN to change the location of a backup set.

• The source location for this command must be disk, however the destination can be DISK or SBT.

BACKUP... BACKUPSET <key |CompletedTimeSpec | ALL>;

BACKUPDEVICE TYPE SBTBACKUP SETCREATED BEFORE 'sysdate – 1'DELETE INPUT

Backing Up Backup Sets You can now back up backup sets from disk to tape or from disk to disk. If RMAN discovers a corrupt block or missing backup piece during the backup, then RMAN automatically performs failover to an existing intact copy. The BACKUP BACKUPSET command uses the default disk channel to copy backup sets from disk to disk. To back up from disk to tape, you must either manually allocate a channel of DEVICE TYPE SBT or configure an automatic sbt channel.The BACKUP BACKUPSET command is a useful way to spread backups among multiple media. For example, you can execute the following BACKUP command weekly as part of the production backup schedule:BACKUP DEVICE TYPE SBT BACKUPSET ALL;

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: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.Oracle

Internal &

OAI U

se O

nly

Page 121: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-35

Copyright © Oracle Corporation, 2002. All rights reserved.

Archived Log Backups

• Oracle9i allows data files and archived logs to be backed up with one command with the PLUS ARCHIVELOG option of BACKUP.

• When backing up to tape, PLUS ARCHIVELOG is the default behavior.

• RMAN will not raise an error if there are no archive logs to backup.

• The BACKUP_COUNT column in V$ARCHIVED_LOGshows the number of times an archived log was backed up.

RMAN> BACKUP DATAFILE 4 PLUS ARCHIVELOG;

Backing Up Archived Logs Under Oracle9i, it is now possible to backup data files and archived logs with a single RMAN backup command. This new feature works as follows:

• The ALTER SYSTEM ARCHIVE LOG CURRENT command is run.• The BACKUP ARCHIVELOG ALL command is run. If backup optimization is enabled,

logs that are already backed up will be skipped.• Backs up data files specified in the BACKUP command• Runs the ALTER SYSTEM ARCHIVE LOG CURRENT command once again• Backs up any archived logs generated during the backup

If there are no archived logs to back up, RMAN will not raise an error. This condition is possible if no archived logs have been generated since the last BACKUP ARCHIVELOG ALLDELETE INPUT command was issued. Query V$ARCHIVED_LOG and inspect the BACKUP_COUNT column to see the number of times an archived log was backed up.Backing Up Archived Logs That Need BackupsYou can use NOT BACKED UP n TIMES clause of the BACKUP ARCHIVELOG command to back up only those logs that have not been backed up at least n times. This option is a convenient way to back up archived logs on specified media (for example, you want to keep at least three copies of each log on tape). This behavior is new to Oracle9i Release 2.

Oracle In

ternal & O

AI Use

Only

Page 122: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-36

Copyright © Oracle Corporation, 2002. All rights reserved.

Archivelog Backup Methods• By time:

• By name:

• By archived logs:

• By log sequence:

• By SCN:

RMAN> backup archivelog from time ‘01-jan-00’ until time ‘30-jun-00’;

RMAN> backup archivelog like ‘oracle/arc/dest/log%’;

RMAN> backup archivelog all;

RMAN> backup archivelog from logseq 20 until logseq 50 thread 1;

RMAN> backup archivelog from scn 1 until scn 9999;

Archived Log Backup MethodsArchived logs can be backed up by many methods. These include specifying archivelog by time, by log sequence and by SCN. The DELETE INPUT option can be used to delete logs from disk after they have been successfully backed up. For example:backup format ‘al_%t_%s_%p’ archivelog all delete input;

Please note that only the archivelog backed up is deleted. This is an issue for multiple archivelog destinations.

Oracle In

ternal & O

AI Use

Only

Page 123: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-37

Copyright © Oracle Corporation, 2002. All rights reserved.

Long Term Backups

• It is possible to archive backups much longer than the restrictions enforced by the retention policy.

• Enabled with the KEEP option to the BACKUPcommand:

• The default behavior is NOKEEP.• The NOLOGS option cannot be used in conjunction

with online backups.

BACKUP ...KEEP [UNTIL TIME 'date'|forever][NOLOGS|LOGS];

Long Term BackupsUnder Oracle9i the KEEP option can be used with the CHANGE, COPY, or BACKUPcommands to allow the backups to be kept until the time specified by the UNTIL TIMEoption regardless of the retention policy.If the backup should never expire, 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, 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 the window defined by the retention policy. Some examples:RMAN> BACKUP DATABASE KEEP UNTIL TIME "to_date('31-MAR-2002','DD_MM_YYYY)" nologs;

RMAN> BACKUP TABLESPACE SAMPLE KEEP FOREVER NOLOGSOracle In

ternal & O

AI Use

Only

Page 124: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-38

Copyright © Oracle Corporation, 2002. All rights reserved.

Test Backups Using RMAN

• The BACKUP...VALIDATE command can be used to perform test backups.

• Check data files for physical and logical corruption.

• Confirm that all database files exist and are in the correct locations.

BACKUP VALIDATE DATABASE;

Test Backups Using RMANRMAN does not actually produce backup sets, but scans the specified files to determine whether they can be backed up. In this sense, the BACKUP VALIDATE command is similar to the RESTORE VALIDATE command, except for backups rather than restore jobs.For example, you can validate that all database files and archived redo logs can be backed up by issuing a command as follows:RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL;

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 BACKUP…VALIDATE 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.

Oracle In

ternal & O

AI Use

Only

Page 125: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-39

Test Backups Using RMAN (continued)RMAN displays the same output that it would if it were really backing up the files. If RMAN cannot validate the backup of one or more of the files, then it displays an error message. For example, RMAN may show output similar to the following:RMAN-00571: =====================================================RMAN-00569: ============ ERROR MESSAGE STACK FOLLOWS =============RMAN-00571: ======================================================RMAN-03002: failure of backup command at 03/15/2002 14:33:47ORA-19625: error identifying file /u01/usr02/arch/archive1_5.dbfORA-27037: unable to obtain file statusSVR4 Error: 2: No such file or directoryAdditional information: 3

Oracle In

ternal & O

AI Use

Only

Page 126: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-40

Copyright © Oracle Corporation, 2002. All rights reserved.

Restarting a Backup

• With the introduction of Oracle9i, RMAN can restart partially completed backups.

• The SINCE TIME parameter can be used to specify a date after which a new backup is required.

• The unit of restartability is the backup set.• RMAN will compare the SINCE TIME date with the

completion time of the last backup of the file.

RMAN> BACKUP DATABASE NOT BACKED UP UP SINCE 2> TIME '03-MAR-02 09:00:00';

Restarting a BackupUsing 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 partway through and you only want to back up the part of the database that did not finish.. 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 only back up 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.Oracle

Internal &

OAI U

se O

nly

Page 127: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-41

Copyright © Oracle Corporation, 2002. All rights reserved.

Default Autolocation for Oracle Real Application Clusters

RMAN can autolocate the following files in an Oracle Real Application Clusters environment:• Backup pieces during backup or restore• Archived redo logs during backup• Data file or control file copies during backup or

restore

Default Autolocation for Real Application ClustersWith the introduction of Oracle9i Release 2, RMAN now automatically discovers which nodes of an Oracle Real Application Clusters configuration can access the files that you want to back up or restore. RMAN can autolocate the following files:

• Backup pieces during backup or restore• Archived redo logs during backup• Data file or control file copies during backup or restore

RMAN detects the Real Application Clusters environment whenever the allocated channels have different PARMS or CONNECT strings. RMAN will then automatically enable the autolocation feature. Prior to Oracle9i Release 2, you had to enable this option manually with SET AUTOLOCATE and the option applied only to backup pieces.

Oracle In

ternal & O

AI Use

Only

Page 128: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-42

Copyright © Oracle Corporation, 2002. All rights reserved.

Summary

In this lesson, you should have learned how to:• Identify the types of backups 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 and

cumulative incremental backup• Outline the Recovery Manager backup algorithm• Demonstrate a working knowledge of the BACKUP

command functionality

Oracle In

ternal & O

AI Use

Only

Page 129: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 3-43

Copyright © Oracle Corporation, 2002. All rights reserved.

Practice Overview: Backups With Recovery Manager

This practice covers the following topics:• Creating a cold backup• Using the CATALOG command• Creating RMAN backups

Oracle In

ternal & O

AI Use

Only

Page 130: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 131: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Copyright © Oracle Corporation, 2002. All rights reserved.

Restore and Recovery with RMAN

Oracle In

ternal & O

AI Use

Only

Page 132: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-2

Copyright © Oracle Corporation, 2002. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:• Identify tasks performed by RMAN before

restoring • Understand important RESTORE functionality• Understand the restore algorithm used by RMAN• Identify the four distinct phases of recovery using

RMAN• Understand important RECOVER functionality

Oracle In

ternal & O

AI Use

Only

Page 133: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-3

Copyright © Oracle Corporation, 2002. All rights reserved.

The RESTORE Command

The RESTORE command can restore the following types of files from image copies on disk or other media:• Database (all data files)• Tablespaces• Data files• Control files• Archived redo logs• Server parameter files

The RESTORE Command You use the RESTORE command to restore files from backups or image copies. RMAN canrestore an entire database, a tablespace, a data file, or a control file. By default, RMAN restores files to their default location. You can use the SET NEWNAME command to restore files to nondefault locations. RMAN restores backups from disk or tape and restores image copies from disk only. Typically, you restore when a media failure has damaged a current data file, control file, or archived log or prior to performing a point-in-time recovery. The RESTORE command restores full backups, incremental backups (level 0 only), or copies of data files, control files, and archived redo logs. Because the RECOVER command automatically restores archived logs as needed, you should seldom need to restore logs manually.

Oracle In

ternal & O

AI Use

Only

Page 134: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-4

Copyright © Oracle Corporation, 2002. All rights reserved.

Steps in the RESTORE Process

• RESTORE reads only what is needed to restore the required files.

• Allocates memory structures and buffers for each file being restored

• Continues to read the backup set until all file headers for all files being restored have been read

• Decides whether to restore blocks• Checks for corruption and replaces backup set-

relative file numbers with correct RDBA file numbers

Steps in the RESTORE ProcessWhen performing a restore, RMAN initially allocates memory structures and buffers it anticipates will be needed for the operation. The headers of the files to be restored are read and recovery decisions are made. The backup set relative-file number in the data block address is then replaced with the tablespace relative-file number. If RMAN is restoring a data file backup set, unused block ranges are identified and re-created. When each output buffer is filled, it is sent to the output device. Input buffers and output buffers do not need to be in sync. Many input buffers can be processed before an output buffer is filled. The file header is restored last to ensure that a partially restored file cannot be accidentally used.RMAN can tell if a file has not been completely restored. It knows how many pieces are in the set. If all pieces in the set are completely read and the file header is not encountered, DBMS_BACKUP_RESTORE requests another piece, which RMAN knows does not exist.

Oracle In

ternal & O

AI Use

Only

Page 135: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-5

Copyright © Oracle Corporation, 2002. All rights reserved.

File Selection When Restoring

• RMAN selects the best available backup sets or image copies when restoring.

• RMAN uses the most current backup sets or copies if there is more than one choice.– Can be limited by the UNTIL clause

• The RESTORE command searches for backups or copies only on configured channels.– This can be overridden by including a DEVICE TYPE

clause

RUN {SET UNTIL TIME ’23-JUN-2002 00:00:00’;...}

File Selection When RestoringRMAN uses the repository to select the best available backup sets or image copies for use in the RESTORE operation. It gives preference to image copies rather than backup sets. When multiple choices are available, RMAN uses the most current backup sets or copies, taking into account whether you specified an UNTIL clause in the RESTORE command.All specifications of the RESTORE command must be satisfied before RMAN restores a backup set or file copy. Unless limited by the DEVICE TYPE clause, the RESTOREcommand searches for backups and copies on all device types of configured channels.If no available backup or copy in the repository satisfies all the specified criteria, then RMAN returns an error during the compilation phase of the restore job. If you manually allocate channels, and the file cannot be restored because no backup sets or data file copies exist on the device types allocated in the job, then create a new job specifying channels for devices containing the existing backup sets or copies. This problem does not occur when you configure automatic channels.

Oracle In

ternal & O

AI Use

Only

Page 136: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-6

Copyright © Oracle Corporation, 2002. All rights reserved.

Restore Optimization

• RMAN under Oracle9i does not restore a file if the header check succeeds and it is in the right location.

• The FORCE option of the RESTORE command overrides this behavior.

• Restore optimization only verifies the file header and does not inspect the file for corrupted blocks.

Restore OptimizationIn releases prior to Oracle9i, RMAN always restored the requested files. In Oracle9i, RMAN only restores a file if the header check does not succeed. This is now the default behavior. 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 today, this time-saving feature is extremely important.

Oracle In

ternal & O

AI Use

Only

Page 137: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-7

Copyright © Oracle Corporation, 2002. All rights reserved.

Restore Concepts

RMAN performs several tasks prior to the restore process:• Queries the recovery catalog:

– To determine the configuration of the database– Identify the backups available for use

• Decides what backups are optimal to restore the specified files

• Compiles lists of files to restore, taking into consideration the following items: – Time specifications (point-in-time restore)– Any tags specified by users

Oracle In

ternal & O

AI Use

Only

Page 138: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-8

Copyright © Oracle Corporation, 2002. All rights reserved.

Restoring Data Files and Tablespaces

• Restore data file backups and copies to either:– The default location, overwriting the files with the

same name currently there

– A new location set with the SET NEWNAME command

• Restore a tablespace:

RUN {SET NEWNAME FOR data file '/u01/oradata/tools01.dbf' TO '/tmp/tools01.dbf';RESTORE data file '/u01/oradata/tools01.dbf';}

RMAN> RESTORE data file '/u01/oradata/tools01.dbf';

RMAN> RESTORE TABLESPACE tools;

Restoring Data Files and TablespacesRMAN automates the procedure for restoring files. It is not necessary to copy files manually into the appropriate directories. When you issue a RESTORE command, RMAN directs a server session to restore the correct backups and copies to either:

• The default location, overwriting the files with the same name currently there• A new location, which you can specify with the SET NEWNAME command

To restore a data file, mount the database or keep it open and take the data file to be restored offline. SQL> alter database data file '/u01/oradata/tools01.dbf'offline;

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, 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 ortablespaces, the database can be up but the data files or tablespaces must be offline:RMAN> SQL "ALTER TABLESPACE tools OFFLINE IMMEDIATE";RMAN> RESTORE TABLESPACE tools;RMAN> RECOVER TABLESPACE tools; RMAN> SQL "ALTER TABLESPACE tools ONLINE";

Oracle In

ternal & O

AI Use

Only

Page 139: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-9

Copyright © Oracle Corporation, 2002. All rights reserved.

Restoring Archived Logs

To restore archived logs:

• Archived logs can be manually restored but generally, this is not needed.– RMAN automatically restores all archived logs that

are needed during the recovery phase.• Use SET ARCHIVELOG DESTINATION to override

the target database's LOG_ARCHIVE_DEST setting.

restore archivelog {all|like <filename>|<archivelog range>|… );

Restoring Archived LogsRMAN names the restored archived logs by using the LOG_ARCHIVE_FORMAT and the LOG_ARCHIVE_DEST_1 parameters of the target database. These parameters are combined in a port-specific fashion to derive the name of the restored archived log. It is possible to override the default names by using the SET ARCHIVELOG DESTINATIONcommand. This command allows manual staging of archived logs to different locations while a database restore is occurring. During recovery, RMAN knows where to find the restored archived logs. Connect to the target database and recovery catalog (if implemented), then start and open the database:RMAN> STARTUP;

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}

Oracle In

ternal & O

AI Use

Only

Page 140: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-10

Copyright © Oracle Corporation, 2002. All rights reserved.

Restoring the Server Parameter File

• Using a catalog:

• Without a catalog:

• To a nondefault location using a catalog:

• To a nondefault location without a catalog:

RMAN> RESTORE SPFILE;

RMAN> RESTORE SPFILE FROM AUTOBACKUP;

RMAN> RESTORE SPFILE TO'/tmp/spfileTEMP.ora';

RMAN> RESTORE SPFILE TO '/tmp/spfileTEMP.ora' FROM 2> AUTOBACKUP;

Restoring the Server Parameter FileRMAN can restore the server parameter file either to the default location or to a nondefault location. RMAN can also restore the server parameter file as a server parameter file or as a client-side initialization parameter (INIT.ORA) file. If the instance is already started with the server parameter file, then you cannot overwrite the existing server parameter file. If the SPFILE must be restored, connect to the target database and the recovery catalog database, if implemented. If you are connected to a catalog, and if the target database DB_NAME of the target database is not unique in the catalog, then set the DBID of the target database. For example:RMAN> SET DBID 676554321;

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, the steps are slightly different.Oracle

Internal &

OAI U

se O

nly

Page 141: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-11

Restoring the Server Parameter File (continued)If a catalog is being used, restore the SPFILE as shown below:RMAN> RESTORE SPFILE TO '/tmp/spfileTEMP.ora';

The SPFILE now resides in a location different than originally specified in the initialization parameter (INIT.ORA) file. Create a temporary one 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 INIT.ORA and SPFILE:RMAN> STARTUP FORCE PFILE=/tmp/init.ora;

Oracle In

ternal & O

AI Use

Only

Page 142: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-12

Copyright © Oracle Corporation, 2002. All rights reserved.

Parallelization of RESTORE

• Parallelization of RESTORE is controlled by:– The number of channels allocated – The number of backup sets that are required for

RESTORE

• This is true for full backups (level 0) as well as incremental backups of levels greater than 0.

• RMAN minimizes tape scanning by restoring files in the same order that they were backed up.

Parallelization of RESTOREIf there are multiple backup sets that need to be read to restore the whole database, it is faster to allocate an equal number of channels, thereby increasing the degree of parallelization. However, if there is only one backup set that needs to be read to restore the whole database, other channels would not be necessary and would not be used at all, even if allocated.

Oracle In

ternal & O

AI Use

Only

Page 143: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-13

Copyright © Oracle Corporation, 2002. All rights reserved.

Restoring the Database to a New Host

With RMAN, you can:• Create a duplicate version of the production

database • Test the restore of the production database to a

new host• Move the location of the production database to a

new host

Restoring the Database to a New Host RMAN supports several scenarios when restoring a database to a new host. For example, it is possible to:

• Create a duplicate version of the production database for testing or other purposes, while retaining the production database on the original host.

• Test the restore of the production database to a new host, while retaining the production database on the original host.

• Move the location of the production database to a new host. The target must be mounted or open to duplicate the database to the auxiliary database.

To create a duplicate database for testing while maintaining the original database, use the DUPLICATE command instead of the RESTORE command. RMAN automatically creates a unique database identifier for the duplicate database. To test the restore of a database to a new host or to move the database to a new host, run the RESTORE…DATABASE TESTcommand. If you perform a test restore only, then you should do the following to prevent overwriting the target records in the recovery catalog:

• Run RMAN in the default NOCATALOG mode when restoring the data files.• If you must use a recovery catalog, then export the catalog and import it into a

different schema or database and use the copied recovery catalog for the test restore.Oracle

Internal &

OAI U

se O

nly

Page 144: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-14

Copyright © Oracle Corporation, 2002. All rights reserved.

Restoring the Database to a New Host

• The target initialization parameter file must be available on the new host.

• The backups needed for the restore must be accessible on the new host.

• RMAN cannot restore the initialization parameter file, disk backups, or image copies to the new host.

• The restored database will not have the online redo logs of the production database.

• Do incomplete recovery up to the lowest SCN of the newest archived log in each thread.

• Open with RESETLOGS.

Restoring the Database to a New Host (continued)Make the target initialization parameter file accessible on the new host by copying it from the old host to a new host by using an OS utility like FTP. You must also make sure backups used for the restore are accessible on the restore host. For example, if the backups were made with a media manager, then make sure the tape device is connected to the new host.You cannot use RMAN to restore disk backups or image copies created on one host to a new host. Again, you can use an OS utility like FTP. If the files are in the same location in the new host, then you do not need to recatalog them. If you transfer the files to a new location, then use the CATALOG command to update the RMAN repository with the new filenames and use the CHANGE ... UNCATALOG command to uncatalog the old filenames.Because the restored database will not have the online redo logs of the production database, perform incomplete recovery up to the lowest SCN of the most recently archived log in each thread and then open with the RESETLOGS option. Obtain the SCN for recovery termination by finding the lowest SCN among the most recent archived logs for each thread.

Oracle In

ternal & O

AI Use

Only

Page 145: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-15

Restoring the Database to a New Host (continued)Start SQL*Plus and use the following query to determine the necessary SCN:SQL> SELECT MIN(SCN)

2 FROM (SELECT MAX(NEXT_CHANGE#) SCN3 FROM V$ARCHIVED_LOG4 GROUP BY THREAD#);

MIN(SCN)----------

4366578It is possible that you might encounter an RMAN-20240 error when attempting to duplicate a database to either a local or remote machine. A sample error stack excerpt is shown below:RMAN-03022: compiling command: recover(3)RMAN-03023: executing command: recover(3)RMAN-08054: starting media recoveryRMAN-08060: unable to find archivelogRMAN-08510: archivelog thread=1 sequence=6...RMAN-06038: recovery catalog package detected an errorRMAN-20242: specification does not match any archivelog in

the recovery catalogA common cause of this error is that the data file backups being used for the duplication are inconsistent. Most likely an ALTER SYSTEM ARCHIVE LOG CURRENTcommand was not executed after the data file backup 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;

}For more detailed information on handling database duplication errors, refer to WebIV Note:145620.1 “RMAN: Database Duplication Fails with RMAN-20240”.

Oracle In

ternal & O

AI Use

Only

Page 146: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-16

Copyright © Oracle Corporation, 2002. All rights reserved.

Create Standby Database with DUPLICATE

RMAN automates these steps of the database creation:• Restore the standby control file.• Restore the primary data file backups and copies.• Optionally, RMAN recovers the standby database

after the control file has been mounted up to:– The specified time – The latest archived redo log generated

• RMAN leaves the database mounted so the user can– Activate it – Place it in manual or managed recovery mode – Open it in read-only mode

Create Standby Database with DUPLICATEWhen you create a standby database, the procedure differs depending on whether the standby database is on the same host as the primary database or on a different host. These procedures assume that you have already completed the standby setup and preparation as outlined in Oracle9i Data Guard Concepts and Administration. Do not attempt these procedures until you have made all necessary initialization parameter settings and network configuration.After you have performed the steps necessary for preparing the standby instance, run the RMAN DUPLICATE...FOR STANDBY command to create the standby database out of backups of the primary database. Note that a standby database, unlike a duplicate database created by DUPLICATE without the FOR STANDBY OPTION, does not get a new DBID. Therefore, you should not attempt to register the standby database in the repository for the primary database. Some of the steps for creating the standby database differ depending on whether you specify that RMAN should recover the standby database after creating it. For a compete coverage of this topic, please refer to Oracle9i Recovery Manager User’s Guide.Note: It is possible that you may encounter problems creating the standby redo logs. This is Bug 2312344. Please see WebIV Note 185076.1 for a workaround. The bug has been corrected in Oracle9i Release 2.

Oracle In

ternal & O

AI Use

Only

Page 147: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-17

Copyright © Oracle Corporation, 2002. All rights reserved.

Validating Restore of Backups and Copies

• A restore validation executes a restore test without actually restoring the files

• The restore of the database, individual tablespaces, data files, or control files can be tested with the RESTORE…VALIDATE command.

• Backups or copies can be tested with the VALIDATE BACKUPSET command.

RMAN> RESTORE DATABASE VALIDATE;

RMAN> VALIDATE BACKUPSET 218;

Validating Restore of Backups and CopiesA restore validation executes a restore test run without actually restoring the files. You can test the restore of either the entire database or individual tablespaces, data files, or control files. The VALIDATE BACKUPSET command tests whether you can restore backups or copies. The RESTORE...VALIDATE command tests whether RMAN can restore a specific object from a backup or copy. RMAN chooses which backups or copies to use. The VALIDATE BACKUPSET command tests the validity of a backup set that you specify. Use VALIDATE BACKUPSET to specify which backups to test; use RESTORE...VALIDATE to let RMAN choose which backups to validate.To perform the validation, the database can be mounted or open. You do not have to take data files offline when validating them.1. Validate the restore of the backup sets and copies

This example validates the restore of the backup control file, SYSTEM tablespace, and all archived logs:RMAN> RESTORE CONTROLFILE VALIDATE;RMAN> RESTORE TABLESPACE SYSTEM VALIDATE;RMAN> RESTORE ARCHIVELOG ALL VALIDATE;

Oracle In

ternal & O

AI Use

Only

Page 148: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-18

Validating Restore of Backups and Copies (continued)2. Check the outputIf you see an error message stack and then the following message, then you do not have a backup or copy of one of the files that you are validating:RMAN-06026: some targets not found - aborting restore

If you see an error message stack and output similar to the following, for 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:30ORA-19505: failed to identify file "oracle/dbs/1fafv9gl_1_1"ORA-27037: unable to obtain file statusSVR4 Error: 2: No such file or directoryAdditional information: 3

If you do not see an error stack, then RMAN successfully validated the files.

Oracle In

ternal & O

AI Use

Only

Page 149: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-19

Copyright © Oracle Corporation, 2002. All rights reserved.

Restore Autolocation

• Under Oracle9i, RMAN discovers which nodes of an Oracle Real Application Clusters configuration contain the backups you want to restore.

• RMAN searches for files on all configured channels and restores files from those channels only.

• Autolocation is enabled automatically when the channels use:– Different PARMS settings– Different connect strings

Restore AutolocationIn 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 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

Oracle In

ternal & O

AI Use

Only

Page 150: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-20

Copyright © Oracle Corporation, 2002. All rights reserved.

Restore When All Is Lost

• Write a PL/SQL procedure that makes calls to DBMS_BACKUP_RESTORE.

• If target database used a recovery catalog and the catalog is lost, restore the recovery catalog first.

• If the only available backups are in the media manager, you must know the backup piece name for the control file backup.

Restoring When All Is LostWhat happens if the recovery catalog and target database are both lost or the target database and all control files are lost and no recovery catalog is used? Write a PL/SQL ProcedureA PL/SQL procedure will need to be written that makes calls to DBMS_BACKUP_RESTORE. In most cases, the procedure does not have to restore the entire lost database. It simply needs to restore a control file that contains records for the required backups. Then mount the control file and use RMAN to restore the database. $ORACLE_HOME/rdbms/admin/dbmsbkrs.sql contains descriptions of all DBMS_BACKUP_RESTORE functions.Does the Target Database Use a Recovery Catalog?If the target database used a recovery catalog, and the recovery catalog is lost, then the first priority is to restore the recovery catalog.

Oracle In

ternal & O

AI Use

Only

Page 151: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-21

Restore When All Is Lost (continued)Backups in Media ManagerIf the only available backups are in the media manager, you must know the backup piece name for the control file backup. The easiest way to find this is to look at the log from the most recent backup. If that is not available, most media managers have a way to list the backup piece names in their catalog, but if no listings are available, you will have to find a control file by trial and error.The procedure below can be used to restore a control file. The instance must be started, but not mounted to execute this procedure.declare

devtype varchar2(100);done boolean;recid number;stamp number;fullname varchar2(80);

begindevtype :=

dbms_backup_restore.deviceallocate('sbt_tape',params=>'ENV=(NSR_SERVER=backup_server)');

dbms_backup_restore.restoresetdata file;dbms_backup_restore.restorecontrolfileto(

'first_control_file');dbms_backup_restore.restorebackuppiece('backup_piece',

done);dbms_backup_restore.copycontrolfile

('first_control_file', 'second_control_file', recid, stamp,fullname);

-- repeat the above copycontrolfile for each control fileend; /

Support NoteNote: 60545.1 “How to Extract Control Files, Data Files, and Archived Logs from SMR Backupsets” describes in great detail the process of manually extracting objects from RMAN backups.

Oracle In

ternal & O

AI Use

Only

Page 152: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-22

Copyright © Oracle Corporation, 2002. All rights reserved.

Recovery Types

• Complete recovery– A recovery where all changes made to the database

since the restored backup have been applied (including changes recorded in the online redo logs)

• Incomplete Recovery– A recovery where the recovery is stopped before all

changes made to the database since this backup was applied

Recovery TypesThe concept of data file media recovery is the application of online or archived redo logs or incremental backups to a restored data file in order to update it to the current time or some other specified time. Use the RMAN RECOVER command to perform media recovery and apply logs or incremental backups automatically. For our purposes, recovery fall under two categories; complete recovery and incomplete recovery. Incomplete recoveries are performed:

• To undo a user error (recover to the point-in-time before the error occurred)• When all redo information to complete the recovery is not available • When the online logs are lost, and are not mirrored

A “time” to recover to may be specified as a time, log sequence number, or SCN. Time and log sequence are first resolved to an SCN before recovery is done. All files must be recovered to the same point-in-time.

Oracle In

ternal & O

AI Use

Only

Page 153: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-23

Copyright © Oracle Corporation, 2002. All rights reserved.

Recovery Concepts

• If the database is in ARCHIVELOG mode, it is possible to:– Completely recover the database– Recover the database to any arbitrary point-in-time

(incomplete recovery)• For NOARCHIVELOG mode databases, recovery is

not usually possible.• If a database is closed during recovery, all the files

must be consistent before the database can be opened.

Recovery ConceptsARCHIVELOG ModeIf the database is in ARCHIVELOG mode, it is possible to either completely recover the database, or recover the database to any arbitrary point-in-time (incomplete recovery).NOARCHIVELOG ModeFor NOARCHIVELOG mode databases, complete recovery is not usually possible. The only option is to restore from a consistent whole database backup. State of Database and RecoveryIf a database is closed during recovery, all files in that database must be consistent with each other before the database can be opened. If a database is open during a tablespace or data file recovery, the tablespace or data file must be consistent with the remaining data files before it can be brought online (implying that incomplete recovery is not possible in this scenario).

Oracle In

ternal & O

AI Use

Only

Page 154: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-24

Copyright © Oracle Corporation, 2002. All rights reserved.

Basic RMAN Media Recovery

RMAN basic media recovery steps:1. Place the database in the appropriate state.

– Mount the database when recovering whole database.

– Open the database for online tablespace recovery.2. For incomplete recovery, use SET UNTIL to

specify the time, SCN, or log sequence number at which recovery terminates.

3. Restore necessary files using the RESTOREcommand.

4. Recover the data files using the RECOVERcommand.

5. Place the database in its normal state.

Basic RMAN Media RecoveryIf possible, make the recovery catalog available to perform the media recovery. If it is not available, then RMAN uses metadata from the target database control file. If both the control file and recovery catalog are lost, then you can still recover the database—assuming that you have backups of the data files and at least one autobackup of the control file. Consider the following example of RMAN media recovery. The DBA runs the following commands:RESTORE DATABASE;

RECOVER DATABASE;

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.

Oracle In

ternal & O

AI Use

Only

Page 155: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-25

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Recovery Phases

• RMAN divides the RECOVER functions into four distinct phases: – RCV1: Fix the control file and switch to using data

file copies– RCV2: Apply incremental backups– RCV3: Apply all redo on disk– RCV4: Restore archivelogs and apply redo until

complete• These phase tags appear often in RMAN

debugging output.

RMAN Recovery PhasesRMAN performs recovery in four phases. These can be identified by the tags RCV1, RCV2, RCV3, RCV4 in the RMAN Log.RCV1 (Phase 1) During RCV1, the backup control file is inspected and updated, if necessary. Without doing this, recovery would stop whenever it detects that a new data file was added to the database. The DBMS_BACKUP_RESTORE.SWITCHTOCOPY procedure is used to update the control file. Next, implicit switches are performed if required. For example, when the user indicates “restore data file 3,” and the name of the file in the control file does not agree with the name for that file in the recovery catalog, RMAN will automatically execute a SET NEWNAME command for that data file.RCV2 (Phase 2)Check for any incremental backups and offline ranges that can be applied. Incremental backups are applied to a level 0 or full backup. If an incremental backup cannot be found, then the control file view V$ARCHIVED_LOG is searched for the names of archived redo logs to use for recovery. Oracle

Internal &

OAI U

se O

nly

Page 156: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-26

RMAN Recovery Phases (continued)RCV3 (Phase 3)Oracle records an archived log in the control file whenever one of the following occurs:

• The archiver process archives a redo log• RMAN restores an archived log• The RMAN COPY command copies a log• The RMAN CATALOG command catalogs a user-managed backup of an archived

logOffline files are always skipped and read-only files are always skipped (provided the headers are correct) unless CHECK READONLY is specified. RCV4 (Phase 4)If the RMAN repository indicates that no copies of a needed log sequence number exist on disk, then RMAN looks in backups and restores archived redo logs as needed to perform the media recovery. By default, RMAN restores the archived redo logs to the first local archiving destination specified in the initialization parameter file. If the DELETEARCHIVELOG option was specified, then the archived logs are deleted after restoring and applying them.The media recovery session always runs on the default channel, but the ARCHIVELOGrestore steps can run on any channel, and will take advantage of parallelism if more than one channel is allocated.

Oracle In

ternal & O

AI Use

Only

Page 157: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-27

Copyright © Oracle Corporation, 2002. All rights reserved.

Parallelization of Recovery

• The parallelization of applying incremental backups is controlled by:– The number of channels allocated – The number of incremental backup sets needed for

recovery • Redo Application

– Can be parallelized by setting the INIT.ORAparameter RECOVERY_PARALLELISM

– RMAN will restore archived redo logs automatically as they are required.

– Alternatively, archived logs can be manually restored to disk in preparation for recovery.

Oracle In

ternal & O

AI Use

Only

Page 158: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-28

Copyright © Oracle Corporation, 2002. All rights reserved.

Incomplete Database Recovery

• Incomplete recovery is stopped before the database is fully recovered to its current state.

• Also known as database point-in-time recovery (DBPITR).

• DBPITR is typically performed when a user error requires the database to be recovered to a point-in-time before the error occurred.

• The database backup used by the restore must have completed before the time being recovered to.

Incomplete Database RecoveryRMAN can perform recovery of the database to a past time, SCN, or log sequence number. This is called incomplete recovery because it does not use all of the available redo. Incomplete database recovery is also called database point-in-time recovery (DBPITR).Incomplete recovery of the database requires you to open the database with the RESETLOGS option. This option gives the online redo logs a new time stamp and SCN, eliminating the possibility of corrupting data files by the application of obsolete archived redo logs. You cannot recover some data files before the RESETLOGS and others after the RESETLOGS. You must recover all data files. The only exception is if the data file is offline normal or read-only. You can bring files in read-only or offline normal tablespaces online after the RESETLOGS because they do not need any redo. The easiest method to perform DBPITR is to use the SET UNTIL command because it sets the desired time for any subsequent RESTORE, SWITCH, and RECOVER commands in the same RUN job. If you specify a SET UNTIL after a RESTORE and before a RECOVER, it may not be possible to recover the database to the desired point in time because the restored files may already have time stamps more recent than the set time. It is recommended that you specify the SET UNTIL command before the RESTOREcommand.

Oracle In

ternal & O

AI Use

Only

Page 159: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-29

Copyright © Oracle Corporation, 2002. All rights reserved.

Block Media Recovery

• Oracle9i introduced block media recovery (BMR).• A block is the smallest unit of restore and

recovery.• BMR lowers the mean time to recover (MTTR).• BMR increases availability during media recovery• RMAN must be used for BMR:

– Restores individual data blocks from available backups

– Coordinates with the server to have them recovered

Tape

Block Media RecoveryBlock media recovery (BMR) reduces the smallest recoverable unit of media recovery from a data file to a block. When a small number of blocks in the database are known to require media recovery, it is more efficient to selectively restore and recover just those blocks. Only blocks being recovered need to be unavailable, allowing continuous availability of the rest of the database during recovery. Block media recovery (BMR) provides two main benefits over file-level recovery:

• Lowering the mean time to recover (MTTR)• Allowing increased availability of data during media recovery as the data file being

recovered remains online.BMR uses existing recovery mechanisms to apply changes from the redo stream to block versions restored from suitable backups. RMAN must be used to perform BMR. RMAN restores individual data blocks from available backups and coordinates with the Oracle server process to have them recovered. Without block-level recovery, if even a single block is corrupt, the entire file must be restored and all redo changes generated for that file because backup must be applied. The reduction in MTTR realized by using block-level recovery includes both restore and recovery time. Note that only complete recovery is possible. Incomplete recovery would render the database logically inconsistent.Oracle

Internal &

OAI U

se O

nly

Page 160: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-30

Copyright © Oracle Corporation, 2002. All rights reserved.

Other BMR Benefits

• Increased availability during media recovery:– The data file where the blocks are being recovered

remains online.– Only blocks undergoing media recovery are

inaccessible.• Ability to skip over missing or corrupt redo:

– Corrupted redo records are ignored if they do not pertain to blocks being recovered.

– BMR defers signaling stuck recovery failure because missing redo changes may refer to a block that could be renewed later in the redo stream.

Other BMR BenefitsData blocks undergoing media recovery are inaccessible to queries or DML because they are media corrupt, but the data file itself remains online. This is a significant availability improvement over file-level recovery, where the entire data file is offline for the duration of the recovery.BMR may be able to survive gaps in the redo stream if it is evident that the missing redo records do not pertain to blocks being recovered. This does not help if the redo stream is unreadable, but provides some degree of fault tolerance to missing or corrupt redo records. BMR requires an unbroken set of redo changes only for the blocks being recovered, which is a weaker requirement than the unbroken redo stream currently required by data file/database media recovery. Failure status for each block in the set being recovered is independent, so BMR may be successful for a subset of the recovery set. BMR can defer signaling stuck recovery failure when missing redo changes are first detected. When a block is renewed all previous redo for that block becomes irrelevant, because the redo applies to a defunct incarnation of the block. BMR can optimistically defer failure if a redo change needed for a block is missing or corrupt, because the block may be renewed at some later point in the redo stream. For example, the Oracle server can renew a block when users delete all the rows recorded in the block or drop the table.

Oracle In

ternal & O

AI Use

Only

Page 161: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-31

Copyright © Oracle Corporation, 2002. All rights reserved.

The BLOCKRECOVER Command

• BMR is implemented through the RMAN BLOCKRECOVER command.

• Identifies the backups from which to obtain the blocks to recover

• Reads the backups and accumulates requested blocks into in-memory buffers

• Starts and manages the block media recovery session, reading the archive logs from backup if necessary

RMAN> BLOCKRECOVER data file 6 BLOCK 3;

The RMAN BLOCKRECOVER CommandRMAN supports BMR by means of the new BLOCKRECOVER command. When the user encounters a block corruption the error message or the trace files indicate which block is causing problems. The DBA can then invoke this command to restore only the block in question saving an enormous amount of down time and data unavailability.The BLOCKRECOVER command does the following:

• Identifies the backups from which to obtain the blocks to recover• Reads the backups and accumulates requested blocks into in-memory buffers. If any

of the desired blocks are corrupt (either media or logical corruption), RMAN reads the next oldest backup of that file, looking for a good copy of the block. The UNTILoption limits selection to backup sets or file copies taken at or before the specified time, SCN, or log sequence; this forces BLOCKRECOVER to use an older backup instead of the most recent one.

• Starts and manages the block media recovery session, reading archive logs from backup if necessary.

• Always does a complete recovery. No point-in-time recovery is possible using the BLOCKRECOVER command.Oracle

Internal &

OAI U

se O

nly

Page 162: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-32

The RMAN BLOCKRECOVER Command (continued)Block media recovery is most useful for data losses that affect specific blocks. Typically, this type of block corruption is reported in these locations:

• Oracle error messages in standard output • The alert log • User trace files • Results of the SQL ANALYZE TABLE and ANALYZE INDEX commands • Results of the dbverify utility • Third-party media management output

Block-level data loss usually results from: • Intermittent, random I/O errors that do not cause widespread data loss • Memory corruptions that get written to disk

For example, you may discover the following messages in a user trace file: ORA-01578: ORACLE data block corrupted (file # 6, block # 3)ORA-01110: data file 6: '/oracle/dbs/tbs_71.f'ORA-01578: ORACLE data block corrupted (file # 2, block # 235)ORA-01110: data file 2: '/oracle/dbs/tbs_21.f‘

You can then specify the corrupt blocks in the BLOCKRECOVER command as follows: RMAN> BLOCKRECOVER data file 6 BLOCK 3 data file 2 BLOCK 235;

Oracle In

ternal & O

AI Use

Only

Page 163: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-33

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN BMR Interface

• The list of corrupted database blocks is stored in the V$DATABASE_BLOCK_CORRUPTION view.

• The CORRUPTION LIST clause specifies the recovery of all blocks listed in this view.

• RMAN lists corruptions in backup sets and proxy copies in two views:– V$BACKUP_CORRUPTION

– V$COPY_CORRUPTION

RMAN> BLOCKRECOVER CORRUPTION LIST RESTOREUNTIL TIME 'sysdate – 10';

RMAN BMR InterfaceUsing the CORRUPTION LIST clause in Oracle9i recovers blocks listed in V$DATABASE_BLOCK_CORRUPTION. After a block has been repaired through block media recovery (or normal media recovery), V$DATABASE_BLOCK_CORRUPTIONwill not be updated until you take a new backup. The UNTIL clause specifies that only backups and copies created before the specified time, SCN, or log sequence number should be restored and used for the recovery.Two types of corruption result in rows being added to V$BACKUP_CORRUPTION and V$COPY_CORRUPTION by the BACKUP and COPY commands respectively:

• Physical corruption (sometimes called media corruption). The Oracle server does not recognize the block at all: the checksum is invalid, the block contains all zeros, or the header and footer of the block do not match. Physical corruption checking is ON by default, and can be turned off with the NOCHECKSUM option.

• Logical corruption. The block has a valid checksum, the header and footer match, and so forth, but the contents are logically inconsistent. Logical checking is OFF by default, and can be turned on with the CHECK LOGICAL option.Oracle

Internal &

OAI U

se O

nly

Page 164: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-34

Copyright © Oracle Corporation, 2002. All rights reserved.

Trial Recovery

• In Oracle9i, trial recovery is invoked by adding the TEST option to any restore command:

– Errors are reported in the alert log.• Media recovery can mark a data block corrupt if

required to proceed.

– The alert log indicates if the problem can be skipped.

• The database is left in a consistent state and when recovery stops, the database can always be opened.

RMAN> RECOVER DATABASE ALLOW 1 CORRUPTION;

RMAN> RECOVER DATABASE USING BACKUP CONTROLFILE TEST;RMAN> RECOVER TABLESPACE sales TEST;RMAN> RECOVER DATABASE UNTIL CANCEL TEST

Trial RecoveryIn the past, some problems that can 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, recovery always leaves behind a consistent database, 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 in order to investigate if a recovery problem is an isolated problem.

With these enhancements, almost all practical problems during media recovery are recoverable thanks to an optimistic redo application algorithm. Recovery optimistically assumes that no problem will occur during media recovery. If one does occur, the Oracle server will rollback 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.

Oracle In

ternal & O

AI Use

Only

Page 165: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-35

Copyright © Oracle Corporation, 2002. All rights reserved.

Tablespace Recovery Example

$ rman target internal/secret@prod rcvcat rman/rman@rcat

RMAN> run {2>allocate channel t1 type 'sbt_tape';3>sql 'alter tablespace sample 4> offline immediate';5> restore tablespace sample;6> recover tablespace sample;7> sql 'alter tablespace sample online';8> }

Tablespace Recovery Example This example illustrates the restoration and recovery of all files in the SAMPLEtablespace. In this scenario, a channel is manually allocated. Assume the database is open.

Oracle In

ternal & O

AI Use

Only

Page 166: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-36

Copyright © Oracle Corporation, 2002. All rights reserved.

Recover Database Example

To recover the database with an autobackup of the control file without a recovery catalog:1. Start RMAN and connect to the target database.2. Start the target instance but don’t mount the

database.3. Set the database identifier for the target database. 4. Restore the autobackup control file, then perform

recovery.5. Open the database and reset the online logs.6. Back up the database.

Database Recovery Example1. Start RMAN and connect to the target database. For example, run:

RMAN> CONNECT TARGET /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 recentbackup 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. If the autobackup was created on a disk channel, however, then you do not need to allocate a channel manually.Oracle

Internal &

OAI U

se O

nly

Page 167: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-37

Database Recovery Example (continued)Restore the autobackup of the control file and mount the database. Because the repository is now available, any automatic channels that you configured are also available. If the online logs are inaccessible, then restore and recover the database. You must terminate recovery by setting the UNTIL clause to a time, log sequence, or SCN before the online redo logs. In this example, the online redo logs have been lost. This example limits the restore of the control file autobackup, then performs recovery of the database to log sequence 13243, which is the most recent archived log:RMAN> RUN {# Optionally, set upper limit for time stamps of control file # backups# SET UNTIL TIME ’03/10/2002 13:45:00’;# Specify a nondefault autobackup format only if required# SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO# ’?/oradata/%F.bck’;# manually allocate one or more channels2> ALLOCATE CHANNEL c1 DEVICE TYPE sbt; 3> RESTORE CONTROLFILE FROM AUTOBACKUP4> MAXSEQ 100 # start at sequence 100 and count down5> MAXDAYS 180; # start at UNTIL TIME and search back 6 months6> ALTER DATABASE MOUNT DATABASE;7> }# use automatic channels configured in restored control fileRMAN> RESTORE DATABASE UNTIL SEQUENCE 13243;RMAN> RECOVER DATABASE UNTIL SEQUENCE 13243;

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> SHUTDOWN IMMEDIATERMAN> STARTUP MOUNTRMAN> BACKUP DATABASE;RMAN> ALTER DATABASE OPEN;

Oracle In

ternal & O

AI Use

Only

Page 168: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-38

Copyright © Oracle Corporation, 2002. All rights reserved.

Recover a NOARCHIVELOGDatabase 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.

Recovering a Database in NOARCHIVELOG Mode: ExampleA NOARCHIVELOG database can be recovered with consistent incremental backups. Assume the database has a media failure on Saturday, destroying half of the data files as well as the online redo logs. In this case, you must perform an incomplete media recovery until Friday, because that is the date of the most recent incremental backup. RMAN uses the level 0 Sunday backup as well as the Wednesday and Friday level 1 backups.Because the online redo logs are lost, you must specify the NOREDO option in the RECOVER command. You must also specify NOREDO if the online logs are available but the redo cannot be applied to the incrementals. If the online logs had been available, then you could have run RECOVER DATABASE without specifying NOREDO. Connect to TRGT and the catalog and recover the database using the following command:STARTUP FORCE MOUNT;RESTORE CONTROLFILE; # restore control file from consistent backupALTER DATABASE MOUNT;RESTORE DATABASE; # restore datafiles from consistent backupRECOVER DATABASE NOREDO; # specify NOREDO online redos are lostALTER DATABASE OPEN RESETLOGS;All changes generated between the Friday incremental backup and the Saturday failure are not applied.

Oracle In

ternal & O

AI Use

Only

Page 169: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-39

Copyright © Oracle Corporation, 2002. All rights reserved.

DBPITR Example

Database Point-In-Time Recovery$ rman target internal/secret@prod rcvcat rman/rman@rcat

RMAN> startup nomount

RMAN> run {2> set until time "to_date('2002/02/23 16:00:00',

3> 'YYYY/MM/DD HH24:MI:SS')";4> allocate channel t1 type 'SBT_TAPE';

5> allocate channel t2 type 'SBT_TAPE';

6> restore controlfile;7> sql 'alter database mount';

8> restore database;9> recover database;

10> }

DBIPTR ExampleThe above example illustrates the restore of the whole database, including control file (to the original locations) until time ‘2002/02/23 16:00:00’. This example assumes the database is stopped. Note the startup command is done from RMAN.

Oracle In

ternal & O

AI Use

Only

Page 170: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-40

Copyright © Oracle Corporation, 2002. All rights reserved.

BLOCKRECOVER Examples

1. Recovering a group of corrupt blocks2. Limiting block media recovery by type of restore3. Limiting block media recovery by backup tag4. Limiting block media recovery by time, SCN, or log

sequence

BLOCKRECOVER Examples1. 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 data file 3 BLOCK 1,2,3,4,5TABLESPACE sales DBA 4194405, 4194409, 4194412FROM data fileCOPY;

}3. Limiting BMR by backup tag

BLOCKRECOVER TABLESPACE SYSTEM DBA 4194404, 4194405 FROM TAG "weekly_backup";

4. The following example recovers two blocks in the SYSTEM tablespace and forces the blocks to be restored from backups created at least two days ago:BLOCKRECOVER TABLESPACE SYSTEM DBA 4194404, 4194405 RESTORE UNTIL TIME 'SYSDATE-2';Oracle

Internal &

OAI U

se O

nly

Page 171: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-41

BLOCKRECOVER Examples (continued)The following example recovers two blocks and forces the blocks to be restored using backups made before SCN 100:BLOCKRECOVER data file 9 BLOCK 13 data file 2 BLOCK 19 RESTORE UNTIL SCN 100;

The following example recovers two blocks and forces the blocks to be restored using backups made before log sequence 7024:BLOCKRECOVER data file 9 BLOCK 13 data file 2 BLOCK 19 RESTORE UNTIL SEQUENCE 7024;

Oracle In

ternal & O

AI Use

Only

Page 172: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-42

Copyright © Oracle Corporation, 2002. All rights reserved.

Summary

In this lesson, you should have learned how to:• Identify tasks performed by RMAN before

restoring • Understand important RESTORE functionality• Understand the restore algorithm used by RMAN• Identify the four distinct phases of recovery using

RMAN• Understand important RECOVER functionality

Oracle In

ternal & O

AI Use

Only

Page 173: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 4-43

Copyright © Oracle Corporation, 2002. All rights reserved.

Practice Overview: Restore and Recovery with RMAN

This practice covers the following topics:• Familiarity with DBMS_BACKUP_RESTORE• Complete recovery from a total failure• Incomplete recovery to some time in the past

Oracle In

ternal & O

AI Use

Only

Page 174: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 175: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Maintenance

Oracle In

ternal & O

AI Use

Only

Page 176: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-2

Copyright © Oracle Corporation, 2002. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:• Use the LIST command to display backup data

recorded in the catalog or target control file• Use the REPORT command to gather detailed

information regarding 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

Oracle In

ternal & O

AI Use

Only

Page 177: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-3

Copyright © Oracle Corporation, 2002. All rights reserved.

Oracle9i Command Unification

• RMAN has four related command sets for catalog maintenance: LIST, CROSSCHECK, CHANGE, and DELETE…EXPIRED.

• A number of changes have been implemented to provide greater consistency:– Unified actions– Similar syntax– Shared output style and status codes when

possible• The old syntax is still supported for backwards

compatibility.

Oracle9i Command UnificationThe following changes have been implemented to provide greater consolidation among the command sets: • CROSSCHECK and DELETE...EXPIRED deal with all object types.• CROSSCHECK, DELETE, and LIST can process smaller object sets like CHANGE

does.• CROSSCHECK sets status to 'X' if a data file copy, control file copy, and so on is

not available and skips any objects that are unavailable.• CROSSCHECK and DELETE functions have been consolidated. • UNCATALOG function has been removed.• DELETE lists and prompts for confirmation unless NOPROMPT is specified.• CHANGE syntax enhanced to be more consistent with DELETE/CROSSCHECK and

supports larger object list. • LIKE (fileNamePattern) added to CROSSCHECK/DELETE/CHANGE for pattern

matching.• LIST shows what CROSSCHECK/DELETE EXPIRED will process.

Oracle In

ternal & O

AI Use

Only

Page 178: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-4

Copyright © Oracle Corporation, 2002. All rights reserved.

CROSSCHECK Command

• The CROSSCHECK command synchronizes backup pieces in the recovery catalog with their corresponding files.

• Use the crosscheck feature to check the status of a backup or copy on disk or tape.

• Crosscheck will work only on items that are recorded in the RMAN repository.

• Addresses auto-expiration by the media manager

RMAN> allocate channel for maintenance

2> type 'sbt_tape';

RMAN> crosscheck backup;

The CROSSCHECK CommandSometimes backups and copies disappear from disk, or tapes in the media management library become unavailable. Crosschecks can also update the repository if you delete archived redo logs or other files using operating system commands. To ensure that data about backup sets and image copies in the recovery catalog or control file is synchronized with actual files on disk or in the media management catalog, perform a crosscheck. For files on disk, RMAN directly verifies that the file exists. For files on SBT_TAPE, RMAN queries the media management software. The CROSSCHECK command operates only on files that are recorded in the RMAN repository. Use CROSSCHECK to check the status of a backup or copy on disk or tape. If the backup or copy is on disk, then CROSSCHECK checks whether the header of the file is valid. If a backup is on tape, then the command checks that the backups exist. Backup sets, pieces, and copies can be AVAILABLE, EXPIRED, or UNAVAILABLE. You can issue the DELETE EXPIRED command to delete all expired backups and copies. RMAN removes the record for the expired file from the repository. If for some reason the file still exists on the media, then RMAN issues warnings and lists the mismatched objects that cannot be deleted.Oracle

Internal &

OAI U

se O

nly

Page 179: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-5

Copyright © Oracle Corporation, 2002. All rights reserved.

The LIST Command

The LIST command displays the contents of the RMAN repository (control file or recovery catalog).• List all databases known to the recovery catalog

or incarnations of a database:

• List backup sets or file copies containing a backup of a specified list of files:

• List all data file copies, control file copies, and archived logs:

RMAN> list incarnation of database;

RMAN> list backup of datafile 2;

RMAN> LIST COPY;

The LIST Command The LIST command queries the recovery catalog or control file and produces a listing of the backups, copies, archived redo logs, and database incarnations recorded there. Every time you reset the online redo logs of a target database, you create a new incarnation of the database. View incarnations with the LIST INCARNATION command.RMAN> list incarnation;List of Database IncarnationsDB Key Inc Key DB Name DB ID CUR Reset SCN Reset Time------- ------- -------- ------------ --- ---------- ----------1 2 U02 775813490 NO 1 06-MAR-021 73 U02 775813490 YES 440227 27-MAR-02

Some important column descriptions are described below:DB Key When combined with the Inc Key, the unique key by which RMAN

identifies the database incarnation in the recovery catalog. CUR Whether the incarnation is the current incarnation of the database.Reset SCN The SCN at which the incarnation was created.Reset Time The time at which the incarnation was created.Note that U02 was opened with the RESETLOGS option at SCN 440227 resulting in a new database incarnation.Oracle

Internal &

OAI U

se O

nly

Page 180: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-6

The LIST Command (continued)By default, RMAN lists backups by backup, which means that it serially lists each backup set or proxy copy and then identifies the files included in the backup.

RMAN> list backup of datafile 2;List of Backup Sets===================

BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------45 Full 29M DISK 00:00:13 24-MAR-02

BP Key: 46 Status: AVAILABLE Tag: Piece Name: /u01/user02/ORADATA/u06/01dk630k_1_1

List of Datafiles in backup set 45File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- --------- ----2 Full 439498 24-MAR-02 /u01/user02/ORADATA/u02/undo1_01_U02.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------59 Incr 1 29M DISK 00:00:09 27-MAR-02

BP Key: 60 Status: AVAILABLE Tag: Piece Name: /u01/user02/ORADATA/u06/03dkd96e_1_1

List of Datafiles in backup set 59File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- --------- ----2 0 Incr 439828 27-MAR-02 /u01/user02/ORADATA/u02/undo1_01_U02.dbf

Column Indicates----------- --------------------------------------------------------------------------------------------File The absolute data file numberKey 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. Itcorresponds to BS_KEY in the RC_BACKUP_SET view. If you are connectedin NOCATALOG mode, then Key displays the RECID from V$BACKUP_SET. RECID and STAMP form a concatenated primary key thatuniquely 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 incrementalsS 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 prior to the SCN have been written to the file; changes after thespecified SCN have not been written to the file

Ckp Time The checkpoint of the data file at the time it was backed up. All changesprior to the time have been written to the file; changes after the specified timehave not been written to the file

#Pieces 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 to 4Tag The tag applied to the backup set; NULL if noneOracle

Internal &

OAI U

se O

nly

Page 181: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-7

Copyright © Oracle Corporation, 2002. All rights reserved.

LIST Command Output

• LIST command output is verbose by default.• Specify SUMMARY to see output in a summarized

format.

• Specify the desired objects to summarize with the listObjectList or recordSpec clause.

RMAN> LIST BACKUP SUMMARY;RMAN> LIST EXPIRED BACKUP SUMMARY;

LIST Command OutputBy default the LIST output is highly detailed, but you can also specify that RMAN display the output in summarized form. Specify the desired objects with the listObjectList or recordSpec clause. If you do not specify an object, then LIST BACKUP displays all backups. By default, RMAN lists backups in verbose mode. To list backups in summary mode: After connecting to the target database and recovery catalog (if you use one), execute LIST BACKUP. Specify the desired objects and options. For example, you can enter:RMAN> LIST BACKUP SUMMARY;List of Backups===============Key TY LV S Device Type Completion Time #Pieces #Copies Tag------- -- -- - ----------- --------------- ------- ------- ---45 B F A DISK 24-MAR-02 1 1 55 B F A DISK 24-MAR-02 1 1 59 B 1 A DISK 27-MAR-02 1 1 69 B F A DISK 27-MAR-02 1 1 88 B F A DISK 27-MAR-02 1 1Oracle

Internal &

OAI U

se O

nly

Page 182: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-8

Copyright © Oracle Corporation, 2002. All rights reserved.

The REPORT Command

The REPORT command reports data in more detail than LIST and can answer questions such as: • What files need a backup? • Which files have had unrecoverable operations

performed on them?• Which backups or copies are obsolete and can be

deleted?• What was the physical schema of the database at

some previous time?

The REPORT CommandTo gain more detailed information from the RMAN repository, generate a report. Use the REPORT command to answer questions such as the following:

• Which files need a backup?• Which files have had unrecoverable operations performed on them?• Which backups or copies are obsolete and can be deleted?• What was the physical schema of the database at some previous time?• Which files have not been backed up recently?

The information that can be obtained from reports can be extremely important for implementing a backup and recovery strategy. For reports to be accurate, the repository must be synchronized with the control file and you must have run the CHANGE, UNCATALOG, and CROSSCHECK commands recently to update the status of all backups and copies.

Oracle In

ternal & O

AI Use

Only

Page 183: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-9

Copyright © Oracle Corporation, 2002. All rights reserved.

Report Objects Needing Backup

• Reports files needing backup according to the retention policy.

• Redundancy defaults to 1 if not specified.• To ensure recovery is possible within an

acceptable time:

RMAN> report need backup [ redundancy | days | incremental ] n;

RMAN> report need backup incremental 3 database;REPORT NEED BACKUP DAYS = 30 TABLESPACE SYSTEM;REPORT NEED BACKUP DAYS = 14 DATAFILE '/u01/user02/ORADATA/u03/users_01_U02.dbf';

Report Objects Needing BackupYou can report on objects that require a backup by specifying the NEED BACKUPkeyword. The REDUNDANCY parameter specifies the minimum number of backups or copies that must exist for a data file to be considered not in need of a backup. If you do not specify the parameter, REDUNDANCY defaults to 1. The DAYS parameter indicates that recovery must begin by using logs more than integer days old. The INCREMENTAL parameter indicates that more than integer incremental backups are required for complete recovery. If you disable the retention policy, then REPORT NEED BACKUP generates an error message:RMAN> report need backup;RMAN-00571: ================================================RMAN-00569: =========== ERROR MESSAGE STACK FOLLOWS=========RMAN-00571: ================================================RMAN-03002: failure of report command at 03/28/2002 21:07:27RMAN-06525: RMAN retention policy is set to none

Oracle In

ternal & O

AI Use

Only

Page 184: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-10

Report Objects Needing Backup (continued)To report on objects that need a backup, the following steps outline a typical approach:

1. After connecting to the target database and recovery catalog (if used), run CROSSCHECK commands to update backups and copies status. Following is a typical crosscheck session:RMAN> CROSSCHECK BACKUP;RMAN> CROSSCHECK COPY;

2. If you have a retention policy configured, then run REPORT NEED BACKUPwithout any other options to determine which files need backupsRMAN> REPORT NEED BACKUP;RMAN retention policy will be applied to the commandRMAN retention policy is set to redundancy 1Report of files with less than 1 redundant backupsFile #bkps Name---- ----- ---------------------------------------------2 0 /u01/user02/ORADATA/u02/undo1_01_U02.dbf3 0 /u01/user02/ORADATA/u03/users_01_U02.dbf

3. If you do not have a retention policy enabled, run REPORT NEED BACKUP DAYS. Any files 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 recoverRMAN> REPORT NEED BACKUP DAYS = 30 TABLESPACE SYSTEM;

4. To determine which files need an incremental backup, specify the INCREMENTALparameter. 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;

Oracle In

ternal & O

AI Use

Only

Page 185: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-11

Copyright © Oracle Corporation, 2002. All rights reserved.

Report Unrecoverable Backups and Copies

• Run the REPORT UNRECOVERABLE command regularly to ensure that recovery is possible.

• A data file is unrecoverable if an unrecoverable operation has been performed against an object in the data file since the last backup.

• The absence of a backup of a data file is not sufficient reason to consider it unrecoverable.

RMAN> report unrecoverable;

Report Unrecoverable Backups and CopiesIt is extremely important to run the REPORT UNRECOVERABLE command regularly to ensure that the necessary backups are available to perform recovery. Assume that you perform an unrecoverable operation on the EMPLOYEES table by issuing an ALTER TABLE EMPLOYEES...NOLOGGING statement. If the EMPLOYEES table is located in data file 3, then the REPORT command can flag backups of this data file as unrecoverable.After connecting to the target database and recovery catalog (if you use one) and run:RMAN> REPORT UNRECOVERABLE DATABASE;

The nonexistence of any backup of a data file is not sufficient reason to consider it unrecoverable. Such data files can be recovered through the use of the CREATE DATAFILE command, if redo logs starting from when the file was created still exist.

Oracle In

ternal & O

AI Use

Only

Page 186: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-12

Copyright © Oracle Corporation, 2002. All rights reserved.

Report Obsolete Backups and Copies

• Use the OBSOLETE option to identify which backups are superfluous.

• Use the ORPHAN option to list unusable backups and copies.

• The RECOVERY WINDOW option specifies a window during which the database must be recoverable.– This option was introduced with Oracle9i

RMAN> REPORT OBSOLETE REDUNDANCY = 2 DEVICE TYPE sbt;

RMAN> REPORT OBSOLETE ORPHAN;

Report Obsolete Backups and CopiesYou can report on objects that are obsolete,or unneeded, by specifying the OBSOLETEkeyword. If you do not specify any other options, then REPORT OBSOLETE displays the backups and copies that are marked obsolete by the current retention policy. By default, the retention policy is configured to REDUNDANCY of 1. A new option, RECOVERY WINDOW, has been added in Oracle9i to specify a window of time during which the database must be recoverable. This option is mutually exclusive with the REDUNDANCY option. When RECOVERY WINDOW is specified, then for each data file, one backup that is older than the recovery window must exist. All backups older than that one are obsolete.To list backups and copies that are obsolete and are candidates for removal, the following steps outline a typical approach:

1. Connect to the target database and recovery catalog (if used) and issue CROSSCHECK commands as needed to update the status of backups and copies. Following is a possible crosscheck session:RMAN> CROSSCHECK BACKUP; # crosschecks all backupsRMAN> CROSSCHECK COPY; # crosschecks all copies

2. Use the OBSOLETE option to find backups that are no longer needed for recovery.REPORT OBSOLETE REDUNDANCY = 2 DEVICE TYPE sbt;

Oracle In

ternal & O

AI Use

Only

Page 187: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-13

Report Obsolete Backups and Copies (continued)3. Use the ORPHAN option to list unusable backups and copies belonging to an

incarnation that does not directly precede the current incarnation.RMAN> REPORT OBSOLETE ORPHAN;

4. Optionally, delete backups that are obsolete with the DELETE OBSOLETEcommand.RMAN> DELETE OBSOLETE;

Oracle In

ternal & O

AI Use

Only

Page 188: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-14

Copyright © Oracle Corporation, 2002. All rights reserved.

Report Database Schema

• To report the database schema:

• To report the database schema at a specified point in time:

• The AT clause requires that a recovery catalog be used.

RMAN> REPORT SCHEMA ;

RMAN> REPORT SCHEMA AT TIME 'SYSDATE-14'; RMAN> REPORT SCHEMA AT SCN 1000; RMAN> REPORT SCHEMA AT SEQUENCE 100 THREAD 1;

Report Database SchemaIt is not necessary to use V$ views or recovery catalog views to identify the database files. The REPORT SCHEMA command will list file names and numbers, size and tablespace information. If you use a recovery catalog, then you can also generate historical reports of the database schema at a past time. You do not need a recovery catalog, however, to report the current schemaConnect to the target database and recovery catalog and issue REPORT SCHEMA for a list of all the data files and tablespaces in the target database at the desired time:RMAN> REPORT SCHEMA AT SCN 1000;

Report of database schemaFile K-bytes Tablespace RB segs Datafile Name---- ------- ---------- ------- ----------------------------1 307200 SYSTEM YES /oracle/oradata/trgt/system01.dbf2 20480 UNDOTBS YES /oracle/oradata/trgt/undotbs01.dbf...8 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.Oracle

Internal &

OAI U

se O

nly

Page 189: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-15

Copyright © Oracle Corporation, 2002. All rights reserved.

Show RMAN Configuration Settings

• The SHOW…command displays specified configuration values.

• The SHOW ALL command displays current CONFIGURE values as well as RMAN’s default configurations.

• Any CONFIGURE command can be returned to its default setting by running CONFIGURE…CLEAR.

RMAN> show controlfile autobackup;

Show RMAN Configuration SettingsThe SHOW ALL command displays both the CONFIGURE commands that you have issued as well as RMAN’s default configurations. Note that you can return any CONFIGUREcommand to its default setting by running CONFIGURE...CLEAR. To show all RMAN configuration settings, connect to the target database and run the SHOW ALL command:RMAN> SHOW ALL; RMAN configuration parameters are:CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default...CONFIGURE DATAFILE BACKUP COPIES FOR DISK TO 2;CONFIGURE DATAFILE BACKUP COPIES FOR SBT TO 1; #defaultCONFIGURE ARCHIVELOG BACKUP COPIES FOR SBT TO 1; # defaultCONFIGURE ARCHIVELOG BACKUP COPIES FOR DISK TO 1; # defaultCONFIGURE SNAPSHOT CONTROLFILE NAME TO ’/oracle/dbs/cf_snap.f’;

Individual settings can be shown like this:RMAN> show retention policy;RMAN configuration parameters are:CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # defaultOracle

Internal &

OAI U

se O

nly

Page 190: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-16

Copyright © Oracle Corporation, 2002. All rights reserved.

The CHANGE…UNAVAILABLE andCHANGE…AVAILABLE Commands

• The CHANGE…UNAVAILABLE command is used to update the availability information in the recovery catalog.– To mark a backup piece, file copy, or archivelog as

unavailable or available for restore or recovery

• When the maintenance is complete, the CHANGE…AVAILABLE command can be issued.

RMAN> change archivelog2> '/u01/arch/al_prd1_123.rdo'

3> unavailable;

The CHANGE…UNAVAILABLE CommandRMAN can update the repository to show backups and copies as available or unavailable. For example, you may have several backups on a tape drive that is being upgraded or replaced. You can use the CHANGE...UNAVAILABLE command to mark these backups and copies as unavailable for the duration of the maintenance on the drive. RMAN does not consider UNAVAILABLE backups and copies for its backup and recovery operations.When the maintenance is complete, you can issue the CHANGE...AVAILABLEcommand to inform RMAN that these backups and copies are now available again. Note that this command does not check for the existence of the files or validate the file in any way: it merely updates the repository record to AVAILABLE. You can run CROSSCHECKto validate the file.

Oracle In

ternal & O

AI Use

Only

Page 191: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-17

Copyright © Oracle Corporation, 2002. All rights reserved.

CHANGE…UNCATALOG Command

• To remove references to a backup piece, file copy, or archivelog from the recovery catalog if it was for example deleted by an O/S utility

• The CHANGE…UNCATALOG command does not touch physical backups and copies.

RMAN> change archivelog2> '/disk1/archivelog/al_prd1_123.rdo' 3> uncatalog;

The CHANGE…UNCATALOG CommandThis command removes references to a data file copy or archived redo log (but not a backup piece or backup set) from the recovery catalog, and updates records in the target control file to status DELETED. The CHANGE...UNCATALOG command does not touch physical backups and copies. Use this command to notify RMAN when a file is deleted by some means other than a DELETE command. In releases prior to Oracle9i, RMAN sometimes updated the status of records to DELETED in the recovery catalog rather than removing the records altogether. In Oracle9i, RMAN always removes the catalog record rather than marking it as DELETED. Therefore, catalog records should only be marked with status DELETED if the catalog has been upgraded or the catalog was resynchronized from a backup control file. You can remove all repository records of backups and copies with status DELETED using the prgrmanc.sql script, which is located in $ORACLE_HOME/rdbms/admin.

Oracle In

ternal & O

AI Use

Only

Page 192: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-18

Copyright © Oracle Corporation, 2002. All rights reserved.

Deleting Specified Backups and Copies

To delete backups and copies and remove their repository records:• Use the LIST command to obtain primary keys of

backups and copies.• Allocate a channel for maintenance if you don’t

have an automatic one configured.• Run the DELETE command to remove the physical

files and their repository records.

Deleting Specified Backups and CopiesUse the DELETE command to remove backups and copies that you no longer want to retain. This command removes the physical files, deletes the catalog records (if you use a catalog), and updates the status in the target control file to DELETED.To delete backups and copies and remove their repository records:

1. Run the LIST command to obtain primary keys of backups and copies.RMAN> LIST BACKUP OF DATABASE ARCHIVELOG ALL;RMAN> LIST COPY;

2. If you do not have automatic channels configured, then allocate a maintenance channel.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> DELETE BACKUPPIECE 101;RMAN> DELETE CONTROLFILECOPY ’/tmp/control01.ctl’;RMAN> DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 300;RMAN> DELETE BACKUP OF TABLESPACE users DEVICE TYPE sbt;

# deletes only tape backupsOracle

Internal &

OAI U

se O

nly

Page 193: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-19

Deleting Specified Backups and Copies (continued)RMAN> DELETE COPY OF CONTROLFILE LIKE ’/tmp/%’;

# LIKE specifies name of the copyRMAN> DELETE BACKUP OF SPFILE COMPLETED BEFORE

’SYSDATE-7’;RMAN> DELETE NOPROMPT ARCHIVELOG ALL BACKED UP 3 TIMES

TO sbt; # backs up logs only if already backed up three times to tape

Oracle In

ternal & O

AI Use

Only

Page 194: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-20

Copyright © Oracle Corporation, 2002. All rights reserved.

Deleting Expired or Obsolete Backups

• Run CROSSCHECK to make sure backups and copies are still on the specified media.

• Run DELETE EXPIRED command to remove these backups and their records in the repository.

• Run the DELETE OBSOLETE command with no options to delete backups, copies, and their records that are obsolete as defined by the retention policy.

RMAN> DELETE EXPIRED BACKUP;

RMAN> DELETE OBSOLETE;

Deleting Expired or Obsolete BackupsYou can use the CROSSCHECK command to determine whether backups and copies recorded in the repository still exist on disk or tape. If RMAN cannot locate the backups and copies, then it updates their records to EXPIRED status. You can then use the DELETE EXPIRED command to remove these expired records. Note that if for some reason the expired files still exist, then the DELETE EXPIRED command aborts with an error message. Use the DELETE OBSOLETE command to remove backups and copies that are obsolete, as defined by the defined retention policy. The DELETE OBSOLETEcommand removes both the physical files, deletes the catalog records (if you use a catalog), and updates the records in the target control file to status DELETED.You can run the DELETE OBSOLETE REDUNDANCY or DELETE OBSOLETERECOVERY WINDOW commands to delete obsolete backups and copies. The redundancy or recovery window setting on the DELETE command overrides settings on the CONFIGURE RETENTION POLICY command. For example, enter:RMAN> DELETE OBSOLETE REDUNDANCY = 3;

RMAN> DELETE OBSOLETE RECOVERY WINDOW OF 7 DAYS;Oracle In

ternal & O

AI Use

Only

Page 195: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-21

Copyright © Oracle Corporation, 2002. All rights reserved.

Stored Script Information

• List stored scripts by querying RC_STORED_SCRIPT.

• Use the PRINT SCRIPT command to display the text of a stored script.

• Display text of stored scripts by querying RC_STORED_SCRIPT_LINE.

Stored Script InformationThe RC_STORED_SCRIPT view contains information about all stored scripts for all incarnations of the target databases registered in the catalog. Use the PRINT SCRIPTcommand to display the text of a stored script. If desired, you can save the output to an RMAN log file. The RC_STORED_SCRIPT_LINE view contains the text of all stored scripts for all incarnations of the target databases registered in the recovery catalog.To print scripts from RMAN and save the output to a log file:$ rman TARGET / CATALOG rman/cat@catdb LOG = rman_log

RMAN> PRINT SCRIPT backup_whole;

To view script lines from the RC_STORED_SCRIPT_LINE view, start a SQL*Plus session and connect to the recovery catalog as RMAN:$ sqlplus rman/cat@catdb

SQL> SELECT TEXT2 FROM RC_DATABASE_INCARNATION i, RC_STORED_SCRIPT_LINE s3 WHERE i.DB_KEY = database_key AND SCRIPT_NAME = ‘script_name’

4 AND i.DB_KEY = s.DB_KEY;

Oracle In

ternal & O

AI Use

Only

Page 196: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-22

Copyright © Oracle Corporation, 2002. All rights reserved.

Maintenance Required When Not Using a Recovery Catalog

Tasks to be performed manually when using RMAN without a recovery catalog:• Monitor the overwriting of control file records• Maintain the control file repository• Backing up and restoring the control file

Maintenance RequiredWhen you do not use a recovery catalog, the control file is the sole source of information about RMAN backups and copies. As you make backups and copies, the Oracle server adds new records to the control file. What happens when the server needs to add new records to the control file, but the oldest record is less than the value specified in CONTROL_FILE_RECORD_KEEP_TIME? The Oracle server attempts to expand the size of the control file, which it can only do if the underlying operating system file can be expanded. If it cannot expand the control file, then the server overwrites the oldest record, regardless of whether its age is less than the CONTROL_FILE_RECORD_KEEP_TIME value and logs this action in the alert log. Hence, if you are not using a recovery catalog, then set the CONTROL_FILE_RECORD_KEEP_TIME value to slightly longer than the oldest file that you need to keep.If you use the control file as the sole repository of the RMAN metadata, maintain alternate control files through multiplexing or operating system mirroring and back up the control file frequently. If you lose the control file and do not have a backup, you lose all information about RMAN backups and copies contained in the file. For this reason, you should set CONFIGURE CONTROLFILE AUTOBACKUP to ON.

Oracle In

ternal & O

AI Use

Only

Page 197: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-23

Copyright © Oracle Corporation, 2002. All rights reserved.

Summary

In this lesson, you should have learned how to:• Use the LIST command to display backup data

recorded in the catalog or target control file• Use the REPORT command to gather detailed

information regarding 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

Oracle In

ternal & O

AI Use

Only

Page 198: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 5-24

Copyright © Oracle Corporation, 2002. All rights reserved.

Practice Overview: RMAN Maintenance

This practice covers the following topics:• Using the LIST command• Using the REPORT command• Deleting expired or obsolete backups• View stored scripts

Oracle In

ternal & O

AI Use

Only

Page 199: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Copyright © Oracle Corporation, 2002. All rights reserved.

Using RMAN with a Media Manager

Oracle In

ternal & O

AI Use

Only

Page 200: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-2

Copyright © Oracle Corporation, 2002. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:• Identify how RMAN makes backups to tape• Understand how the Media Management Interface

works• Identify the two versions of the SBT interface• Discuss linking the Oracle server with a media

manager• Discuss media manager issues and informational

messages

Oracle In

ternal & O

AI Use

Only

Page 201: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-3

Copyright © Oracle Corporation, 2002. All rights reserved.

Backups to Tape

• The Oracle server can only write backups to disk.• To store backups on tape, RMAN requires a media

manager.• A media manager is a vendor-supplied utility that

can backup and restore to sequential media. • The System Backup to Tape (SBT) API is provided

to participating vendors.

Backups to TapeTo 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 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 reference the following site: http://www.oracle.com/database/recovery/index.html?/database/recovery/backupsp.html

Oracle In

ternal & O

AI Use

Only

Page 202: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-4

Copyright © Oracle Corporation, 2002. All rights reserved.

Media Manager

Media Manager Architecture

RecoveryManager

MediaManagerLibrary

OracleServer

Session

Media Management

Server Software

Tape Subsystem

RecoveryCatalog

Control File

Media Manager ArchitectureThe Oracle server session is the same type of server session used when a client such as SQL*Plus connects to the database. The media management library (MML) represents vendor-supplied media management software library that can interface with Oracle. Oracle calls MML software routines to back up and restore data files to and from media controlled by the media manager. When doing backups or restores, the RMAN client connects to the target instance and directs the instance to talk to its media manager. No direct communication occurs between the RMAN client and the media manager; all communication occurs on the target instance.

Oracle In

ternal & O

AI Use

Only

Page 203: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-5

Copyright © Oracle Corporation, 2002. All rights reserved.

Media Manager Prerequisites

1. Install and configure the media management software on the target host.

2. Ensure that non-RMAN backups of operating system files can be made on the target database.

3. Install the third-party media management module for integration with the Oracle server.

Media Manager PrerequisitesBefore you can begin using RMAN with a media manager, you must install it and make sure that RMAN can communicate with it. Instructions for this procedure should be available in the media manager vendor’s software documentation. Depending on the product that you are installing, the following basic steps apply:

1. Install and configure the media management software on the target host or production network. No RMAN integration is required at this stage.

2. Ensure that you can make non-RMAN backups of operating system files on the target database host. This step makes later troubleshooting much easier. Refer to your media management documentation to learn how to back up files to the media manager.

3. Obtain and install the third-party media management module for integration with the Oracle server. This module must contain the library that Oracle loads when accessing the media manager.

If you have not performed the preceding steps, then do not proceed with the media management configuration.Oracle

Internal &

OAI U

se O

nly

Page 204: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-6

Copyright © Oracle Corporation, 2002. All rights reserved.

Linking a Media Manager on UNIX

Suggested steps to correctly link the Media Management software the Oracle server:• Remove any old libobk.so files or links in

$ORACLE_HOME before installing the software.• Check the vendor documentation to determine

where the media management library is installed.• Change the name of the media management

library to $ORACLE_HOME/lib/libobk.so or create a symbolic link to the library called libobk.so.

Linking a Media Manager on UNIXAfter you install the media management software, the media management library should already be integrated with the Oracle server. You should not have to perform further integration. However, you may choose to follow the procedure in this section to ensure that the media manager is integrated correctly. Because the specifics of your media management integration with Oracle depends on both the product and the operating system, this section cannot cover all possible cases. In Oracle8i, the operating system implicitly loads the library at the start of any Oracle server session. In Oracle9i, Oracle explicitly loads the library with a dlopen(3X)call for each RMAN channel allocation.On UNIX, Oracle accesses the media management library through the UNIX shared library libobk.so. This file must exist somewhere in the system path. It is highly recommended that you place libobk.so in $ORACLE_HOME/lib, which is where Oracle searches first.

Oracle In

ternal & O

AI Use

Only

Page 205: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-7

Linking a Media Manager on UNIX (continued)To integrate the media manager on UNIX:

1. If an old libobk.so symbolic link already exists in $ORACLE_HOME/lib, then remove it before installing the media manager. For example:$ rm $ORACLE_HOME/lib/libobk.so

2. After installation, check your media management vendor documentation to determine where the media management library is installed. For example, suppose that the library is installed as /vendor/lib/oracle_lib.so.

3. Either change the name of the installed media management library to $ORACLE_HOME/lib/libobk.so, or created a symbolic link to the library called libobk.so. For example, you can create a symbolic link to the library as follows:$ ln -s /vendor/lib/oracle_lib.so$ORACLE_HOME/lib/libobk.soAlternatively, you can simply change the name of the library to libobk.so. For example:$ mv /vendor/lib/oracle_lib.so$ORACLE_HOME/lib/libobk.so

Oracle In

ternal & O

AI Use

Only

Page 206: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-8

Copyright © Oracle Corporation, 2002. All rights reserved.

Linking a Media Manager on NT

1. If an old orasbt.dll exists in the system path, remove it before installing the media manager.

2. After installation, check the vendor documentation to find the media management library location.

3. If the library is not called orasbt.dll, then rename it to %ORACLE_HOME%\bin\orasbt.dll.

Linking a Media Manager on NTOn Windows NT, Oracle accesses the media management library through the library orasbt.dll. This file must exist somewhere in the system path. Typically, the file is located in the %ORACLE_HOME%\bin folder of the Oracle home. In Oracle 8.x, the DLL is loaded by the operating system once when the Oracle service starts up. In Oracle9i, the DLL is loaded when a channel is allocated, and unloaded when the channel is released.You do not need to start or shut down the instance when installing the media management library. To integrate the media manager with RMAN on NT, follow the steps below:

1. If an orasbt.dll already exists in the system path, then remove it before installing the media manager. For example:C:\> del %ORACLE_HOME%\bin\orasbt.dll

2. After installation, check your media management vendor documentation to determine where the media management library is installed. For example, suppose that the library is installed as D:\vendor\lib\oracle_lib.dll.

3. If the installed library is not called orasbt.dll, then rename the installed media management library to %ORACLE_HOME%\bin\orasbt.dll. For example, you can copy the installed library as follows:D:\> copy D:\vendor\oracle_lib.dll%ORACLE_HOME%\bin\orasbt.dllThe orasbt.dll file does not have to be in the %ORACLE_HOME\bin folder as long as the folder containing the library is in the system PATH variable setting.

Oracle In

ternal & O

AI Use

Only

Page 207: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-9

Copyright © Oracle Corporation, 2002. All rights reserved.

Testing the Media Manager Installation

1. Start RMAN and connect to the target database.2. Issue an ALLOCATE CHANNEL command.

3. If an ORA-27211 error is not raised, then the shared library loaded successfully.

RMAN> ALLOCATE CHANNEL c1 DEVICE TYPE sbt

PARMS=’ENV=(NSR_SERVER=tape_srv,NSR_GROUP=oracle_tapes)’;

Testing the Media Manager InstallationAfter integrating the media management library with Oracle, test whether RMAN is able to load the library.

1. Start RMAN and connect to the target database. 2. Run the ALLOCATE CHANNEL command with the PARMS required by the media

management software. For example, run this command in a RUN block:ALLOCATE CHANNEL c1 DEVICE TYPE sbtPARMS=’ENV=(NSR_SERVER=tape_srv,NSR_GROUP=oracle_tapes)’;

If you do not receive an error message, then Oracle successfully loaded the shared library. However, channel allocation can fail with the ORA-27211 error:RMAN-03009: failure of allocate command on c1 channel at 13:57:18ORA-19554: error allocating device, device type: SBT_TAPEORA-27211: Failed to load Media Management LibraryAdditional information: 25

The ORA-27211 error indicates that Oracle 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 redo. For any other errors, check the trace file in USER_DUMP_DEST directory for more information.Oracle

Internal &

OAI U

se O

nly

Page 208: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-10

Copyright © Oracle Corporation, 2002. All rights reserved.

Perform a Test Backup to Tape

• Allocate a channel and issue a BACKUP command, including the correct PARMS for the tape device.

• If the backup hangs, the media manager is probably waiting for the tape to mount.– See if there are jobs in "tape mount request" mode

and correct.• An ORA-19511 is usually indicative of a

configuration error.– Check and retest the configuration.

Perform a Test BackupAfter testing a channel allocation on the media manager, make a test backup. For example, to test whether your backup goes successfully to tape, you might execute the following command in a RUN block:ALLOCATE CHANNEL c1 DEVICE TYPE sbtPARMS=’ENV=(NSR_SERVER=tape_srv,NSR_GROUP=oracle_tapes)’;BACKUP DATAFILE 1;

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 PARMSsetting instructs the media manager to back up to a volume pool 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 “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. Ensure that the steps covered previously have been followed.

Oracle In

ternal & O

AI Use

Only

Page 209: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-11

Copyright © Oracle Corporation, 2002. All rights reserved.

Automatic Channels and Media Manager

1. Configure a generic channel of DEVICE TYPE SBT.2. Test by issuing a BACKUP command without a

manual channel allocation.3. If successful, configure the default device to SBT.

RMAN> CONFIGURE DEFAULT DEVICE TYPE TO SBT;

Automatic Channels and Media ManagerUse the CONFIGURE CHANNEL command to configure automatic channel options for device type sbt. You can use the same options for CONFIGURE CHANNEL that you used for ALLOCATE CHANNEL earlier. 1. Configure a generic channel of DEVICE TYPE sbt. In the configuration, type all

parameters you tested in the previous steps. For example, assume that your media vendor requires PARMS settings as follows:RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt2> PARMS=’ENV=(NSR_SERVER=tape_svr, NSR_CLIENT=oracleclnt,3> NSR_GROUP=oracle_tapes)’ FORMAT "BACKUP_%U";

2. After configuring the channel, test the backup with the following command:RMAN> BACKUP DEVICE TYPE sbt DATAFILE 1;

3. Check your configuration by running the following command:RMAN> SHOW CHANNEL DEVICE TYPE sbt;

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;Oracle

Internal &

OAI U

se O

nly

Page 210: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-12

Automatic Channels and Media Manager (continued)5. After configuring the default device, make a test backup to determine whether it is

really going to the media manager:RMAN> BACKUP DATAFILE 1;

6. Check your configuration by running the following command:RMAN> SHOW DEFAULT DEVICE TYPE;

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 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)

Oracle In

ternal & O

AI Use

Only

Page 211: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-13

Copyright © Oracle Corporation, 2002. All rights reserved.

Default SBT Interface

It is possible to write to disk using the Oracle Disk SBT interface. • This is useful for simulating tape backups for

troubleshooting purposes.• This is not supported for actual backups.• For Oracle9i use SBT_TAPE, specify BACKUP_DIR

and SBT_LBRARY.RMAN> allocate channel c1

2> type ‘sbt_tape’3> ‘ENV=SBT_LIBRARY=oracle.disksbt,4> (BACKUP_DIR=/your/backup/directory)’;

Default SBT InterfaceOn platforms that support third-party media managers through the Oracle Media Management (SBT) API, the new SBT_LIBRARY parameter controls which media management library that RMAN uses on channels of DEVICE TYPE sbt. Use SBT_LIBRARY in the PARMS setting of the ALLOCATE CHANNEL or CONFIGURE CHANNEL command to specify the filename of the shared library to be loaded. You can also specify SBT_LIBRARY=oracle.disksbt, which causes the server to load Oracle’s disk sbt library (formerly called the "dummy API"). If no SBT_LIBRARYparameter is specified in PARMS, then the Oracle server attempts to load the dynamic libraries orasbt.dll on Windows NT and libobk.so on UNIX. If Oracle cannot locate the library, then the server returns an error.Note: Do not use the the default SBT interface for production backups. If a real media manager is later installed, these backups will become unusable. Always use DISK channels for production backups to disk.

Oracle In

ternal & O

AI Use

Only

Page 212: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-14

Copyright © Oracle Corporation, 2002. All rights reserved.

Events in a Media Manager Backup

1. When an SBT channel is allocated, RMAN connects to the Oracle server and starts a server session.

2. The Oracle server starts the media management software by calling sbtinit().

3. Oracle calls sbtinit2() to pass additional data to the media manager not passed by sbtinit().

4. Oracle calls sbtbackup() to create the backup piece.

5. The Oracle Server reads the input database files.

Events in a Media Manager BackupAPI version 2.0 is supplied with Oracle8i and Oracle9i. The following sequence of events occurs in the SBT API 2.0 backup session:

1. When an SBT channel is allocated, RMAN connects to the Oracle server on the target host and starts a server session.

2. When started, the Oracle server session initializes the media management software by calling sbtinit(). The version of SBT API supported by the media management software is returned. This information is displayed in the RMAN message RMAN-08503 message, for example:RMAN-08503: ... comment=API Version 2.0,MMS Version 3.2.0.0

3. After successfully calling sbtinit(), Oracle calls sbtinit2() to supply additional information to the media management software that was not supplied by sbtinit().

4. The Oracle session calls sbtbackup() in order to create a backup piece. In other words, the sbtbackup() instructs the media manager to get ready to accept a stream.

5. The Oracle server begins reading the input database files (data files, archived logs, or control files). The data is sent to the media manager by the sbtwrite2() API call. The sbtwrite2() function writes the data to the backup media.

Oracle In

ternal & O

AI Use

Only

Page 213: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-15

Copyright © Oracle Corporation, 2002. All rights reserved.

Events in a Media Manager Backup

6. When Oracle finishes writing the backup piece, sbtclose() is called to close it.

7. Oracle calls sbtinfo2() to see if the backup piece is stored in the media manager.

8. When sbtinfo2() finishes, RMAN writes the name of the backup piece.

9. After the Oracle server sessions backs up all data, it calls sbtend() to clean up and release resources.

Events in a Media Manager Backup (continued)6. When the Oracle server session finishes writing the backup piece, it calls

sbtclose2() to close it. The sbtclose2() function tells the media manager to commit data on the backup medium.

7. Oracle calls sbtinfo2() to see if the backup piece is stored in the media manager database. The sbtinfo2() function requests the media manager return the mediumID, location, and expiration time of the backup medium on which the backup piece is stored.

8. When sbtinfo2() finishes, RMAN writes the name of the backup piece as in the following example:RMAN-08045: channel ORA_SBT_TAPE_1: finished piece 1 at MAR 13 2001 08:48:12RMAN-08503: piece handle=41ckj865_1_1 comment=API Version 2.0,MMS Version 3.2.0.0If 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.

Oracle In

ternal & O

AI Use

Only

Page 214: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-16

Copyright © Oracle Corporation, 2002. All rights reserved.

Events in a Media Manager Restore

1. When an SBT channel is allocated, RMAN connects to the Oracle server and starts a server session.

2. The Oracle server session initializes the media management software by calling sbtinit().

3. The Oracle server calls sbtread() to read data from the media manager library.

4. The Oracle session calls sbtrestore() to request the backup piece from the media manager.

Events in a Media Manager RestoreThe sequence of events in a SBT API 2.0 restore session occurs in the following order:

1. When an sbt channel is allocated, RMAN connects to the Oracle server on the target host and starts a server session.

2. When started, the Oracle server session initializes the media management software by calling sbtinit().

3. The Oracle server starts reading data from the media manager library by calling sbtread().

4. The Oracle session calls the sbtrestore() function to request the backup piece from the media manager. Essentially, the sbtrestore() instructs the media manager to find and prepare the backup medium containing the requested backup piece. For example, if the backup was done to tape, this function instructs the media manager to load the tape into the tape drive and rewind it.

Oracle In

ternal & O

AI Use

Only

Page 215: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-17

Copyright © Oracle Corporation, 2002. All rights reserved.

Events in a Media Manager Restore

5. The Oracle server starts reading data from the media manager library by calling sbtread2()

6. Oracle calls sbtclose() when it reaches the end of the backup piece.

7. If there is more data to be restored, then the algorithm continues from step 4.

8. After the server sessions restores all data, it calls sbtend() to clean up and release resources.

Events in a Media Manager Restore (continued)5. The Oracle server starts reading data from the media manager library by calling

sbtread2(). The data received from sbtread2() is written to disk.6. When it reaches the end of the backup piece, Oracle calls sbtclose(). The

sbtclose() function instructs the media manager to stop reading data from the tape.

7. If there is more data to be restored, then the algorithm continues from step 4.8. After the server sessions restores all data, it calls sbtend(). This function cleans

up and releases resources. After sbtend() returns, the RMAN channel is released and the server session ends. During this step, a typical media manager library instructs the session manager to end the restore session and unload the tapes.

Oracle In

ternal & O

AI Use

Only

Page 216: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-18

Copyright © Oracle Corporation, 2002. All rights reserved.

Media Manager Diagnostics

• sbttest

– A stand-alone program that tests if the media management software is installed and can accept a data stream 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.

– Found in the location specified by USER_DUMP_DESTor by default on UNIX systems in $ORACLE_HOME/rdbms/log

Media Manager DiagnosticsOn specific platforms, Oracle provides a diagnostic tool called sbttest. This utility performs a simple test of the media management software by acting as the Oracle database server and attempting to communicate with the media manager. On UNIX, the sbttest utility is located in $ORACLE_HOME/bin. Note that on platforms such as Solaris, you do not have to relink when using sbttest. On other platforms, relinking may be necessary.

Oracle In

ternal & O

AI Use

Only

Page 217: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-19

Copyright © Oracle Corporation, 2002. All rights reserved.

Troubleshooting: Media Manager or RMAN

Step 1: Is RMAN integrated with the media manager?• The RMAN-08526 indicates the Oracle8i server is

not linked with the media manager library.

• In Oracle9i, the ORA-27211 indicates the Oracle server session is unable to load the media management library.

RMAN-08526: channel ORA_SBT_TAPE_1: WARNING: Oracle Test Disk API

ORA-19557: device error, device type:SBT_TAPE, device name:ORA-27211: Failed to load Media Management Library

Troubleshooting: Media Manager or RMANIf the media manager is not linked with the Oracle server, or if the Oracle server is unable to load the media manager library, then ensure that the following requirements are met:

• On UNIX, in Oracle8i the name of the media manager library must be $ORACLE_HOME/lib/libobk.so. The exception is Oracle 8.1.6 on Solaris, where the media manager library should be $ORACLE_HOME/lib/libdsbtsh8.so (see bug 1252142). After renaming, the database instance should be restarted.

• The media manager DLL should be %ORACLE_HOME%\BIN\ORASBT.DLL. in Oracle8i on NT.You should restart the services. Sometimes a reboot is required.

• In Oracle9i, the only requirement is that media manager library name must be $ORACLE_HOME/lib/libobk.so on UNIX or %ORACLE_HOME%\BIN\ORASBT.DLL on NT. In Oracle9i, the DLL is loaded when a channel is allocated, and unloaded when the channel is released, so there is no need to restart the Oracle instance. You can use the PARMS parameter SBT_LIBRARY to alter location of the media manager library.

The following example shows a Veritas NetBackup setting:CONFIGURE CHANNEL DEVICE TYPE sbtPARMS=’SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so.1,ENV=(NB_ORA_CLASS=oracle_class)’;

Oracle In

ternal & O

AI Use

Only

Page 218: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-20

Copyright © Oracle Corporation, 2002. All rights reserved.

Troubleshooting: Media Manager or RMAN

Step 2: Investigate RMAN output and trace files.• Investigate the RMAN output for SBT errors.• Any error message referring to a sequential file is

an SBT API error.ORA-19506: failed to create sequential file, name="4eckrg0_1", parms=""ORA-27007: failed to open fileAdditional information: 7009Additional information: 1ORA-19511: Error received from media manager layer, error text:SBT error = 7009, errno = 0, sbtopen: can’t connect with media manager

Troubleshooting: Media Manager or RMAN (continued)You should investigate the RMAN output for SBT errors. If an error message refers to a sequential file, then you have identified an SBT API error. In the example above, the problem occurs in the SBT API because the ORA-19506 error refers to a sequential file. On Windows NT and UNIX platforms, all errors involving the write, read, open, or close of a sequential file indicates that an SBT function has failed.The text after the ORA-19511 message explains the error according to data received from the media manager. The textual error message is only displayed if the SBT API is version 2.0. The example below shows the failure of an SBT API 2.0 sbtbackup()function:ORA-19506: failed to create sequential file, name="4fckrhkv_1_1", parms=""ORA-27028: skgfqcre: sbtbackup returned errorORA-19511: Error received from media manager layer, error text:sbtbackup: Failed to open for backup. # SBT API 2.0 textual error messageOracle

Internal &

OAI U

se O

nly

Page 219: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-21

Troubleshooting: Media Manager or RMAN (continued)It also important to look at the trace file in the USER_DUMP_DEST location. This trace file is created by the Oracle server session process that is doing backup. In the trace file, the Oracle server session indicates which SBT function fails:*** 2002-03-16 11:42:28.852*** SESSION ID:(14.1) 2002-03-16 11:42:28.799SKGFQ OSD: Error in function sbtopen on line 691SKGFQ OSD: Look for SBT Trace messages in file ...log/sbtio.logIf 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 something like the following:ssexhd()+380 CALL ksedmp()+0sigacthandler()+40 PTR_CALL 00000000free_sbtinfo2_mem PTR_CALL 00000000sbtinfo2()+744 CALL free_sbtinfo2_memskgfgsm()+244 PTR_CALL 00000000skgfgsi()+184 CALL skgfgsm()+0skgfcls()+888 CALL skgfgsi()+0kgffsubmit()+12928 CALL skgfcls()+0

If you paste the stack above into the stack trace interpreter available on WebIV, you will find that a sequential file was being closed when sbtinfo() was called. The ssexhd() and ksedmp() functions are error dump routines and sigacthandler() is a signal handling function so these can be ignored. This gives the analyst something to proceed with.

Oracle In

ternal & O

AI Use

Only

Page 220: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-22

Copyright © Oracle Corporation, 2002. All rights reserved.

Troubleshooting: Media Manager or RMAN

Step 3: Do a backup to disk and the SBT disk library.• Prove that the problem is caused by the media

manager software rather than by RMAN.• Back up to disk with the format '/dev/null'

• If successful, back up to the SBT disk interface.

RUN {ALLOCATE CHANNEL tst TYPE DISK FORMAT ’/dev/null’;BACKUP DATABASE;}

RUN {ALLOCATE CHANNEL tst TYPE SBT FORMAT ’%U’ PARMS=’ENV=(BACKUP_DIR=/backup_disk)’;BACKUP DATABASE;}

Troubleshooting: Media Manager or RMAN (continued)In some cases, you need to prove to the customer that the problem is caused by the media manager software rather than by RMAN. The easiest test to back up to disk with the FORMAT '/dev/null' (UNIX only). This indicates that RMAN is functioning correctly. However, this test does not have the same code path as an SBT API backup. So next, try the backup with the SBT disk library provided by Oracle. For example:RUN {ALLOCATE CHANNEL tst TYPE SBT FORMAT ’%U’ PARMS=’ENV=(BACKUP_DIR=/backup)’;BACKUP DATABASE; }

In Oracle9i, the SBT disk library provided by Oracle can be loaded without removing the existing media manager library 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 media manager library is causing problems in Oracle server functions.

Oracle In

ternal & O

AI Use

Only

Page 221: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-23

Copyright © Oracle Corporation, 2002. All rights reserved.

Troubleshooting: Media Manager or RMAN

Step 4: Trace the server session to determine if the error is occurring within media manager.• Start the backup with channel option TRACE=1

• The trace is created in the USER_DUMP_DESTdirectory.

RUN {ALLOCATE CHANNEL tst TYPE DISK TRACE=1 FORMAT '/dev/null';BACKUP DATABASE;}

Troubleshooting: Media Manager or RMAN (continued)If the Oracle server session core dump or hangs, verify whether the core dump or hang occurs inside the media manager library. If you start the backup with channel option TRACE=1, then Oracle writes all entering and exiting of the SBT API functions in the trace which is created in the USER_DUMP_DEST directory.The trace output looks something like the following:*** SESSION ID:(9.17) 2002-03-16 13:50:21.945skgfalo(se=0x815ff8c8, ctx=0x262bf98, dev=0x264861c, devparms=, flags=33554432)skgfidev(se=0x815ff8c8 ctx=0x262bf98, dev=0x264861c)entering sbtinit on line 2203return from sbtinit on line 2213skgfqsbi(ctx=0x262bf98, vtapi=API Version 1.1, id=MMS Version 2.2.0.1)skgfqcre(se=0x815ff8c8, ctx=0x262bf98, dev=0x264861c, file=0x2647f08, fparms=, flags=0x0)entering sbtopen on line 683return from sbtopen on line 704skgfwrt(ctx=0x262bf98, file=0x2647f08, iosb=0x2647cf4,

Oracle In

ternal & O

AI Use

Only

Page 222: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-24

Troubleshooting: Media Manager or RMAN (continued)

buf=0x815b0000, numblks=1)skgfwrt(data=13020000 00000001 0003A1B1 00000104)entering sbtwrite on line 903...

The trace output indicates exactly which environment variables 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 if 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 nothing after this then the function sbtwrite is hung.Note: 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, prior to returning to the client.

Oracle In

ternal & O

AI Use

Only

Page 223: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-25

Copyright © Oracle Corporation, 2002. All rights reserved.

Troubleshooting: Media Manager or RMAN

Step 5: Isolate the server process from the SBT library.• The media manager may be interfering with the

server session.• Isolate the processes responsible for reading and

writing.• Enable the BACKUP_TAPE_IO_SLAVES initialization

parameter.

Troubleshooting: Media Manager or RMAN (continued)The media manager can interfere with the reading of files performed by the Oracle server session. This problem occurs because the media manager library is loaded by the Oracle server process and the library shares all operating system resources dedicated to the Oracle server process. For example, the media manager library can mistakenly close data file descriptors opened by Oracle code in the server process (see bug 1554531).You should attempt to separate the process responsible for reading from the process responsible for writing (performed by SBT functions in the media management library). You can separate these processes by setting the BACKUP_TAPE_IO_SLAVESinitialization parameter to true.

Oracle In

ternal & O

AI Use

Only

Page 224: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-26

Copyright © Oracle Corporation, 2002. All rights reserved.

Troubleshooting Media Manager

1. Determine if OS backup with media manager works.

2. Determine which API function fails.3. Investigate RMAN Output.4. Investigate the sbtio.log.

Troubleshooting Media ManagerThe customer should test whether the media manager operation system backup module can back up database files without RMAN. This test helps to determine whether the basic components of the media manager are correctly installed and configured. If the media manager operating system backup does not work, then the problem is not related to the Oracle media manager module. Rather, the problem is in the media manager installation and configuration.You can identify the problematic SBT API function in both in the Oracle trace file (located in the USER_DUMP_DEST directory) and in the RMAN output:ORA-19511: Error received from media manager layer, error text:SBT error 7009, errno = 0, sbtopen: can’t connect with media manager

The media manager library (SBT API 2.0) can return a text describing the error. The error text is written to the RMAN output. The below example displays the error text 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.

Oracle In

ternal & O

AI Use

Only

Page 225: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-27

Troubleshooting Media Manager (continued)In some cases, the media manager library returns an undocumented error code. In this case, Oracle displays the following:ORA-19506: failed to create sequential file, name="58cl3cdo_1_1", parms=""ORA-27007: failed to open fileAdditional information: 1ORA-19511: Error received from media manager layer, error text:Unknown SBT error code = 0, errno = 0

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 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 written in the media manager monitor and logs are also very helpful for vendor support. Ask the customer to collect the data.

Oracle In

ternal & O

AI Use

Only

Page 226: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-28

Copyright © Oracle Corporation, 2002. All rights reserved.

SBTINIT and SBTINIT2 Function Errors

• These functions are responsible for initializing the media manager library.

• Typical errors might include:– Faulty installation of the media manager– File permissions are incorrect– Insufficient resources to initialize the library

SBTINIT and SBTINIT2 Function ErrorsThe sbtinit()and sbtinit2() functions are responsible for initializing the media manager library. An error that occurs when calling sbtinit() or sbtinit2() indicates that the media manager library cannot initialize itself.Common implementations of sbtinit() and sbtinit2() like NetBackup, Legato, and OmniBack II, simply initialize the internal structures of the media management library. Consequently, this error is uncommon. If sbtinit() or sbtinit2() fails, then the media manager integration module was not properly installed. For example, it could be that permissions of the configuration files are not correct. The other more remote possibility is that not enough resources are available for initialization In Oracle8, if the media manager library is not installed in the right directory or is not linked with the Oracle binaries, then the server sessions call sbtinit() of the Oracle disk SBT API library. In this case, the following error is reported:ORA-27000: skgfqsbi: failed to initialize storage subsystem (SBT)layerAdditional information: 4110ORA-19511: SBT error = 4110, errno = 0, BACKUP_DIR environment variable is not setOracle

Internal &

OAI U

se O

nly

Page 227: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-29

SBTINIT and SBTINIT2 Function Errors (continued)RMAN-10031: ORA-19624 occurred during call to DBMS_BACKUP_RESTORE.DEVICEALLOCATE

At first glance, it would appear that this is a media manager error and it is. If you look closely, however, you will see that the BACKUP_DIR environment variable was improperly set. This indicates that this error came from Oracle's “dummy” SBT module using the SBT_DISK device.

Oracle In

ternal & O

AI Use

Only

Page 228: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-30

Copyright © Oracle Corporation, 2002. All rights reserved.

SBTOPEN or SBTBACKUP Failures

• SBTOPEN()and SBTBACKUP() should create the backup piece and start the backup session.

• Failures might include:– Incorrect configuration of the media manager– Incorrect PARMS environment variables– The OS owner of the server session may not be a

recognized user in the media manager configuration

SBTOPEN or SBTBACKUP FailuresThese two functions should create a backup piece at RMAN’s request and start the media manager backup session. If sbtopen() or sbtbackup() fails during the backup, then the media manager cannot create a backup piece or start a backup session. The overwhelming majority of problems are caused by incorrect configuration of the media manager. The following situations are common:

• The environment variables specified in PARMS option are incorrect. For example, in the case of Legato NetWorker, a wrong media pool is specified. In case of NetBackup, the "Class" setting could be wrong.

• The pool, class, or some other media manager configuration entity is not correctly configured for Oracle backups. For example, in the case of NetBackup, the "Class" specified by NB_ORA_CLASS is not an Oracle class. In the case of Legato, the media pool specified by NSR_DATA_VOLUME_POOL does not exist.

• The UNIX or NT user under which Oracle server sessions are running is not a valid user in the media manager configuration. For example, in case of OmniBack II, the user under which Oracle is running must be included in the OmniBack II UserList.

• The media manager library cannot connect to the media manager server daemon because it is not started.

Oracle In

ternal & O

AI Use

Only

Page 229: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-31

Copyright © Oracle Corporation, 2002. All rights reserved.

SBTOPEN or SBTRESTORE Failures

• The SBTOPEN() and SBTRESTORE() functions are called to retrieve an existing backup piece.

• Typical failures might include:– The backup piece is not in the media management

database.– The media manager does not have the proper

permissions for the restore.• Permission errors are common in Oracle Real

Application Clusters environments.

SBTOPEN or SBTRESTORE FailuresThe sbtopen() and sbtresotre() functions are used to retrieve an existing backup piece. If the sbtopen() or sbtresotre() function fails during the restore, then the media manager cannot find the requested backup piece or it cannot start the restore session. There are two primary reasons for these functions to fail during a restore:

• The backup piece does not exist in the media management database. For example, the tape containing the backup is deleted from the media manager database. The easiest way to check this problem is to look for the backup piece in the media management database.

• The media management library does not have the permissions required to restore the requested object. This error is common in Real Application Cluster environments in which each Oracle instance should have access to data backed up with other nodes. For example, the first node in the cluster configurations backs up a backup piece. During the restore, the second node can ask the media manager library for the same backup piece. The media manager daemon can be configured in such way that node 2 is not allowed to restore the backup piece backed up with other nodes.Oracle

Internal &

OAI U

se O

nly

Page 230: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-32

Copyright © Oracle Corporation, 2002. All rights reserved.

SBTWRITE or SBTREAD Failures

• SBTWRITE() and SBTREAD() transfer data from the server session to the media manager library.

• Typical failures include:– An I/O error happens while reading from or writing

to the backup media.– The user aborted the media manager backup

session.– The link between the media manager library and the

media manager session is broken.

SBTWRITE or SBTREAD FailuresThe sbtwrite() or sbtread() functions are responsible for the transfer of data from the Oracle server session to the media manager library. If the sbtwrite() or sbtread() functions fail during the backup, then the media manager cannot write data to a backup media (for example, to tape). If the sbtwrite() or sbtwrite2() fails during the restore, then the media manager cannot read data from a backup media and sbtread() will fail also. The following are the primary reasons for these functions to fail during a backup or restore:

• An I/O error happen while reading or writing the backup media.• The media manager session was aborted by a media manager operator.• The communication link is broken between the media manager library and the

media manager session manager.

Oracle In

ternal & O

AI Use

Only

Page 231: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-33

Copyright © Oracle Corporation, 2002. All rights reserved.

SBT API Return Codes

• SBT API Version 2 function errors have been greatly reduced.

• The new functions return a simple error code and a textual message.

• Errors returned from more than one function have been collapsed into a single error code.

• Version 1.1 codes are retained for backward compatibility only.

Return Codes for SBT API Version 2In SBT API version 2, the number of different types of errors that may be returned from API functions has been greatly reduced. The new functions return an error stating that the API function failed, and a textual description of the failure. Common error conditions which can be returned from more than one function have been consolidated into a single error code. All of the version 1.1 error codes have been retained for backwards compatibility. Following is the list of return codes for SBT API version V2:#define SBT_ERROR_OPERATOR 7500 /*Operator intervention requested*/#define SBT_ERROR_MM 7501 /* Catch-all media manager error */#define SBT_ERROR_NOTFOUND 7502 /* File Not Found */#define SBT_ERROR_EXISTS 7503 /* File already exists */#define SBT_ERROR_EOF 7504 /* End of File */#define SBT_ERROR_NOPROXY 7505 /* cant proxy copy the file */#define SBT_ERROR_NOWORK 7506 /* no proxy work in progress *//* error codes for sbtinit */#define SBTINIT_ERROR_ARG 7110 /* invalid argument(s) */#define SBTINIT_ERROR_SYS 7111 /* OS error */If a function returns SBT_ERROR_MM for example, 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.

Oracle In

ternal & O

AI Use

Only

Page 232: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-34

Copyright © Oracle Corporation, 2002. All rights reserved.

Media Manager Vendor Differences

Several media manager issues exist and must be taken into consideration:• Maximum supported file sizes • Uniqueness of backup piece name• Restoring to another node• Reconciling RMAN and the media manager's

catalog

Media Manager Vendor DifferencesA problem that can be encountered with making backups to tape is the backup file size created by the Oracle Server may be much larger than the file size 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 supported file size 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. Use the substitution variables provided by RMAN to generate unique backup piece names when writing backups to a media manager. If the FORMAT parameter is not specified, RMAN automatically generates a unique filename using the %U substitution variable. Make sure your media manager supports filenames generated by %U if you intend to use RMAN automatic file naming. The media manager considers the backup piece name as the filename 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, be sure of this functionality and also of any license limitations. Check the media management documentation to be sure.Oracle

Internal &

OAI U

se O

nly

Page 233: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-35

Copyright © Oracle Corporation, 2002. All rights reserved.

Summary

In this lesson, you should have learned how to:• Identify how Oracle makes backups to tape• Understand how the Media Management Interface

works• Identify the two versions of the SBT interface• Link the Oracle server with a media manager• Identify media manager issues and informational

messages

Oracle In

ternal & O

AI Use

Only

Page 234: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 6-36

Copyright © Oracle Corporation, 2002. All rights reserved.

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

Oracle In

ternal & O

AI Use

Only

Page 235: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Copyright © Oracle Corporation, 2002. All rights reserved.

Debugging RMAN

Oracle In

ternal & O

AI Use

Only

Page 236: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-2

Copyright © Oracle Corporation, 2002. All rights reserved.

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

Oracle In

ternal & O

AI Use

Only

Page 237: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-3

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Message Output

RMAN troubleshooting information can be found in the:• RMAN command output• RMAN trace file• The alert log• Oracle server trace file• The sbtio.log file

RMAN Message OutputRMAN command output contains actions relevant to the RMAN job as well as error messages generated by RMAN, the server, and the media vendor. RMAN error messages have an RMAN-nnnn prefix. The output is displayed to the terminal (standard output) but can be written to a file by defining the LOG option or by shell redirection..The RMAN trace file contains DEBUG output and is used only when the TRACEcommand option is used. The sbtio.log file contains vendor-specific information written by the media management software and can be found in USER_DUMP_DEST. Note that this log does not contain Oracle server or RMAN errors.The Oracle trace file contains detailed output generated by Oracle server processes. This file is created when an ORA-600 or ORA-3113 (following an ORA-7445) error message occurs, whenever RMAN cannot allocate a channel, and when the media management library fails to load. It can be found in USER_DUMP_DEST.The alert log contains a chronological log of errors, initialization parameter settings, and administration operations. Because it records values for overwritten control file records, it can be useful for RMAN maintenance when operating without a recovery catalog.Oracle

Internal &

OAI U

se O

nly

Page 238: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-4

Copyright © Oracle Corporation, 2002. All rights reserved.

The DEBUG Option

• The DEBUG option is used to:– See the generated PL/SQL– Determine precisely where an RMAN command is

hanging or faulting• The DEBUG option can be executed from an RMAN

command line, at the RMAN prompt or within a run block.

• The DEBUG option creates an enormous amount of output, so redirect the output to a trace file.

• DEBUG output redirected to a trace file:$ rman target / catalog rman/rman debug trace trace.log

The DEBUG OptionThe DEBUG option displays all SQL statements executed during RMAN compilations and the results of SQL statement executions. Any information generated by the recovery catalog PL/SQL packages is displayed also. In the example below, DEBUG output is written during the backup of data file 3, but not data file 4:RMAN> run {

debug on;allocate channel c1 type disk;backup datafile 3;debug off;backup datafile 4; }

Keep in mind that DEBUG output can be voluminous so make sure you have adequate disk space for the trace file. This simple backup session that generates no errors creates a trace file that is almost a half megabyte in size:$ rman target / catalog rman/rman debug trace sample.logRMAN> backup database;RMAN> host "ls –l sample.log";-rw-r--r-- 1 user02 dba 576270 Apr 6 10:38 sample.loghost command completeOracle

Internal &

OAI U

se O

nly

Page 239: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-5

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Code Layer Error Numbers

Important RMAN code layer error ranges:• 5000-5499: RESTORE or RECOVER compilation

errors• 5500-5999: DUPLICATE compilation errors• 6000-6999: General compilation errors• 7000-7999: General execution manager• 8000-8999: Generated PL/SQL errors and

messages• 10000-10999: Execution manager server side

errors• 12000-12999: Catalog package diagnostics

RMAN Code Layer Error Numbers In the RMAN message stack, you will find errors prefixed with RMAN-nnn, ORA-nnn, and finally errors preceded by the line Additional information:. The RMAN error codes are arranged in the following ranges:0550 - 0999 Command line interpreter1000 - 1999 Keyword analyzer2000 - 2999 Syntax analyzer3000 - 3999 Main layer4000 - 4999 Services layer5000 - 5499 Compilation of RESTORE or RECOVER5500 - 5999 Compilation of DUPLICATE6000 - 6999 General compilation7000 - 7999 General execution8000 - 8999 PL/SQL programs9000 - 9999 Low-level keyword analyzer10000 - 10999 Server-side execution11000 - 11999 Interface errors between PL/SQL and RMAN12000 - 12999 Recovery Catalog packages

Oracle In

ternal & O

AI Use

Only

Page 240: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-6

Copyright © Oracle Corporation, 2002. All rights reserved.

Media Manager Error Numbers

Media manager error ranges:• 7000-7012 SBTOPEN

• 7020-7025 SBTCLOSE

• 7040-7044 SBTWRITE

• 7060-7065 SBTREAD

• 7080-7086 SBTREMOVE

• 7090-7095 SBTINFO

• 7110-7111 SBTINIT

Media Manager Error NumbersWhen RMAN logs errors that occur through the media management API, RMAN returns an error message number with the "Additional information:" prefix. The media manager error codes are ranged by SBT function. A complete list of media manager error codes can be found in Appendix A. Below is an example of the message format:Additional information: 7005ORA-19511: Error received from media manager layer, error text:SBT error = 7005, errno = 2, sbtopen: system error

Oracle In

ternal & O

AI Use

Only

Page 241: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-7

Copyright © Oracle Corporation, 2002. All rights reserved.

Interpreting RMAN Error Stacks

• Read stack from bottom to top.• Look for "Additional information".• The RMAN-03009 identifies the failed command.RMAN-00571: ===========================================RMAN-00569: ======= ERROR MESSAGE STACK FOLLOWS =======RMAN-00571: ===========================================RMAN-03009: failure of backup command on c1 channel at 09/04/2001 13:18:19ORA-19506: failed to create sequential file, name="07d36ecp_1_1", parms=""ORA-27007: failed to open fileSVR4 Error: 2: No such file or directoryAdditional information: 7005Additional information: 1ORA-19511: Error from media manager layer,error text:

Interpreting RMAN Error StacksBecause of the amount of data that RMAN logs, you may find it difficult to identify the useful messages in the RMAN error stack. Note the following tips and suggestions:

• Because many of the messages in the error stack are not meaningful for troubleshooting, try to identify the one or two errors that are most important.

• Check for a line that says Additional information followed by an integer. This line indicates a media management error. The integer that follows refers to a code that is explained in the text of the error message.

• Read the messages from the bottom up because this is the order in which RMAN issues the messages. The last one or two errors displayed in the stack are often informative.

• Look for the RMAN-03002 or RMAN-03009 message immediately following the banner. The RMAN-03009 is the same as RMAN-03002 but includes the channel ID. If the failure is related to an RMAN command, these messages indicate which command failed. Syntax errors generate an RMAN-00558 error.

• Identify the basic type of error according to the error range chart on page 5. If the error is still unclear, then refer to Oracle9i Database Error Messages for more detail.

The example shown above is obviously a media manager problem. Looking at Appendix A, it can be determined that the 7005 error is related to a busy or defective tape device.Oracle

Internal &

OAI U

se O

nly

Page 242: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-8

Copyright © Oracle Corporation, 2002. All rights reserved.

Interpreting RMAN Errors

Starting backup at 06-APR-02allocated channel: ORA_SBT_TAPE_1channel ORA_SBT_TAPE_1: sid=15 devtype=SBT_TAPEchannel ORA_SBT_TAPE_1: WARNING: Oracle Test Disk APIallocated channel: ORA_SBT_TAPE_2channel ORA_SBT_TAPE_2: sid=14 devtype=SBT_TAPEchannel ORA_SBT_TAPE_2: WARNING: Oracle Test Disk APIRMAN-00571: ========================================RMAN-00569: ===== ERROR MESSAGE STACK FOLLOWS ======RMAN-00571: ========================================RMAN-03002: failure of backup command at 04/06/2002 15:32:42RMAN-06004: ORACLE error from recovery catalog database: RMAN-20202: tablespace not found in the recovery catalogRMAN-06019: could not translate tablespace name

RMAN ErrorsAssume that a backup of the SAMPLE tablespace was attempted. The resultant output is shown in the slide above. What happened? The RMAN-03002 error indicates that an RMAN command has failed, the BACKUP command, to be specific. Look at the last two messages in the stack first and immediately the reason for the command failure is obvious: no tablespace SAMPLE appears in the recovery catalog because the name was mistyped. Another interesting note here is the warning issued when the two channels were allocated for the backup. As can be seen from the output, the devices were configured to use the Oracle test disk API to simulate an SBT tape device. Remember that this media manager interface is provided by Oracle for testing only. Actual backup and recovery using the oracle.disksbt library is not recommended or supported.

Oracle In

ternal & O

AI Use

Only

Page 243: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-9

Copyright © Oracle Corporation, 2002. All rights reserved.

Interpreting Server Errors

RMAN> RECOVER TABLESPACE SAMPLE;Starting recover at 04-APR-02using channel ORA_DISK_1starting media recoverymedia recovery failedRMAN-00571: ===========================================RMAN-00569: ======= ERROR MESSAGE STACK FOLLOWS =======RMAN-00571: ===========================================RMAN-03002: failure of recover at 04/06/2002 10:12:22RMAN-11003: failure during parse/execution of SQL statement: alter database recover if needed tablespace SAMPLEORA-00283: recovery session canceled due to errorsORA-01124: cannot recover data file 8 - file is in use or recoveryORA-01110:data file 7: '/u01/user02/ORADATA/sample01.dbf'

Interpreting Server ErrorsAssume that an attempt to recover the SAMPLE tablespace was initiated. The RESTOREfails and the resultant output is shown above. What is the cause of the failure?The error stack is read from the bottom up, as suggested. The ORA-01110 message explains there was a problem with the recovery of datafile sample01.dbf. The second error indicates that Oracle cannot recover the data file because it is in use or already being recovered. The remaining RMAN errors indicate that the recovery session was cancelled due to the server errors. If you assume that this data file was not previously being recovered, the problem must be that the data file is online and needs to be taken offline and recovered.

Oracle In

ternal & O

AI Use

Only

Page 244: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-10

Copyright © Oracle Corporation, 2002. All rights reserved.

The sbttest Utility

• Oracle provides sbttest to test the SBT interface. • sbttest emulates the Oracle server and tries to

communicate with the media manager. • sbttest creates a file and backs it up to the

media manager.• sbttest reads the file to see if it was properly

backed up.• Create a backup file called testfile.f and write

trace output to sbtio.log:$ sbttest testfile.f -trace sbtio.log

The sbttest UtilityOn UNIX platforms, Oracle ships a utility called sbttest. This diagnostic tool is used to test the third-party vendor’s SBT interface. It works by emulating the Oracle server and initiating a backup using the installed SBT library. If the program runs without error, it returns a 0. This indicates the media manager software is installed and can accept a data stream and return the same data when requested. If any error is encountered, sbttestreturns a -1. This means the media management software is not installed or configured correctly. The sbttest utility is found in $ORACLE_HOME/bin. If sbttest is not available, download stksbt2.c at ftp://dlsun336.us.oracle.com/pub/sdk. It can be compiled and run on any supported UNIX platform.Type sbttest with no arguments and you should see the command documentation. The example above shows the syntax to create a test file called testfile.f and write the output to sbtio.log. When examining the output, if the program encounters an error, it provides messages describing the failure. If Oracle cannot find the library libobk.soyou will see something like the following:$ sbttest testfile.f -trace sbtio.logThe sbt function pointers are loaded from oracle.static library.libobk.so could not be loaded. Check that it is installed

Oracle In

ternal & O

AI Use

Only

Page 245: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-11

Copyright © Oracle Corporation, 2002. All rights reserved.

Checking Backup and Restore Progress

Run this query to check the progress of a backup or restore:SQL> SELECT SID, SERIAL#, CONTEXT, SOFAR, TOTALWORK,

2 ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE"3 FROM V$SESSION_LONGOPS4 WHERE OPNAME LIKE 'RMAN%'5 AND OPNAME NOT LIKE '%aggregate%'6 AND TOTALWORK != 07 AND SOFAR <> TOTALWORK;

SID SERIAL# CONTEXT SOFAR TOTALWORK %_COMPLETE------ -------- --------- ---------- ---------- ---------

13 75 1 9470 15360 61.6512 81 1 15871 28160 56.36

Checking Backup and Restore ProgressMonitor the progress of backups, 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 being processed by one job step, while aggregate rows describe the files processed by all job steps in an RMAN command. A job step is the creation or restore of one backup set or data file copy. Detail rows are updated with every buffer that is read or written during the backup step, so their granularity of update is small. Aggregate rows are updated when each job step completes, so their granularity of update is large. Important columns in V$SESSION_LONGOPS for RMAN include:• SID: The server session ID corresponding to an RMAN channel.• 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 other rows except proxy

copy (which does not update this column), the value is 1.Oracle In

ternal & O

AI Use

Only

Page 246: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-12

Checking Backup and Restore Progress (continued)• 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 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 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.

Oracle In

ternal & O

AI Use

Only

Page 247: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-13

Copyright © Oracle Corporation, 2002. All rights reserved.

Monitoring the Media Manager

To monitor the SBT events, run the following query:SQL> COLUMN EVENT FORMAT a10SQL> COLUMN SECONDS_IN_WAIT FORMAT 999SQL> COLUMN STATE FORMAT a20SQL> COLUMN CLIENT_INFO FORMAT a30SQL> SELECT p.SPID, EVENT, SECONDS_IN_WAIT AS SEC_WAIT,

2 STATE, CLIENT_INFO3 FROM V$SESSION_WAIT sw, V$SESSION s, V$PROCESS p4 WHERE sw.EVENT LIKE 'sbt%'5 AND s.SID=sw.SID6 AND s.PADDR=p.ADDR;

SPID EVENT SEC_WAIT STATE CLIENT_INFO---- --------- -------- ------- ---------------------------8642 sbtbackup 600 WAITING rman channel=ORA_SBT_TAPE_1

Monitoring the Media ManagerYou can use the event names in the dynamic performance event views to monitor RMAN calls to the media management API. The event names have one-to-one correspondence with the SBT functions like sbtinit(), sbtopen(), sbtread(), and so on.Before making a call to any of the functions in the media management API, the server adds a row in V$SESSION_WAIT, with the STATE column including the string WAIT. The V$SESSION_WAIT.SECONDS_IN_WAIT column shows the number of seconds that the server has been waiting for this call to return. After an sbt function is returned from the media manager, this row disappears.A row in V$SESSION_WAIT corresponding to an sbt event name does not indicate a problem, because the server updates these rows at runtime. The rows appear and disappear as calls are made and returned. However, if the SECONDS_IN_WAIT column is high, then the media manager may be hung.In the query executed above, note that RMAN has been waiting for the sbtbackupfunction to return for ten minutes (600/60).

Oracle In

ternal & O

AI Use

Only

Page 248: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-14

Copyright © Oracle Corporation, 2002. All rights reserved.

Monitoring Recovery Manager Sessions

To identify what a server session is doing, correlate a process with a channel during a backup:• Start RMAN and connect to the target database

and recovery catalog database.• If monitoring multiple sessions, set COMMAND ID

after allocating channels and backup the object.• Query the joined V$SESSION and V$PROCESS

views while the backup is executing.

Monitoring Recovery Manager SessionsTo identify which server sessions correspond to which RMAN channels, you can query V$SESSION and V$PROCESS. The SPID column of V$PROCESS identifies the operating system ID number for the process or thread. On UNIX the SPID column shows the process ID, on NT the SPID column shows the thread ID. There are two basic methods for obtaining this information, depending on whether you have multiple RMAN sessions active concurrently. When only one RMAN session is active, execute the following query on the target database while the RMAN job is running:SQL> COLUMN CLIENT_INFO FORMAT a30SQL> COLUMN SID FORMAT 999SQL> COLUMN SPID FORMAT 9999SQL> SELECT s.SID, p.SPID, s.CLIENT_INFO

2 FROM V$PROCESS p, V$SESSION s3 WHERE p.ADDR = s.PADDR4 AND CLIENT_INFO LIKE 'rman%';SID SPID CLIENT_INFO---- ------------ ------------------------------

15 2714 rman channel=ORA_SBT_TAPE_113 2715 rman channel=ORA_SBT_TAPE_2

Oracle In

ternal & O

AI Use

Only

Page 249: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-15

Monitoring Recovery Manager Sessions (continued)When multiple RMAN sessions are running, it will help to correlate a process with a channel during a backup using the SET COMMAND ID command as shown below:

1. In each session, set the COMMAND ID to a different value after allocating the channels and then back up the desired object. For example, enter the following in session 1:RUN{ALLOCATE CHANNEL c1 TYPE sbt;SET COMMAND ID TO 'sess1';BACKUP DATABASE;}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$PROCESSviews while the RMAN job is executing. For example, enter:SELECT SID, SPID, CLIENT_INFOFROM V$PROCESS p, V$SESSION sWHERE p.ADDR = s.PADDRAND 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_idFor example, the following shows sample output:SID SPID CLIENT_INFO---- ------------ ------------------------------11 8358 id=sess115 8638 id=sess214 8374 id=sess1,rman channel=c19 8642 id=sess2,rman channel=c1

Oracle In

ternal & O

AI Use

Only

Page 250: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-16

Copyright © Oracle Corporation, 2002. All rights reserved.

Determining Which Data Files Require Recovery

• Query V$RECOVER_FILE to determine:– Which files need to be recovered– Why the files need recovery– The beginning SCN and time needed for recovery

• Query V$DATAFILE and V$TABLESPACE to get file and tablespace names.

SQL> SELECT * FROM V$RECOVER_FILEFILE# ONLINE ONLINE_ ERROR CHANGE# TIME----- ------- ------- ---------- ---------- ---------

4 ONLINE ONLINE FILE NOT 0FOUND

5 ONLINE ONLINE FILE NOT 0FOUND

8 OFFLINE OFFLINE OFFLINE 0

Determining Which Data Files Require RecoveryYou can often use the dynamic performance view V$RECOVER_FILE to determine which files need to be recovered and why they need to be recovered. SQL> SELECT * FROM V$RECOVER_FILEFILE# ONLINE ONLINE_ ERROR CHANGE# TIME----- ------- ------- --------------- ---------- -------

4 ONLINE ONLINE FILE NOT FOUND 05 ONLINE ONLINE FILE NOT FOUND 08 OFFLINE OFFLINE OFFLINE 0

Query V$DATAFILE and V$TABLESPACE to obtain filenames and tablespace namesfor data files requiring recovery. For example, enter:SQL> SELECT d.NAME, t.NAME FROM V$DATAFILE d, V$TABLESPACE t

2 WHERE t.TS# = d.TS# AND d.FILE# IN (4,5,8);# use values obtained from V$RECOVER_FILE query

NAME NAME---------------------------------- ---------------/oracle/oradata/trgt/drsys01.dbf DRSYS/oracle/oradata/trgt/example01.dbf EXAMPLE/oracle/oradata/trgt/users01.dbf USERS

Oracle In

ternal & O

AI Use

Only

Page 251: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-17

Copyright © Oracle Corporation, 2002. All rights reserved.

Insufficient Privileges

• The ORA-1031 error indicates that an attempted operation is not allowed for the user specified.

• First determine which database is returning the error:– Is this the target, catalog, or auxiliary instance?– Connect to each separately to confirm:

$ rmanRMAN> connect target /RMAN> connect catalog rman_user/pswd@catalogRMAN> connect auxiliary sys/paswd@aux

Insufficient Privileges The RMAN user created for the recovery catalog owner needs to be granted the privileges necessary for catalog ownership. Connect to the recovery catalog database and grant RECOVERY_CATALOG_OWNER to the RMAN user:SQL> connect system/managerSQL> 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. Prior to troubleshooting the error at the target, find out where they are running RMAN—from the target database software installation, or from a different Oracle_Home or a different system altogether.When connecting locally to the target database, the user must be a member of the operating system group responsible for managing SYSDBA privileges, usually DBA. If an ORA-1031 is logged when connecting locally, make sure the username 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 databaseOracle

Internal &

OAI U

se O

nly

Page 252: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-18

Insufficient Privileges (continued)Whenever the listener is being used to make a SYSDBA connection, a password file must be used at the target instance.The password file exists as:%ORACLE_HOME%\database\pwdSID.ora on Windows NT $ORACLE_HOME/dbs/orapwSID on UNIXFor a password file to be utilized, the REMOTE_LOGIN_PASSWORDFILE initialization parameter must be set to SHARED or EXCLUSIVE for the target instance (it is inconsequential at the catalog database). The password file can be built or rebuilt using the command line utility orapwd. $ orapwd file=$ORACLE_HOME/dbs/orapwSID password=Asecret1

Oracle In

ternal & O

AI Use

Only

Page 253: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-19

Copyright © Oracle Corporation, 2002. All rights reserved.

UNIX Tape Backup Failure

The media manager has been linked with Oracle, but cannot perform backups to SBT_TAPE.

RMAN-00571: ==========================================RMAN-00569: ======ERROR MESSAGE STACK FOLLOWS ========RMAN-00571: ==========================================RMAN-03002: failure of backup command at 04/07/2002 15:42:22ORA-19554: error allocating device, device type: SBT_TAPE, device name: ORA-27000: skgfqsbi: failed to initialize storage subsystem layerAdditional information: 4110ORA-19511: Error received from media manager layer, error text:

SBT error = 4110, errno = 0, Oracle Test Disk API: BACKUP_DIRenvironment variable is not set

UNIX Tape Backup FailureWhen the media management software is not linked correctly, the most common error is an ORA-19511 and a 4110 media manager return code. The 4110 error code is issued because the BACKUP_DIR environment variable is not set for the channel servicing the backup. This indicates that Oracle is linked with the dummy API (oracle.disksbt) instead of the media manager API. If the customer was really using the dummy API for testing , they must set the BACKUP_DIR location by using the PARMS parameter of the ALLOCATE CHANNEL command. Otherwise the media manager was improperly linked.On UNIX, in Oracle8i the name of the media manager library must be $ORACLE_HOME/lib/libobk.so. The exception is Oracle 8.1.6 on Solaris, where the media manager library should be $ORACLE_HOME/lib/libdsbtsh8.so (see bug 1252142). To fix this on 8.1.6, shutdown your database. Then follow the steps below:cd $ORACLE_HOME/libmv libdsbtsh8.so libdsbtsh8.soORIGln -s <media vendor library> libdsbtsh8.so

On Oracle9i, have the customer use SHOW CHANNEL to look at the tape device settings.RMAN> show channel;Oracle

Internal &

OAI U

se O

nly

Page 254: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-20

UNIX Tape Backup Failure (continued)CONFIGURE CHANNEL DEVICE TYPE DISK RATE 5 M FORMAT "$HOME/ORADATA/u06/%U" MAXOPENFILES 20;

CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=oracle.disksbt';

This particular example shows that indeed the device SBT_TAPE is 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. The easiest way to fix this problem is to use the SBT_LIBRARY option of the CONFIGURE command to properly define the channel and load the proper library:RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=vendors_library';

Oracle In

ternal & O

AI Use

Only

Page 255: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-21

Copyright © Oracle Corporation, 2002. All rights reserved.

NT Tape Backup Failure

• Media manager has been installed on NT, but does one of the following when backing up to SBT_TAPE:– Backs up to the $ORACLE_HOME/database

directory on disk– Returns an SBT error of 4110– Fails to perform the backup

• Look for an RMAN-08503 in the RMAN log. RMAN-08503:…comment=API Version 1.0, MMS Version 1.0.1.2 RMAN-008526: channel tst WARNING: Oracle Test Disk API

NT Tape Backup FailureThe symptoms on NT might manifest themselves in one of several ways:

• The backup fails entirely, a 4110 is possibly issued.• The user specifies ‘sbt_tape’, the backup succeeds but the backup is written to

DISK

Evidence that the vendor interface is not used can be found in the RMAN log. Look for an RMAN-08503, this usually means the default Oracle test disk API software is being used. Reasons why the backups are not written to tape when SBT_TAPE is used include:

• Oracle cannot find the library to load, so it uses the dummy disk API instead. Windows NT searches for the dll called orasbt.dll in its default directory path (our developers recommend to the BSP members that they put their library in the SYSTEM32 system directory).

• There is an error in the vendor’s DLL. Either the DllMain() function returned an error, or the vendor did not implement all of the SBT functions.

The loadsbt.exe utility can be used to diagnose why the DLL cannot be loaded. It is available for download at ftp://dlsun336.us.oracle.com/pub/sdk.Oracle

Internal &

OAI U

se O

nly

Page 256: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-22

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Session Is Hung in Media Manager

• Possible reasons why backups are not proceeding:– The backup abnormally terminates– A server side or media management error– One of the channels is waiting for a tape resource

• Check for a hang situation by querying V$SESSION and V$SESSION_WAIT.

SQL> SELECT p.SPID, EVENT, SECONDS_IN_WAIT AS SEC_WAIT, 2 STATE, CLIENT_INFO 3 FROM V$SESSION_WAIT sw, V$SESSION s, V$PROCESS p 4 WHERE sw.EVENT LIKE ’sbt%’ AND s.SID=sw.SID 5 AND s.PADDR=p.ADDR

RMAN Session Is Hung in Media ManagerThe best way to terminate RMAN when the connections for the allocated channels are hung in the media manager is to kill the Oracle process of the connections. The RMAN process detects this termination and proceeds to exit, removing all connections except target connections that are still operative in the media management layer. To terminate an Oracle process that is hung in the media manager:

1. Query V$SESSION and V$SESSION_WAIT as illustrated above. Below is a typical result of the query:SPID EVENT SEC_WAIT STATE CLIENT_INFO---- --------- -------------- -----------------------------8642 sbtwrite2 600 WAITING rman channel=ORA_SBT_TAPE_18374 sbtwrite2 600 WAITING rman channel=ORA_SBT_TAPE_2

2. Kill 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.

Oracle In

ternal & O

AI Use

Only

Page 257: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-23

RMAN Session Is Hung in Media Manager (continued)If the problem is persistent, you may need to investigate the cause. First, check to see what the server processes performing the backup are doing. Is it only one process hanging, or all? If only one, check to see what it is doing.

• Look at V$SESSION_WAIT and note where wait_time = 0• Check what part of the Oracle code you are in by using oradebug:

RMAN-03022: compiling command: allocateRMAN-03023: executing command: allocateRMAN-08030: allocated channel: T1RMAN-08500: channel T1: sid=12 devtype=SBT_TYPESQL> select sid, paddr from v$session where sid = 12;

SID PADDR--------- --------

12 81355388SQL> select addr, spid from v$process where addr='81355388';ADDR SPID--------- --------81355388 21397SQL> oradebug setospid 21397SQL> oradebug event immediate trace name errorstack level 10;

• 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

Oracle In

ternal & O

AI Use

Only

Page 258: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-24

Copyright © Oracle Corporation, 2002. All rights reserved.

RPC Call Fails

• A backup job is started and a "failed to start RPC call" error message is raised:

• The message indicates:– The target database instance is slow– A timing problem occurred

channel c8: including datafile number 47 in backupsetRPC call appears to have failed to start on channel c9RPC call ok on channel c9channel c3: including datafile number 18 in backupset

RPC Call Fails This is indicative of an internal Oracle timing problem. When RMAN begins an RPC, it checks the V$SESSION performance view. The RPC updates the information in the view to indicate when it starts and finishes. Sometimes RMAN checks V$SESSION before the RPC has indicated it has started, which in turn generates the following message:RPC call appears to have failed

This is only a real problem if a message stating "RPC call ok on channel CHname" does not appear in the output immediately following the message stating:"RPC call appears to have failed".

Oracle In

ternal & O

AI Use

Only

Page 259: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-25

Copyright © Oracle Corporation, 2002. All rights reserved.

Snapshot Control File Creation Failure

• Backup fails because RMAN cannot make a snapshot control file.

• Usually, the control file is being backed up by another session.

RMAN-00571: ============================================RMAN-00569: ======= ERROR MESSAGE STACK FOLLOWS ========RMAN-00571: ============================================RMAN-03002: failure of backup command at 04/07/2002 16:32:21ORA-00230: operation disallowed: snapshot controlfile enqueue unavailable

Snapshot Control File Creation FailureWhen RMAN needs to back up the control file, it first creates a snapshot of the control file. If one RMAN job is already backing up the control file while another needs to create a new snapshot control file, then you may see the following message:waiting for snapshot controlfile enqueue

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> SELECT s.SID, USERNAME AS "User", PROGRAM, MODULE,2 ACTION, LOGON_TIME "Logon", l.* FROM V$SESSION s,3 V$ENQUEUE_LOCK l WHERE l.SID = s.SID AND l.TYPE = 'CF'4 AND l.ID1 = 0 AND l.ID2 = 2;

Oracle In

ternal & O

AI Use

Only

Page 260: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-26

Snapshot Control File Creation Failure (continued)After you have determined which job is creating the enqueue, you can do one of the following:

• Wait until the job creating the enqueue completes• Cancel the current job and restart it after the job creating the enqueue completes• Cancel the job creating the enqueue

Commonly, enqueue situations occur when a job is writing to a tape drive, but the tape drive is waiting for a new cassette to be inserted. If you start a new job in this situation, then you will probably receive the enqueue message because the first job cannot complete until the new tape is loaded.

Oracle In

ternal & O

AI Use

Only

Page 261: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-27

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Cannot Locate an Archived Log

• The RMAN-06059 occurs when RMAN tries to back up an archived log that is not accessible.

• This is usually caused by deleting archived logs with operating system commands.

RMAN-00571: ============================================RMAN-00569: ======== ERROR MESSAGE STACK FOLLOWS =======RMAN-00571: ============================================RMAN-03002: failure of backup command at 04/07/2002 15:04:21RMAN-06059: expected archived log not found, lost of archived log compromises recoverabilityORA-19625: error identifying file /u01//ORADATA/u05/1_9.dbfORA-27037: unable to obtain file statusSVR4 Error: 2: No such file or directory

RMAN Cannot Locate an Archived LogThis problem occurs when the archived log that RMAN is looking for cannot be accessed by RMAN, or the recovery catalog needs to be resynchronized. Often, this error occurs when you delete archived logs with an operating system command, which means that RMAN is unaware of the deletion. The RMAN-6059 error occurs because RMAN attempts to back up a log that the repository indicates still exists but is no longer there or has permission, user, or group errors.Make sure that the archived logs exist in the specified directory and that the RMAN catalog is synchronized. Check the following:

1. Make sure the archived log file that is specified by the RMAN-6059 error exists in the correct directory.

2. Check that the operating system permissions are correct for the archived log. The owner of the log file should be the owner of the Oracle binaries and the group associated with the file should be DBA.

3. If the file appears to be correct, then try synchronizing the catalog by running the the RESYNC CATALOG command.Oracle

Internal &

OAI U

se O

nly

Page 262: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-28

RMAN Cannot Locate an Archived Log (continued)If you know that the logs are unavailable because you deleted them by using an operating system utility, then run the following command at the RMAN prompt to update RMAN metadata:RMAN> CROSSCHECK ARCHIVELOG ALL;allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=15 devtype=DISKvalidation failed for archived logarchive log filename=/u01/user02/ORADATA/u05/1_1.dbf recid=3 stamp=457814434validation succeeded for archived logarchive log filename=/u01/user02/ORADATA/u05/1_2.dbf recid=4 stamp=458057563validation succeeded for archived log...archive log filename=/u01/user02/ORADATA/u05/1_29.dbf recid=2 stamp=457378699Crosschecked 14 objects

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 sbt2> ARCHIVELOG ALL3> DELETE ALL INPUT;

Oracle In

ternal & O

AI Use

Only

Page 263: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-29

Copyright © Oracle Corporation, 2002. All rights reserved.

Missing Log Causes Duplication Failure

Duplicate database fails with the following error stack:RMAN-00571: ============================================RMAN-00569: ======= ERROR MESSAGE STACK FOLLOWS ========RMAN-00571: ============================================RMAN-03002: failure of Duplicate Db command at 04/04/2002 21:14:33RMAN-03015: error occurred in stored script Memory ScriptRMAN-06053: unable to perform media recovery because of missing logRMAN-06025: no backup of log thread 1 seq 16 scn 145858 found to restore

Missing Log Causes Duplication FailureThe customer attempted to duplicate a database with the DUPLICATE command, but received the error stack as shown above. The problem is that RMAN is not able to apply all the archived logs needed for complete recovery. For example, if the customer only backed up logs through sequence 15, but the most recent archived log is sequence 16, then the DUPLICATE command fails. When creating the duplication script, use the SET UNTIL command to specify a log sequence number for incomplete recovery. For example, to terminate recovery after applying log sequence 15, run the following RMAN block:RMAN> RUN {SET UNTIL SEQUENCE 16 THREAD 1; # recovers up to but not including log 16DUPLICATE TARGET DATABASE TO ’dupdb’;}

Oracle In

ternal & O

AI Use

Only

Page 264: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-30

Copyright © Oracle Corporation, 2002. All rights reserved.

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

Oracle In

ternal & O

AI Use

Only

Page 265: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 7-31

Copyright © Oracle Corporation, 2002. All rights reserved.

Practice Overview: Debugging RMAN

This practice covers the following topics:• Analyzing RMAN errors• Analyzing media manager errors• Analyzing OS errors on the RMAN stack

Oracle In

ternal & O

AI Use

Only

Page 266: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 267: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Performance Tuning

Oracle In

ternal & O

AI Use

Only

Page 268: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-2

Copyright © Oracle Corporation, 2002. All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:• Discuss general performance tips and techniques• Discuss and implement synchronous and

asynchronous I/O• Tune the RMAN BACKUP/RESTORE process

Oracle In

ternal & O

AI Use

Only

Page 269: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-3

Copyright © Oracle Corporation, 2002. All rights reserved.

Tuning RMAN

• RMAN BACKUP and RESTORE operations have the following components:– Reading or writing data– Processing data by copying and validating blocks

• The slowest of these operations is the bottleneck.• Tuning RMAN requires that the bottlenecks be

identified and addressed.

Tuning RMANRMAN backup and restore operations have the following distinct components:

• Reading or writing input data• Processing data by validating and copying blocks from the input to the output

buffersThe 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 physical media. The key to tuning RMAN is understanding I/O. RMAN’s backup and restore jobs use two types of I/O buffers: disk and tertiary storage (usually tape). When performing a backup, RMAN reads input files using disk buffers and writes the output backup file by using either disk or tape buffers. 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. Hence, you can easily determine how much time 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 concepts such as synchronous and asynchronous I/O, disk and tape buffers, and channel architecture. When you understand these concepts, then you can learn how to use fixed views to monitor bottlenecks.Oracle

Internal &

OAI U

se O

nly

Page 270: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-4

Copyright © Oracle Corporation, 2002. All rights reserved.

RMAN Disk Buffer Allocation

The buffer allocation algorithm:Allocation Rule

1 MB buffers are allocated so that the total buffer size for all the input files is 16 MB

512 KB are allocated so that the total buffer size for all the files is less than 16 MB

RMAN allocates a fixed 4 disk buffers of 128 KB for each file, so that the total size is 512 KB for each file

Multiplexing Level

Less than or equal to 4

Greater than 4 but less than or equal to 8

Greater than 8

RMAN Disk Buffer AllocationRMAN uses two different types of buffers for I/O: disk and tape. To understand how RMAN allocates disk buffers, you must understand how RMAN multiplexing works. RMAN multiplexing is the number of files in a backup read simultaneously and then written to the same backup piece. The degree of multiplexing depends on the FILESPERSET parameter of the BACKUP command as well as the MAXOPENFILESparameter of the CONFIGURE CHANNEL or ALLOCATE CHANNEL commands.For example, assume that you back up two data files with one channel. You set FILESPERSET to 3 and set MAXOPENFILES to 8. In this case, the number of files in each backup set is 2 (the lesser of FILESPERSET and the files read by each channel), and so the level of multiplexing is 2 (the lesser of MAXOPENFILES and the number of files in each backup set). When RMAN backs up from disk, it uses the algorithm described in the table above.

Oracle In

ternal & O

AI Use

Only

Page 271: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-5

Copyright © Oracle Corporation, 2002. All rights reserved.

Disk Buffer Allocation Example

Data files

1 MB1 MB

1 MB1 MB

Input Disk Buffers

ChannelFILESPERSET = 4MAXOPENFILES = 4

1 MB1 MB

1 MB1 MB

1 MB1 MB

1 MB1 MB

1 MB1 MB

1 MB1 MB

Disk Buffer Allocation ExampleIn the example shown above, one channel is backing up four data files. MAXOPENFILESis set to 4 and FILESPERSET is set to 4. So the level of multiplexing is 4 in this example.The total size of the buffers for each data file is 4 MB. To calculate the total size of the buffers allocated in a backup set, multiply the total bytes for each data file by the number of data files being concurrently accessed by the channel, and then multiply this number by the number of channels.Assume that you use one channel to back up four data files, and use the settings shown in above. In this case, multiply as follows to obtain the total size of the buffers allocated for the backup:4 MB per data file x 1 channel x 4 data files per channel = 16 MB

Set the MAXOPENFILES parameter so that the number of files read simultaneously is just enough to utilize the output device fully. This consideration is especially important when the output device is tape.

Oracle In

ternal & O

AI Use

Only

Page 272: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-6

Copyright © Oracle Corporation, 2002. All rights reserved.

Tape Buffer Allocation

256 kb256 kb

256 kb256 kb

Tape Buffers

DIGITAL DATA STORAGE

If BACKUP_TAPE_IO_SLAVES = TRUE, tape buffers are allocated from the SGA.

If BACKUP_TAPE_IO_SLAVES is false, tape buffers are allocated from the PGA.

Channel

Tape Buffer AllocationIf you make a backup to a tape device, then Oracle allocates four buffers for each channel for the tape writers (or reads if doing a restore). Oracle allocates these buffers only if the channel is an SBT channel. Typically, each tape buffer is 256 KB. To calculate the total size of buffers used during a backup or restore, multiply the buffer size by 4, and then multiply this product by the number of channels.As illustrated in the example above, assume that you use one tape channel and each buffer is 256 KB. In this case, the total size of buffers used during a backup is as follows:256 KB per buffer x 4 buffers per channel x 1 channel = 1024 KB

RMAN allocates the tape buffers in the SGA or the PGA, depending on whether I/O slaves are used. If the initialization parameter BACKUP_TAPE_IO_SLAVES = 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 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.Oracle

Internal &

OAI U

se O

nly

Page 273: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-7

Copyright © Oracle Corporation, 2002. All rights reserved.

Synchronous Versus Asynchronous I/O

1. Server process writes data to buffer

Tape Buffers

Server Process

2. Server process waits; tape process writes data

3. Tape process signals finish

4. Server process writes data to new buffer

DIGITAL DATA STORAGE

Synchronous I/O

01001000100100

Synchronous Versus Asynchronous I/OWhen RMAN reads or writes data, the I/O is either synchronous or asynchronous. When the I/O is synchronous, a server process can perform only one task at a time. When it is asynchronous, a server process can begin an I/O and then perform other work while waiting for the I/O to complete. It can also begin multiple I/O operations before waiting for the first to complete.You can set initialization parameters that determine the type of I/O. If you set BACKUP_TAPE_IO_SLAVES to true, then the tape I/O is asynchronous. Otherwise, the I/O is synchronous. The example above shows synchronous I/O in a backup to tape. The following steps occur in a synchronous transfer:

1. A server process writes blocks to a tape buffer.2. The tape process writes data to tape. The server process is idle while the media

manager copies data from the Oracle buffers to the media manager’s internal buffers.

3. The tape process relays to the server process that it has completed writing.4. The server process can initiate a new task.Oracle

Internal &

OAI U

se O

nly

Page 274: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-8

Copyright © Oracle Corporation, 2002. All rights reserved.

Synchronous Versus Asynchronous I/O

1. Server process writes data to buffer

Tape Buffers

Server Process

2. Tape process writes data

DIGITAL DATA STORAGE

Asynchronous I/O

01001000100100 0100100

3. Server process writes to new buffers while step 2 completes

Synchronous Versus Asynchronous I/O (continued)Many operating systems support native asynchronous I/O and Oracle can take advantage of this feature whenever it is available. It is recommended that you always set BACKUP_TAPE_IO_SLAVES to true when the platform supports it. On operating systems that do not support native asynchronous I/O, Oracle can simulate it by using special I/O slave processes that are dedicated to performing I/O on behalf of another process. You can control disk I/O slaves by setting the DBWR_IO_SLAVES parameter to a nonzero value. Oracle allocates four backup disk I/O slaves for any nonzero value of DBWR_IO_SLAVES.The example above illustrates asynchronous I/O in a backup to tape. The steps that occur in an asynchronous exchange are detailed below:

1. A server process writes blocks to a tape buffer.2. The tape process writes data to tape. While the tape process is writing, other server

processes are free to process more input blocks and fill more output buffers.3. Two spawned server processes write to tape buffers as the initial tape process writes

to tape.Oracle In

ternal & O

AI Use

Only

Page 275: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-9

Copyright © Oracle Corporation, 2002. All rights reserved.

Setting LARGE_POOL_SIZE

• If LARGE_POOL_SIZE is not set, the Oracle server tries to get memory from the shared pool.

• If LARGE_POOL_SIZE is not big enough, the server does not allocate buffers from the shared pool.

• If the server cannot get enough memory, it allocates buffers from local process memory.– The Oracle server writes a message to the alert log

indicating that synchronous I/O is used for this backup.

ksfqxcre: failure to allocate shared memory means sync I/O will be used whenever async I/O to file not supported natively

Setting LARGE_POOL_SIZERequests for contiguous memory allocations from the shared pool are small, usually under 5 KB in size. It is possible however, 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 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 Oracle9i suggested LARGE_POOL_SIZE is calculated as:number_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.

Oracle In

ternal & O

AI Use

Only

Page 276: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-10

Copyright © Oracle Corporation, 2002. All rights reserved.

Performance Monitoring

• Useful views for monitoring I/O:– V$BACKUP_SYNC_IO

– V$BACKUP_ASYNC_IO

• The following rows will exist for a backup or restore:– One row for each data file– One aggregate data file row– One row for each backup piece

• Whether or not I/O is synchronous depends on how the controlling process views it.

Performance MonitoringThe 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 do not need to 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.Which view the SBT_TAPE row appears in is a good indication of whether the BACKUP_TAPE_IO_SLAVES parameter is set and of course, 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.

Oracle In

ternal & O

AI Use

Only

Page 277: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-11

Copyright © Oracle Corporation, 2002. All rights reserved.

Asynchronous I/O Bottlenecks

• If LONG_WAITS + SHORT_WAITS is a large part of IO_COUNT then the file is probably a bottleneck.

• LONG_WAITS = number of times the backup/restore process told the OS to wait until I/O was complete

• SHORT_WAITS = Calls the backup/restore process made polling for I/O completion in nonblocking mode

• WAITS times should be zero to avoid bottlenecks.

Asynchronous I/O BottlenecksThe LONG_WAITS column shows the number of times the backup/restore process told the O/S to wait until an I/O was complete. The SHORT_WAITS column shows the number of times the backup/restore process made an O/S call to poll for I/O completion in a non-blocking mode. On some platforms, the asynchronous I/O implementation may cause the calling process to wait for the I/O to complete while performing a non-blocking poll for I/O.If the SHORT_WAIT_TIME_TOTAL column is equal to or greater than the LONG_WAIT_TIME_TOTAL column, then your platform probably blocks for I/O completion when performing non-blocking I/O polling. In cases like this, the SHORT_WAIT_TIME_TOTAL column represents real I/O time for this file.If the SHORT_WAIT_TIME_TOTAL is low compared to the total time for this file, then the delay is most likely caused by other factors, such as process swapping. If possible, tune your operating system so the I/O wait time appears in the LONG_WAIT_TIME_TOTAL column.

Oracle In

ternal & O

AI Use

Only

Page 278: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-12

Copyright © Oracle Corporation, 2002. All rights reserved.

Synchronous I/O Bottlenecks

• It is hard to identify specific bottlenecks because all synchronous I/O is considered to be a bottleneck.

• Use DISCRETE_BYTES_PER_SECOND column from V$BACKUP_SYNC_ IO to see the I/O rate. – Compare this rate with the device's maximum rate.– If the rate is lower than the device specifies, this is a

tuning opportunity.

Synchronous I/O BottlenecksWhen using synchronous I/O, it can easily be determined how much time backup jobs require because devices only perform one I/O task at a time. Oracle I/O uses a polling mechanism rather than an interrupt mechanism to determine when each I/O request completes. Because the backup or restore process is not immediately notified of I/O completion by the operating system, you cannot determine the duration of each I/O. Use V$BACKUP_SYNC_IO to determine the source of backup or restore bottlenecks and to determine the progress of backup jobs. V$BACKUP_SYNC_IO contains rows when the I/O is synchronous to the process (or thread, on some platforms) performing the backup.

Oracle In

ternal & O

AI Use

Only

Page 279: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-13

Copyright © Oracle Corporation, 2002. All rights reserved.

Tape Backup Speed

The following factors affect the speed of the backup to tape:• Native transfer rate• Tape compression• Tape streaming• Physical tape block size

Tape Backup SpeedThe tape native transfer rate is the write speed without compression. This speed represents the upper limit of the backup rate. The upper limit of your backup performance should be the aggregate transfer rate of all the tape drives. If the backup is performing at that rate, and an excessive amount of CPU is not being used, then tuning RMAN will not help.Tape compression greatly affects backup performance. If the tape has good compression, then the sustained backup rate is faster. For example, if the compression ratio is 2:1 and native transfer rate of the tape drive is 6 MB/s, then the resulting backup speed is 12 MB/s.Almost all tape drives currently on the market are fixed-speed, streaming tape drives. In other words, these drives can only write data at one speed. As a result, when they run out of data to write to tape, they must slow down and stop. For example, when the drive's buffer empties, the tape is moving so quickly that it actually overshoots and must rewind past the point where it stopped writing.The physical tape block size can affect backup performance. The block size is the amount of data written by media management software to a tape in one write operation. The common rule is that a larger tape block size leads to a faster backup. The physical tape block size is controlled by the media management software.

Oracle In

ternal & O

AI Use

Only

Page 280: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-14

Copyright © Oracle Corporation, 2002. All rights reserved.

Tape Subsystem Performance Rules

• The more tape drives, the faster the backup and restore.

• The faster the tape drives, the faster the backup.• Allocate one channel per physical device:

– If more channels than physical drives are used, then the backup sets will be intermingled

– Similar to multiplexing data files• If tape drive is not streaming, increase the number

of files multiplexed.• Back up files that are likely to be restored together

in the same backup set.

Performance RulesIt may sound obvious to some, but you can speed the backup and restore process by buying more tape drives, faster tape drives, or ideally a combination of the two. Generally speaking, 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 then number of files multiplexed together may help. Be aware 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 only 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.

Oracle In

ternal & O

AI Use

Only

Page 281: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-15

Copyright © Oracle Corporation, 2002. All rights reserved.

Empty Files and Incremental Backups

• When backing up files with many empty blocks, it may become difficult to keep the buffers full.

• This condition will keep the tape drives from streaming.

• When doing incremental backups, set multiplexing level to 50 to keep tape streaming.

• Full or level 0 backups require a lower multiplexing value.

Empty Files and Incremental Backups When performing a full backup of files that are largely empty, or when performing an incremental backup when few blocks have changed, you may not be able to supply data to the tape fast enough to keep it streaming. In either case, you can improve performance by increasing the level of multiplexing. An incremental backup is an RMAN backup in which only modified blocks are backed up. Incremental backups are not necessarily faster than full backups because Oracle still reads the entire data file to take an incremental backup. If tape drives are not locally attached, then incremental backups can be faster. You must consider how much bandwidth exists for reading the disks compared to the bandwidth for writing to the tapes. If tape bandwidth is limited compared to disk, then incremental backups may help.If only a few blocks have changed in an incremental backup, then you need to input many buffers from the data file before you accumulate enough blocks to fill a buffer and write to tape. Therefore the tape drive may not stream. If you set the level of multiplexing to a large value, then you can scan many data files in parallel, the output buffers for the tape drive are filled quickly, and you can write them frequently to keep the drive streaming. The FILESPERSET value should be less than or equal to MAXOPENFILES. For example, set both parameters to 8, and raise this value if the tape drive does not stream.Oracle

Internal &

OAI U

se O

nly

Page 282: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-16

Empty Files and Incremental Backups (continued)For an incremental backup, 50 is a good value for the level of multiplexing. For a full or incremental level 0 backup, the level of multiplexing should be a lower value such as 4 or 8. A good way to test whether your tape backup performance is slow because of empty files is to try backing up archived logs, which contain nothing but data. In other words, they do not contain empty space.

Oracle In

ternal & O

AI Use

Only

Page 283: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-17

Copyright © Oracle Corporation, 2002. All rights reserved.

Control Tape Buffer Size with BLKSIZE

• Adjusting the size of the tape buffer can help to keep tape streaming.

• Use the BLKSIZE option of PARMS to set the desired buffer size:

• Set BLKSIZE to a value that is a little less than the tape block size of the media manager.

RMAN> CONFIGURE CHANNEL DEVICE TYPE SBT_TAPE2> PARMS="BLKSIZE=524288";

Control Tape Buffer Size with BLKSIZEIf the tape is not streaming, but the problem is not due to an incremental backup or by backing up empty files, then try adjusting the block size of the tape buffer. You can change the size of each tape buffer using the PARMS parameter of the ALLOCATE CHANNEL or CONFIGURE CHANNEL command. If the BLKSIZE parameter for PARMS is supported on your platform, then you can set it to the desired size of each buffer. For example, configure an SBT channel as follows:RMAN> CONFIGURE CHANNEL DEVICE TYPE SBT PARMS="BLKSIZE=524288";

A good rule of thumb is to set BLKSIZE to a value that is a little less than the tape block size of the media manager. What "a little less" means depends on the media manager. For example, if the tape block size is 512 KB and the media manager has a header of size 16 KB, then you can set BLKSIZE=49600.Note that it is also a good idea to increase the media management physical tape block size. For example, you do not want to set the BLKSIZE parameter to 512 KB and leave the physical tape block size as 32 KB.Oracle

Internal &

OAI U

se O

nly

Page 284: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-18

Copyright © Oracle Corporation, 2002. All rights reserved.

Channel Tuning

Use CONFIGURE CHANNEL/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

Channel TuningYou can set various channel limit parameters that apply to operations performed by the allocated server session in the CONFIGURE CHANNEL and ALLOCATE CHANNELcommands.The MAXPIECESIZE parameter specifies the maximum size of a backup piece. Use this parameter to force RMAN to create multiple backup pieces in a backup set. RMAN creates each backup piece with a size no larger than the value 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, 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 simultaneously read and then written into the same backup piece.Oracle

Internal &

OAI U

se O

nly

Page 285: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-19

Copyright © Oracle Corporation, 2002. All rights reserved.

Tuning the BACKUP Command

• MAXSETSIZE prevents RMAN from writing a single backup set to multiple volumes.

• FILESPERSET prevents RMAN from reading from too many disks at once.

• DISKRATIO limits the number of disk drives that are read from simultaneously.

Tuning the BACKUP CommandThe MAXSETSIZE parameter specifies the maximum size in bytes of a backup set. This parameter is used to prevent a single backup set from spanning multiple volumes.The FILESPERSET parameter specifies the maximum number of files to place in a backup set. If you allocate only one channel, then you can use this parameter to make RMAN create multiple backup sets. For example, if you have fifty input data files and two channels, you can set FILESPERSET=5 to create ten backup sets. This strategy can prevent you from splitting a backup set among multiple tapes.The DISKRATIO parameter specifies the number of drives to include in the backup. Assume the data files are located on five disks, each disk supplies data at 10 bytes per second, and the tape drive requires 20 bytes per second to keep streaming. If you set DISKRATIO=2, then RMAN reads from two drives at a time, thereby distributing the backup load.

Oracle In

ternal & O

AI Use

Only

Page 286: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle9i Database: Supporting Recovery Manager 8-20

Copyright © Oracle Corporation, 2002. All rights reserved.

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

Oracle In

ternal & O

AI Use

Only

Page 287: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

__________ Appendix A

__________

Oracle In

ternal & O

AI Use

Only

Page 288: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

RMAN Catalog Views and Corresponding Control File Views

Recovery Catalog View Corresponding V$ View View Description

RC_ARCHIVED_LOG V$ARCHIVED_LOG Archived and unarchived redo logs

RC_BACKUP_CONTROLFILE V$BACKUP_DATAFILE Control files in backup sets

RC_BACKUP_CORRUPTION V$BACKUP_CORRUPTION Corrupt block ranges in datafile backups

RC_BACKUP_DATAFILE V$BACKUP_DATAFILE Datafiles in backup sets

RC_BACKUP_PIECE V$BACKUP_PIECE Backup pieces

RC_BACKUP_REDOLOG V$BACKUP_REDOLOG Archived redo logs in backup sets

RC_BACKUP_SET V$BACKUP_SET Backup sets for all incarnations of the database

RC_BACKUP_SPFILE V$BACKUP_SPFILE Server parameter files in backups

RC_CHECKPOINT Deprecated in favor of RC_RESYNC

RC_CONTROLFILE_COPY V$DATAFILE_COPY Control file copies on disk

RC_COPY_CORRUPTION V$COPY_CORRUPTION Control file copies on disk

RC_DATABASE_BLOCK_CORRUPTION

V$DATABASE_BLOCK_CORRUPTION

Database blocks marked as corrupted in the most recent RMAN backup or copy

RC_DATABASE_INCARNATION

V$DATABASE_INCARNATION

Database incarnations registered in the recovery catalog

RC_DATAFILE V$DATAFILE Datafiles registered in the recovery catalog

RC_DATAFILE_COPY V$DATAFILE_COPY Datafile copies on disk

Oracle9i Database: Supporting Recovery Manager Appendix A-2

Oracle In

ternal & O

AI Use

Only

Page 289: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

RC_LOG_HISTORY V$LOG_HISTORY Online redo log history indicating when log switches occurred

RC_OFFLINE_RANGE V$OFFLINE_RANGE Offline ranges for datafiles

RC_PROXY_CONTROLFILE V$PROXY_DATAFILE Control file backups that were taken using the proxy copy functionality

RMAN Compatability Matrix

Target Database 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

Oracle9i Database: Supporting Recovery Manager Appendix A-3

Oracle In

ternal & O

AI Use

Only

Page 290: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

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

Depricated RMAN Commands

Deprecated In Deprecated Syntax Preferred Current Syntax

9.2 REPLICATE RESTORE CONTROLFILE FROM ...

9.2 SET AUTOLOCATE Now enabled by default.

9.0.1 ALLOCATE CHANNEL FOR DELETE

Not available

9.0.1 ALLOCATE CHANNEL ... TYPE

CONFIGURE CHANNEL ... DEVICE TYPE

9.0.1 ALLOCATE CHANNEL ... KBYTES

CONFIGURE CHANNEL ... MAXPIECESIZE

9.0.1 ALLOCATE CHANNEL ... READRATE

CONFIGURE CHANNEL ... RATE

9.0.1 ... ARCHIVELOG ... LOGSEQ ...

ARCHIVELOG ... SEQUENCE

9.0.1 BACKUP ... SETSIZE BACKUP ... MAXSETSIZE

9.0.1 CHANGE ... CROSSCHECK CROSSCHECK

Oracle9i Database: Supporting Recovery Manager Appendix A-4

Oracle In

ternal & O

AI Use

Only

Page 291: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

9.0.1 CHANGE ... DELETE DELETE

9.0.1 REPORT ... AT LOGSEQ REPORT ... AT SEQUENCE

9.0.1 SET AUXNAME CONFIGURE AUXNAME

Oracle9i Database: Supporting Recovery Manager Appendix A-5

Oracle In

ternal & O

AI Use

Only

Page 292: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 293: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

__________ Appendix B

Practices __________

Oracle In

ternal & O

AI Use

Only

Page 294: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 2 Practices

1. Put your database in archivelog mode. Make sure 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, etc. Make the datafile 20meg in size and place it in $HOME/ORADATA/u04. Create a Recovery Manager user called RMAN and set the user’s default tablespace to RCVCAT. Let the RMAN user have unlimited quota on this tablespace. Set the temporary tablespace to TEMP. Grant role of 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: • Automatically backup the control file • Make DISK the default device type • Set the level of parallelization for the DISK device to 2 • Configure 2 disk channels and specify the file format to be

$HOME/ORADATA/u06/C#_%U • Create a 7 day recovery window • Name the snap controlfile $HOME/ORADATA/u06/cfcp/snapcf_SID.f Verify your configuration

Oracle9i Database: Supporting Recovery Manager Appendix B-2

Oracle In

ternal & O

AI Use

Only

Page 295: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 3 Practices

1. Using operating system commands make a complete cold backup into the directory DONTTOUCH. This is done to provide a point of disaster recovery, should 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 in order to advise the repository of the backup 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. Into the directory BACKUP, make a full or incremental 0 backup of the database. Put all files into one set, but restrict the size of each piece to 20 megabytes. Confirm the backup by examining the appropriate tables in the repository.

5. Perform a database backup using automatic channel allocation. Make sure the backup

command behaves as specified in your persistent configuration.

Oracle9i Database: Supporting Recovery Manager Appendix B-3

Oracle In

ternal & O

AI Use

Only

Page 296: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 4 Practices Complete recovery from a total failure 1. Delete all the datafiles and controlfiles 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 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. Use this time (less five 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. The script needs two arguments; the absolute filename and block number respectively and should be run like the example below:

$ corrupt.sh /u01/user01/ORADATA/u02/sample_01_U01.dbf 417

Oracle9i Database: Supporting Recovery Manager Appendix B-4

Oracle In

ternal & O

AI Use

Only

Page 297: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 5 Practices 1. Use the LIST command to:

• Get the current status of your backups • List backups by datafile • Identify the current database incarnation and identify the SCN at which it changed

2. Use CONFIGURE to change the REDUNDANCY to 2. Using REPORT: • Identify files that have less than 4 redundant backups. • Identify files whose recovery needs more than 7 days of archived logs. • Identify backups that are obsolete according to the new retention policy • Use REPORT to view your database schema.

3. Delete obsolete backups as identified by the redundancy value 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.

Oracle9i Database: Supporting Recovery Manager Appendix B-5

Oracle In

ternal & O

AI Use

Only

Page 298: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 6 Practices 1. Configure the channel SBT_TAPE to use Oracle’s SBT dummy disk API. Use the

SBT_LIBRARY parameter to tell RMAN the proper library to load. Configure the SBT_TAPE channel to be the default channel. Test the SBT configuration by performing a backup. Troubleshoot the configuration if unsuccessful.

Oracle9i Database: Supporting Recovery Manager Appendix B-6

Oracle In

ternal & O

AI Use

Only

Page 299: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 7 Practices 1. Use RMAN to set a backup in progress. While the backup is running log onto the target

database using another telnet session and examine the view V$SESSION_LONGOPS. Using this view it is possible to determine if the backup is progressing, or hanging. If all is well, time_remaining should be decreasing.

2. Using RMAN perform another backup using the DEBUG option. On completion of the

backup script, examine the trace file produced by DEBUG. 3. Run the shell script les07_03.sh. After doing this, perform a database backup 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 re-run the backup to verify the repair.

4. Run the shell script les07_04.sh. After doing this, perform a database backup using the

persistent configuration. Investigate the alert log and trace files for any clues. If this proves fruitless, use debug to gather more information. Correct the condition and run the backup.

Oracle9i Database: Supporting Recovery Manager Appendix B-7

Oracle In

ternal & O

AI Use

Only

Page 300: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Oracle In

ternal & O

AI Use

Only

Page 301: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

__________ Appendix C

Solutions __________

Oracle In

ternal & O

AI Use

Only

Page 302: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 2 Practices

1. Put your database in archivelog mode. Make sure the archived logs are written to $HOME/ORADATA/ARCHIVE1.

To switch a database’s 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 equal 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

Switch to archivelog mode and then open the database:

SQL> alter database archivelog; SQL> alter database open;

2. On your database Unn create a tablespace called RCVCAT that will contain the schema for the repository tables, views, etc. Make the datafile 20meg in size and place it in $HOME/ORADATA/u04. Create a Recovery Manager user called RMAN and set the user’s default tablespace to RCVCAT. Let the RMAN user have unlimited quota on this tablespace. Set the temporary tablespace to TEMP. Grant role of 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.

Oracle9i Database: Supporting Recovery Manager Appendix C-2

Oracle In

ternal & O

AI Use

Only

Page 303: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Create the RMAN user. Make RCVCAT the default tablespace and TEMP the temporary tablespace. Give RMAN unlimited quota in RCVCAT.

Note: In order to connect to your target database it is required that the target user be identified as a sysdba

SQL> create user rman identified by rman 2 DEFAULT TABLESPACE rcvcat QUOTA UNLIMITED ON rcvcat 3 temporary tablespace temp; User created.

Grant RECOVERY_CATALOG_OWNER and any other privileges needed to the RMAN user:

SQL> grant RECOVERY_CATALOG_OWNER, connect, resource, sysdba TO rman; Grant succeeded.

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: • Automatically backup the control file • Make DISK the default device type • Set the level of parallelization for the DISK device to 2 • Configure 2 disk channels and specify the file format to be

$HOME/ORADATA/u06/C#_%U • Create a 7 day recovery window • Name the snap controlfile $HOME/ORADATA/u06/snapcf_SID.f Verify your configuration

Oracle9i Database: Supporting Recovery Manager Appendix C-3

Oracle In

ternal & O

AI Use

Only

Page 304: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

From the RMAN prompt, issue the show all command. RMAN> show all; RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u03/ora9ir2/dbs/snapcf_U01.f';# default

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';

Oracle9i Database: Supporting Recovery Manager Appendix C-4

Oracle In

ternal & O

AI Use

Only

Page 305: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 3 Practices 1. Using operating system commands make a complete cold backup into the directory

DONTTOUCH. This is done to provide a point of disaster recovery, should 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 under the ORADATA directory to the DONTTOUCH directory. The datafiles are on different disks (simulated) so the find command is useful for copying files from multiple locations and collapsing 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 cp {} $HOME/DONTTOUCH \; $ ls –l $HOME/DONTTOUCH total 821824 -rw-r----- 1 user01 dba 954368 Apr 14 17:16 control01.ctl -rw-r----- 1 user01 dba 26214912 Apr 14 17:17 example01.dbf -rw-r----- 1 user01 dba 26214912 Apr 14 17:17 indx01.dbf.rdo ... -rw-r----- 1 user01 dba 15732736 Apr 14 17:17 users01.dbf

Query the CDF table in the RMAN schema. The backups listed include ALL blocks and is most 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 in order to advise the repository of the backup 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 performed earlier to get the names of the datafile copies.

SQL> exit $ rman target / catalog rman/rman RMAN> run { 2> catalog datafilecopy '$HOME/DONTTOUCH/indx01.dbf'; 3> catalog datafilecopy '$HOME/DONTTOUCH/rcvcat.dbf'; 4> catalog datafilecopy '$HOME/DONTTOUCH/example01.dbf'; 5> catalog datafilecopy '$HOME/DONTTOUCH/system01.dbf';

Oracle9i Database: Supporting Recovery Manager Appendix C-5

Oracle In

ternal & O

AI Use

Only

Page 306: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

6> catalog datafilecopy '$HOME/DONTTOUCH/undotbs01.dbf'; 7> catalog datafilecopy '$HOME/DONTTOUCH/users01.dbf'; }

To confirm RMAN’s knowledge 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 needed to do 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

Oracle9i Database: Supporting Recovery Manager Appendix C-6

Oracle In

ternal & O

AI Use

Only

Page 307: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

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 output filename=/home1/user01/BACKUP/RMAN/system01.dbf recid=7 stamp=459206051 Finished copy at 14-APR-02 Starting copy at 14-APR-02 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: copied datafile 2 output filename=/home1/user01/BACKUP/RMAN/undotbs01.dbf recid=8 stamp=459206064 Finished copy at 14-APR-02 ... Starting copy at 14-APR-02 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: copied datafile 6 output filename=/home1/user01/BACKUP/RMAN/rcvcat.dbf recid=12 stamp=459206088 Finished copy at 14-APR-02 Starting Control File Autobackup at 14-APR-02 piece handle=/home1/user01/ORADATA/u05/c-0574317449-20020414-01 comment=NONE Finished Control File Autobackup at 14-APR-02

Note that the control file has been backed up automatically.

Query the CDF table in the RMAN schema and compare the results with the query performed earlier. You should see a second datafile backup.

RMAN> exit $ sqlplus rman/rman SQL> column completion_time format a15 SQL> column fname format a45 SQL> select file#, fname, completion_time from cdf; FILE# FNAME COMPLETION_TIME ---------- --------------------------------------------- --------------- 1 /home1/user01/DONTTOUCH/system01.dbf 14-APR-02 4 /home1/user01/DONTTOUCH/indx01.dbf 14-APR-02 6 /home1/user01/DONTTOUCH/rcvcat.dbf 14-APR-02 5 /home1/user01/DONTTOUCH/example01.dbf 14-APR-02 2 /home1/user01/DONTTOUCH/undotbs01.dbf 14-APR-02 3 /home1/user01/DONTTOUCH/users01.dbf 14-APR-02 1 /home1/user01/BACKUP/RMAN/system01.dbf 14-APR-02 2 /home1/user01/BACKUP/RMAN/undotbs01.dbf 14-APR-02 3 /home1/user01/BACKUP/RMAN/users01.dbf 14-APR-02

Oracle9i Database: Supporting Recovery Manager Appendix C-7

4 /home1/user01/BACKUP/RMAN/indx01.dbf 14-APR-02

Oracle In

ternal & O

AI Use

Only

Page 308: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

5 /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.

4. Into the directory BACKUP, make a full or incremental 0 backup of the database. Put all files into one set, but restrict the size of each piece to 20 megabytes. Confirm the backup 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

Again, note the autobackup of the control file.

5. Perform a database backup using automatic channel allocation. Make sure the backup command behaves as specified in your persistent configuration.

Oracle9i Database: Supporting Recovery Manager Appendix C-8

Oracle In

ternal & O

AI Use

Only

Page 309: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Start RMAN connecting to the catalog and the target database. Issue the backup database command. If the persistent configuration has been setup properly, the RMAN output should be similar to the example below. Please note the two disk channels that are allocated and the backuppiece creation.

RMAN> backup database; Starting backup at 14-APR-02 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=10 devallocated channel: ORA_DISK_2

type=DISK

channel ORA_DISK_2: sid=11 devtype=DISK channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00005 name=/home1/user01/ORADATA/u02/example01.dbf ... channel ORA_DISK_2: starting piece 1 at 14-APR-02 channel ORA_DISK_1: finished piece 1 at 14-APR-02 piece handle=/home1/user01/ORADATA/u06/C1_0gdlvhm2_1_1 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25 channel ORA_DISK_2: finished piece 1 at 14-APR-02 piece handle=/home1/user01/ORADATA/u06/C2_0hdlvhm2_1_1 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:25 Finished backup at 14-APR-02 Starting Control File Autobackup at 14-APR-02 piece handle=/home1/user01/ORADATA/u05/c-0574317449-20020414-00 comment=NONEFinished Control File Autobackup at 14-APR-02 Take notice of the channel allocation. Does the number of channels allocated match the degree of parallelization specified for the DISK device in the persistent configuration? Note the files created by channels 1 and 2. Does the format and file location match that specified by the persistent configuration create earlier? In the output above, the channels are automatically allocated as desired and the backup pieces are written in the correct format and location.

Oracle9i Database: Supporting Recovery Manager Appendix C-9

Oracle In

ternal & O

AI Use

Only

Page 310: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 4 Practices Complete recovery from a total failure 1. Delete all the datafiles and controlfiles 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 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, backup 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. Be careful!

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

Shutdown the database and remove the control file and datafiles.

Oracle9i Database: Supporting Recovery Manager Appendix C-10

Oracle In

ternal & O

AI Use

Only

Page 311: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

SQL> shutdown immediate; SQL> exit $ cd $HOME/ORADATA $ rm u01/*.dbf $ rm u01/*.ctl $ rm u02/*.dbf $ rm u03/*.dbf $ rm u04/*.dbf

Start RMAN and connect to the target database only as 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 14 20:59 c-0574317449-20020414-00 -rw-r----- 1 ora9i dba 963072 Apr 14 21:14 c-0574317449-20020414-01 -rw-r----- 1 ora9i dba 963072 Apr 14 21:46 c-0574317449-20020414-02 -rw-r----- 1 ora9i dba 963072 Apr 14 21:51 c-0574317449-20020414-03 -rw-r----- 1 ora9i dba 963072 Apr 14 23:51 c-0574317449-20020414-05 -rw-r----- 1 ora9i dba 963072 Apr 15 12:41 c-0574317449-20020415-00 -rw-r----- 1 ora9i dba 963072 Apr 15 14:17 c-0574317449-20020415-01 host command complete RMAN> restore controlfile from '$HOME/ORADATA/u05/c-0574317449-20020415-01'; Starting restore at 15-APR-02 using channel ORA_DISK_1 channel ORA_DISK_1: restoring controlfile channel ORA_DISK_1: restore complete RMAN>

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 since the database will need to be opened 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

Oracle9i Database: Supporting Recovery Manager Appendix C-11

Oracle In

ternal & O

AI Use

Only

Page 312: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

piece handle=/home1/user01/ORADATA/u06/C2_0kdlvnad_1_1 tag=null params=NULL channel ORA_DISK_1: restore complete channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00002 to /home1/user01/ORADATA/u02/undotbs01.dbf restoring datafile 00005 to /home1/user01/ORADATA/u02/example01.dbf restoring datafile 00006 to /home1/user01/ORADATA/u04/rcvcat.dbf channel ORA_DISK_1: restored backup piece 1 pi or from recovery catalog database: ORA-01033: ORACLE initialization orece handle=/home1/user01/ORADATA/u06/C1_0jdlvnad_1_1 tag=null params=NULL channel ORA_DISK_1: restore complete Finished restore at 15-APR-02 RMAN> recover database; Starting recover at 15-APR-02 using channel ORA_DISK_1 starting media recovery archive log thread 1 sequence 11 is already on disk as file /home1/user01/ORADATA/u03/redo01.rdo archive log filename=/home1/user01/ORADATA/u03/redo01.rdo thread=1 sequence=11 media recovery complete Finished recover at 15-APR-02 Exit $ rman target / catalog rman/rman RMAN> alter database open resetlogs; database opened RMAN> exit $ rman target / catalog rman/rman RMAN> reset database; RMAN> backup database; RMAN> exit

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. Use this time (less five minutes) to recover the database to a point in time before the new data was introduced.

As user system/manager create the table HR.DEPARTMENTS2 as select * from departments. Confirm that the table exists, and record the total number of rows. After creating the table, get the time and date. View the active log by querying V$LOG. Perform a log switch when finished.

Oracle9i Database: Supporting Recovery Manager Appendix C-12

Oracle In

ternal & O

AI Use

Only

Page 313: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

$ sqlplus system/manager SQL> create table hr.departments2 as select * from hr.departments; SQL> select count(*) from hr.departments2; COUNT(*) ---------- 27 SQL> !date Tue Apr 16 17:05:50 EDT 2002 SQL> select sequence#, status from v$log; SEQUENCE# STATUS ---------- ---------------- 3 INACTIVE 4 CURRENT SQL> alter system switch logfile; System altered.

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# STATUS ---------- ---------------- 5 CURRENT 4 ACTIVE SQL> insert into hr.departments2 values (280, 'DUMMY1','',''); SQL> insert into hr.departments2 values (290, 'DUMMY2','',''); SQL> insert into hr.departments2 values (300, 'DUMMY3','',''); SQL> commit SQL> select count(*) from hr.departments2; COUNT(*) ---------- 30

Shutdown the database, and restart it in mount mode. SQL> shutdown immediate; SQL> startup mount; ORACLE instance started. SQL> exit

Oracle9i Database: Supporting Recovery Manager Appendix C-13

Oracle In

ternal & O

AI Use

Only

Page 314: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Using RMAN perform an incomplete recovery until the date and time recorded in the previous step, less five minutes. Use the set until time clause to the time reported in the first step and then recover the database.

$ 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;

Oracle9i Database: Supporting Recovery Manager Appendix C-14

Oracle In

ternal & O

AI Use

Only

Page 315: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

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. The script needs two arguments; the absolute filename and block number respectively and should be run like the example below:

$ corrupt.sh $HOME/ORADATA/u02/example01.dbf 417

First, find the location of the DEPARTMENTS table. Query the V$DBA_EXTENTS table. Make sure you have write privileges on the data file. If not, use the chmod command to correct this.

SQL> select file_id, block_id from dba_extents 2 where segment_name = 'DEPARTMENTS'; FILE_ID BLOCK_ID ---------- ---------- 5 417 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 SQL> exit $ ls –l $HOME/ORADATA/u02/example01.dbf -rw-rw---- 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) 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

Perform a select against the DEPARTMENTS table to verify the corruption.

Oracle9i Database: Supporting Recovery Manager Appendix C-15

Oracle In

ternal & O

AI Use

Only

Page 316: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

SQL> select * from hr.departments; ERROR at line 1: ORA-01578: ORACLE data block corrupted (file # 5, block # 417) ORA-01110: data file 5: '/home1/user01/ORADATA/u02/example01.dbf'

Use the BLOCKRECOVER command to fix the corruption.

RMAN> blockrecover datafile 5 block 417; Starting blockrecover at 17-APR-02 ... restoring blocks of datafile 00005 channel ORA_DISK_1: restored block(s) from backup piece 1 piece handle=/u03/ora9ir2/dbs/03dm4rji_1_1 tag=null params=NULL channel ORA_DISK_1: block restore complete starting media recovery media recovery complete Finished blockrecover at 17-APR-02 RMAN> exit

Verify that the corruption is repaired.

$ exit SQL> select * from hr.departments; DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID ------------- ------------------------------ ---------- ----------- 10 Administration 200 1700 20 Marketing 201 1800 ... 250 Retail Sales 1700 260 Recruiting 1700 270 Payroll 1700 27 rows selected.

Oracle9i Database: Supporting Recovery Manager Appendix C-16

Oracle In

ternal & O

AI Use

Only

Page 317: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 5 Practices 1. Use the LIST command to:

• Get the current status of your backups • List backups by datafile • 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 Full 163636 17-APR-02 /home1/user01/ORADATA/u02/undotbs01.dbf 5 Full 163636 17-APR-02 /home1/user01/ORADATA/u02/example01.dbf 6 Full 163636 17-APR-02 /home1/user01/ORADATA/u04/rcvcat.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 24 Full 90M DISK 00:00:24 17-APR-02 BP Key: 26 Status: AVAILABLE Tag: Piece Name: /u03/ora9ir2/dbs/04dm4rjj_1_1 List of Datafiles in backup set 24 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 163637 17-APR-02 /home1/user01/ORADATA/u01/system01.dbf 3 Full 163637 17-APR-02 /home1/user01/ORADATA/u03/users01.dbf 4 Full 163637 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

Oracle9i Database: Supporting Recovery Manager Appendix C-17

Oracle In

ternal & O

AI Use

Only

Page 318: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

BP Key: 67 Status: AVAILABLE Tag: Piece Name: /home1/user01/ORADATA/u05/c-0574317449-20020417-03 Controlfile Included: Ckp SCN: 167980 Ckp time: 17-APR-02 RMAN> list backup by file; List of Datafile Backups ======================== File Key TY LV S Ckp SCN Ckp Time #Pieces #Copies Tag ---- ------- - -- - ---------- --------- ------- ------- --- 1 473 B F A 74588 28-MAY-02 1 1 TAG20020528T145408 415 B F A 74176 28-MAY-02 1 1 WKLY_BKUP 381 B F A 70420 28-MAY-02 1 1 TAG20020528T115053 274 B F A 69997 28-MAY-02 1 1 TAG20020528T113959 259 B F A 69942 28-MAY-02 1 1 TAG20020528T113852 ... 5 473 B F A 74588 28-MAY-02 1 1 TAG20020528T145408 382 B F A 70421 28-MAY-02 1 1 TAG20020528T115053 274 B F A 69997 28-MAY-02 1 1 TAG20020528T113959 259 B F A 69942 28-MAY-02 1 1 TAG20020528T113852 6 473 B F A 74588 28-MAY-02 1 1 TAG20020528T145408 382 B F A 70421 28-MAY-02 1 1 TAG20020528T115053 274 B F A 69997 28-MAY-02 1 1 TAG20020528T113959 259 B F A 69942 28-MAY-02 1 1 TAG20020528T113852 List of Archived Log Backups ============================ Thrd Seq Low SCN Low Time BS Key S #Pieces #Copies Tag ---- ------- ---------- --------- ------- - ------- ------- --- 1 1 70236 28-MAY-02 441 A 1 1 TAG20020528T144920 1 2 74241 28-MAY-02 440 A 1 1 TAG20020528T144920 1 3 74293 28-MAY-02 454 A 1 1 TAG20020528T144927 RMAN> list incarnation; List of Database Incarnations DB Key Inc Key DB Name DB ID CUR Reset SCN Reset Time ------- ------- -------- ------------ --- ---------- ---------- 1 2 U02 775813490 NO 1 06-MAR-02 1 73 U02 775813490 YES 440227 27-MAR-02

2. Use CONFIGURE to change the REDUNDANCY to 2. Using REPORT:

• Identify files that have less than 4 redundant backups. • Identify files whose recovery needs more than 7 days of archived logs. • Identify backups that are obsolete according to the new retention policy • Use REPORT to view your database schema.

Oracle9i Database: Supporting Recovery Manager Appendix C-18

Oracle In

ternal & O

AI Use

Only

Page 319: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY = 2; old RMAN configuration parameters: CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; new RMAN configuration parameters: CONFIGURE RETENTION POLICY TO REDUNDANCY 2; new RMAN configuration parameters are successfully stored RMAN> report need backup redundancy = 4; Report of files with less than 4 redundant backups File #bkps Name ---- ----- ----------------------------------------------------- 1 3 /home1/user01/ORADATA/u01/system01.dbf 2 3 /home1/user01/ORADATA/u02/undotbs01.dbf 3 3 /home1/user01/ORADATA/u03/users01.dbf 4 3 /home1/user01/ORADATA/u03/indx01.dbf 5 3 /home1/user01/ORADATA/u02/example01.dbf 6 3 /home1/user01/ORADATA/u04/rcvcat.dbf RMAN> report need backup days = 7; Report of files whose recovery needs more than 7 days of archived logs File Days Name ---- ----- ----------------------------------------------------- RMAN> report obsolete; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 Report of obsolete backups and copies Type Key Completion Time Filename/Handle -------------------- ------ ------------------ -------------------- Backup Set 19 17-APR-02 Backup Piece 20 17-APR-02 /home1/user01/ORADATA/u05/c-0574317449-20020417-00 ... Backup Set 50 17-APR-02 Backup Piece 51 17-APR-02 /home1/user01/ORADATA/u05/c-0574317449-20020417-02 RMAN> report schema; Report of database schema File K-bytes Tablespace RB segs Datafile Name ---- ---------- -------------- ------- ------------------- 1 102400 SYSTEM YES /home1/user01/ORADATA/u01/system01.dbf 2 56320 UNDOTBS YES /home1/user01/ORADATA/u02/undotbs01.dbf 3 15360 USERS NO /home1/user01/ORADATA/u03/users01.dbf 4 46080 INDX NO /home1/user01/ORADATA/u03/indx01.dbf 5 71680 SAMPLE NO /home1/user01/ORADATA/u02/example01.dbf 6 20480 RCVCAT NO /home1/user01/ORADATA/u04/rcvcat.dbf

3. Delete obsolete backups as identified in practice 2.

Oracle9i Database: Supporting Recovery Manager Appendix C-19

Oracle In

ternal & O

AI Use

Only

Page 320: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

RMAN> delete obsolete; Deleting the following obsolete backups and copies: Type Key Completion Time Filename/Handle -------------------- ------ ------------------ -------------------- Backup Set 66 17-APR-02 Backup Piece 67 17-APR-02 /home1/user01/ORADATA/u05/c-0574317449-20020417-03 Datafile Copy 54 17-APR-02 /home1/user01/BACKUP/RMAN/system01.dbf ... Datafile Copy 64 17-APR-02 /home1/user01/BACKUP/RMAN/rcvcat.dbf Do you really want to delete the above objects (enter YES or NO)? y deleted backup piece backup piece handle=/home1/user01/ORADATA/u05/c-0574317449-20020417-03 recid=8 stamp=459448496 ... deleted datafile copy datafile copy filename=/home1/user01/BACKUP/RMAN/rcvcat.dbf recid=6 stamp=459448494 Deleted 7 objects 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> }

Test the script to be sure it works properly.

RMAN> run {execute script whole_bkup;} allocated channel: d1 channel d1: sid=14 devtype=DISK ... Finished backup at 17-APR-02 Starting Control File Autobackup at 17-APR-02 piece handle=/home1/user01/ORADATA/u05/c0574317449-20020417-06 comment=NONE Finished Control File Autobackup at 17-APR-02 released channel: d1 RMAN>

Issue the RMAN print script command to view the stored script lines.

Oracle9i Database: Supporting Recovery Manager Appendix C-20

Oracle In

ternal & O

AI Use

Only

Page 321: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

RMAN> print script whole_bkup; printing stored script: whole_bkup { ALLOCATE CHANNEL d1 DEVICE TYPE DISK FORMAT '$HOME/ORADATA/u06/%U'; backup database; }

A query against RC_STORED_SCRIPT_LINE will also show the stored script.

RMAN> exit $ sqlplus rman/rman SQL> SELECT TEXT FROM RC_STORED_SCRIPT_LINE 2 WHERE SCRIPT_NAME = 'whole_bkup'; TEXT ------------------------------------------------------------------------- { ALLOCATE CHANNEL d1 DEVICE TYPE DISK FORMAT '$HOME/ORADATA/u06/%U'; backup database; }

Oracle9i Database: Supporting Recovery Manager Appendix C-21

Oracle In

ternal & O

AI Use

Only

Page 322: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 6 Practices Configure the channel SBT_TAPE to use Oracle’s SBT dummy disk API. Use the SBT_LIBRARY parameter to tell RMAN the proper library to load. 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

Backup the database to test the configuration.

RMAN> backup database; Starting backup at 18-APR-02 allocated channel: ORA_SBT_TAPE_1 channel ORA_SBT_TAPE_1: sid=16 devtype=SBT_TAPE channel ORA_SBT_TAPE_1: WARNING: Oracle Test Disk API 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 input datafile fno=00005 name=/home1/user01/ORADATA/u02/example01.dbf

Oracle9i Database: Supporting Recovery Manager Appendix C-22

Oracle In

ternal & O

AI Use

Only

Page 323: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

input datafile fno=00002 name=/home1/user01/ORADATA/u02/undotbs01.dbf input datafile fno=00004 name=/home1/user01/ORADATA/u03/indx01.dbf input datafile fno=00006 name=/home1/user01/ORADATA/u04/rcvcat.dbf input datafile fno=00003 name=/home1/user01/ORADATA/u03/users01.dbf channel ORA_SBT_TAPE_1: starting piece 1 at 18-APR-02 channel ORA_SBT_TAPE_1: finished piece 1 at 18-APR-02 piece handle=0qdm7743_1_1 comment=API Version 2.0,MMS Version 8.1.3.0 channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:25 Finished backup at 18-APR-02 Starting Control File Autobackup at 18-APR-02 piece handle=c-0574317449-20020418-01 comment=API Version 2.0,MMS Version 8.1.3.0 Finished Control File Autobackup at 18-APR-02

If you receive an error, troubleshoot the configuration. Below are some common configuration errors. 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

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

Oracle9i Database: Supporting Recovery Manager Appendix C-23

Oracle In

ternal & O

AI Use

Only

Page 324: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

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 RMAN-00600: internal error, arguments [6027] [1] [] [] []

Mismatched quotes or parenthesis will produce an error stack like this:

Starting backup at 18-APR-02 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of backup command at 04/18/2002 09:54:44 ORA-19554: error allocating device, device type: SBT_TAPE, device name: ORA-27207: syntax error in device PARMS - parentheses mismatch or missing

Oracle9i Database: Supporting Recovery Manager Appendix C-24

Oracle In

ternal & O

AI Use

Only

Page 325: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Lesson 7 Practices 1. Use RMAN to set a backup in progress. While the backup is running log onto the target

database using another telnet session and examine the view V$SESSION_LONGOPS. Using this view it is possible to determine if the backup is progressing, or hanging. If all is well, time_remaining should be decreasing.

Start RMAN and backup the database.

$ rman target / catalog rman/rman RMAN> backup database;

From another session:

Before backup starts: SQL> select sid, start_time, elapsed_seconds, time_remaining from v$session_longops; no rows selected Just after backup starts: SQL> select sid, start_time, elapsed_seconds, time_remaining from v$session_longops; SID START_TIM ELAPSED_SECONDS TIME_REMAINING ---------- --------- --------------- -------------- 10 19-APR-02 0 About 5 seconds later: SQL> select sid, start_time, elapsed_seconds, time_remaining from v$session_longops; SID START_TIM ELAPSED_SECONDS TIME_REMAINING ---------- --------- --------------- -------------- 10 19-APR-02 0 15 19-APR-02 8 15 15 19-APR-02 8 About 5 seconds later: SQL> select sid, start_time, elapsed_seconds, time_remaining from v$session_longops; SID START_TIM ELAPSED_SECONDS TIME_REMAINING ---------- --------- --------------- -------------- 10 19-APR-02 0 15 19-APR-02 11 10 15 19-APR-02 11 About 5 seconds later: SQL> select sid, start_time, elapsed_seconds, time_remaining from v$session_longops; SID START_TIM ELAPSED_SECONDS TIME_REMAINING ---------- --------- --------------- -------------- 10 19-APR-02 0 15 19-APR-02 14 5 15 19-APR-02 14

Oracle9i Database: Supporting Recovery Manager Appendix C-25

Oracle In

ternal & O

AI Use

Only

Page 326: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

About 5 seconds later: SQL> select sid, start_time, elapsed_seconds, time_remaining from v$session_longops; SID START_TIM ELAPSED_SECONDS TIME_REMAINING ---------- --------- --------------- -------------- 10 19-APR-02 0 15 19-APR-02 20 0 15 19-APR-02 20 0 About 5 seconds later (controlfile autobackup has just started): SQL> select sid, start_time, elapsed_seconds, time_remaining from v$session_longops; SID START_TIM ELAPSED_SECONDS TIME_REMAINING ---------- --------- --------------- -------------- 10 19-APR-02 25 0 15 19-APR-02 20 0 15 19-APR-02 20 0 13 19-APR-02 0 0 Backup has finished: SQL> select sid, start_time, elapsed_seconds, time_remaining from v$session_longops; SID START_TIM ELAPSED_SECONDS TIME_REMAINING ---------- --------- --------------- -------------- 10 19-APR-02 31 0 15 19-APR-02 20 0 15 19-APR-02 20 0 13 19-APR-02 0 0 10 19-APR-02 0 0

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 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 using the DEBUG option. On completion of the

backup script, examine the trace file 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 ...

Oracle9i Database: Supporting Recovery Manager Appendix C-26

Oracle In

ternal & O

AI Use

Only

Page 327: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

Debugging turned off RMAN> exit $ vi rman.out Recovery Manager: Release 9.2.0.0.0 - Beta (c) Copyright 2001 Oracle Corporation. All rights reserved. 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 ...

Oracle9i Database: Supporting Recovery Manager Appendix C-27

Oracle In

ternal & O

AI Use

Only

Page 328: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

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 (krmice) DBGMISC: command after this command is: NONE (krmice) Debugging turned off 3. Run the shell script les07_03.sh. After doing this, perform a database backup 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 re-run the backup to verify the repair.

From the operating system prompt run the les07_03.sh script. Start RMAN and backup 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 appears to be a media management problem but more information is necessary to determine the cause. Looking at the latest trace file, unn_ora_nnn.trc file in USER_DUMP_DEST gives a clue to the problem:

*** SESSION ID:(15.22) 2002-05-07 13:55:44.577 Failed to load SBT library phony.disksbt

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)"; ...

Oracle9i Database: Supporting Recovery Manager Appendix C-28

Oracle In

ternal & O

AI Use

Only

Page 329: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '$HOME/ORADATA/u06/C2_%U'; Use the configure command to change the SBT_LIBRARY parameter to oracle.disksbt and re-run the backup to confirm the correction. If you have difficulty, refer to the $HOME/les07_03.log file which contains your original consistent configuration.

RMAN> CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS="SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=$HOME/ORADATA/u06)"; old RMAN configuration parameters: CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=phony.disksbt,ENV=(BACKUP_DIR=$HOME/ORADATA/u06)"; new RMAN configuration parameters: 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 starting full resync of recovery catalog full resync complete RMAN> backup database; Starting backup at 07-MAY-02 ... Finished backup at 07-MAY-02

4. Run the shell script les07_04.sh. After doing this, perform a database backup using the persistent configuration. Investigate the alert log and trace files for any clues. If this proves fruitless, 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 observer 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

Oracle9i Database: Supporting Recovery Manager Appendix C-29

Oracle In

ternal & O

AI Use

Only

Page 330: Oracle 9i - Database Supporting Recovery Manager - RMAN - Student Guide(2)

Oracle In

ternal & O

AI Use

Only

... 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 ...

The SVR4 (Unix System V Kernel Release 4) exception is definitely raised by the OS. This looks suspiciously 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 user01 dba 512 May 7 17:32 . drwxrwxrwx 10 user01 dba 512 May 7 17:23 .. drwxrwsr-x 2 user121 class7 96 May 29 17:52 ARCHIVE1 -rw-rw---- 1 user121 class7 4096 May 29 14:26 ARCHIVE15_193_0_60083.bkd drwxrwsr-x 2 user121 class7 96 May 28 16:33 ARCHIVE2 drwxrwsr-x 2 user121 class7 96 May 30 06:23 u01 drwxrwsr-x 2 user121 class7 8192 May 30 06:23 u02 drwxrwsr-x 2 user121 class7 8192 May 30 06:23 u03 drwxrwsr-x 2 user121 class7 96 May 30 06:23 u04 drwxrwsr-x 2 user121 class7 8192 May 29 17:59 u05 dr-xr-s--- 2 user121 class7 8192 May 29 17:58 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 group and retest the backup.

$ chmod 770 u06 $ ls -ld u06 drwxrws--- 2 user01 dba 512 May 7 16:18 u06 $ rman target / catalog rman/rman RMAN> backup database; Starting backup at 07-MAY-02 ... Finished backup at 07-MAY-02

Oracle9i Database: Supporting Recovery Manager Appendix C-30

Oracle In

ternal & O

AI Use

Only


Recommended