- •About the Authors
- •Contents at a Glance
- •Contents
- •Table of Exercises
- •Introduction
- •Assessment Test
- •Answers to Assessment Test
- •What Is ASM?
- •Working with the ASM Instance
- •Overview of ASM Data Dictionary Views
- •Using ASM Storage
- •Using RMAN with ASM
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Understanding the Oracle Database as It Relates to Backup and Recovery
- •Performing Oracle Offline Backups
- •Performing Oracle Online Backups
- •Backing Up the Control File
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Performing Incomplete Recoveries
- •Performing Other Types of Recoveries
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Why Use RMAN?
- •Exploring the RMAN Architecture
- •Connecting to RMAN
- •Configuring RMAN for Use
- •Backing Up Your Database with RMAN
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Introducing the Recovery Catalog
- •Creating the Recovery Catalog User and Schema Objects
- •Using a Recovery Catalog
- •Maintaining the Recovery Catalog
- •Using the RMAN Virtual Private Catalog
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •RMAN Database-Recovery Basics
- •Using Image Copies to Recover Your Database
- •Other Basic Recovery Topics
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Switching Between RMAN Incarnations
- •Overview of RMAN Database Duplication
- •Performing an RMAN Tablespace Point-in-Time Recovery
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Overview of Flashback Technology
- •Using Automatic Undo Management
- •Using Flashback Technologies
- •Using Additional Flashback Operations
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Diagnosing the Database
- •Managing Database Performance
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Managing Memory
- •Managing Space
- •Managing Resources
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Automating Tasks with the Scheduler
- •Exploring the Scheduler Architecture
- •Exploring Common Administration Tools
- •Using Scheduler Jobs
- •Using Scheduler Programs
- •Using Schedules
- •Creating Lightweight Jobs
- •Using Job Chains
- •Using Scheduler Windows
- •Creating and Using Job Classes
- •Using Advanced Scheduler Concepts to Prioritize Jobs
- •Using Scheduler Views
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •An Overview of Globalization Support
- •Using NLS Parameters
- •Using Datetime Datatypes
- •Using Linguistic Sorts and Searches
- •Summary
- •Exam Essentials
- •Review Questions
- •Answers to Review Questions
- •Lab 1.1: Creating an ASM Instance
- •Lab 1.2: Creating ASM Disk Groups
- •Lab 1.3: Using ASM Disk Groups from a Database
- •Lab 2.2: Putting the Database in ARCHIVELOG Mode
- •Lab 2.3: Executing a Manual Online (Hot) Backup
- •Lab 3.1: Executing a Time-Based Point-in-Time Recovery
- •Lab 3.2: Recovering from Control-File Loss with a Backup Control File
- •Lab 3.3: Recovering from Loss of the Current Online Redo Log
- •Lab 4.1: Creating an RMAN Offline Backup
- •Lab 4.2: Creating an RMAN Incremental Backup
- •Lab 4.3: Creating an Image-Copy Backup
- •Lab 5.1: Implementing RVPC
- •Lab 6.1: Restoring a Datafile Online
- •Lab 6.2: Performing a Change-Based Recovery with RMAN
- •Lab 6.3: Restoring a Control File from an Autobackup
- •Lab 7.1: Monitoring RMAN Backups
- •Lab 7.2: One of My Backups Is Missing!
- •Lab 8.1: Duplicating a Database Using Active Database Duplication
- •Lab 8.2: Duplicating a Database Using Backup-Based Duplication to a Different Point in Time
- •Lab 9.1: Using the Recycle Bin
- •Lab 9.3: Using Flashback Data Archive
- •Lab 10.1: Using Support Workbench to Report a Problem to Oracle Support
- •Lab 11.1: Exporting a Transportable Tablespace
- •Lab 11.2: Testing Resumable Space Allocation
- •Lab 11.3: Manually Configuring the SGA
- •Lab 12.1: Creating a Local External Job
- •Lab 12.2: Creating a Job Window
- •Lab 13.1: Using the Locale Builder to Create a New Linguistic Sort
- •Lab 13.2: Setting NLS Parameters
- •Lab 13.3: Performing Linguistic Sorts
- •What You’ll Find on the CD
- •System Requirements
- •Using the CD
- •Troubleshooting
- •Glossary
- •Index
214 Chapter 5 n Using the RMAN Recovery Catalog
E x e r c i s e 5 .1 ( c o n t i n u e d )
6.Test to see whether you can connect to the recovery-catalog schema that you have just created:
SQL> connect rcat_user/rcat_user Connected.
7.Now you need to create the recovery-catalog schema. To do this, use the create catalog command as shown in this example:
C:\Documents and Settings\Robert>Rman catalog=rcat_user/rcat_user@rcat Recovery Manager: Release 11.1.0.6.0 - Production on
Mon Sep 15 23:10:13 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to recovery catalog database
RMAN> create catalog recovery catalog created
Some texts may show you granting connect or resource roles to the recovery catalog–schema owner. This is not required in Oracle Database 11g and may represent a security risk.
Using a Recovery Catalog
Using a recovery catalog is pretty straightforward with RMAN. You simply indicate that you want to connect to the recovery catalog when you start RMAN. You will also have to register the database before your first RMAN operation when connected to the recovery catalog. Most RMAN operations when connected to the recovery catalog are pretty much the same; it’s just that RMAN metadata will now be stored in both the control file and the recovery catalog. In the following sections, we will discuss these topics:
NN |
Connecting to the recovery catalog from RMAN |
NN |
Registering the database with the recovery catalog |
|
|
NN |
Unregistering a database from the recovery catalog |
Connecting to the Recovery Catalog from RMAN
When you start RMAN, you will need to indicate that you want to connect to a recovery catalog if you want the session to use the recovery catalog. There are a couple of ways of
Using a Recovery Catalog |
215 |
connecting to the recovery catalog. The first is to use the catalog RMAN command-line parameter, as shown in this example:
C:\Documents and Settings\Robert>Set oracle_sid=orcl C:\Documents and Settings\Robert>Rman target=sys/Robert catalog=rcat_user/rcat_user@rcat
Recovery Manager: Release 11.1.0.6.0 - Production on Mon Sep 15 22:17:11 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database (not started) connected to recovery catalog database RMAN>
Note the use of the terms target and catalog. As we first mentioned in Chapter 4, the database you are intending to back up is called the target database. In the previous example, you connected directly to the target database with RMAN. At the same time, you connected to the catalog database through Oracle Net. If you desired, you could connect directly to the catalog database and connect to the target database via Oracle Net, or you could connect to both databases via Oracle Net. Since the server itself does the backup work via locally allocated channels, connecting to the server or the recovery catalog through Oracle Net should not impose any undue performance constraints on the performance of your backups.
Another way of connecting to the recovery catalog is to do so from the RMAN commandline prompt using the connect command, as shown in this example:
C:\Documents and Settings\Robert>Rman target=sys/Robert
Recovery Manager: Release 11.1.0.6.0 - Production on Mon Sep 15 22:18:05 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database (not started) RMAN> Connect catalog rcat_user/rcat_user@rcat connected to recovery catalog database
Registering the Target Database with the Recovery Catalog
Once you have connected to the recovery catalog, you will have to register the database with the register database command. To be registered, the database must be mounted or open. In this example, you connect to the target database and the recovery catalog and then register the database with the recovery catalog:
C:\Documents and Settings\Robert>Rman target=sys/Robert catalog=rcat_user/rcat_user@rcat
216 Chapter 5 n Using the RMAN Recovery Catalog
Recovery Manager: Release 11.1.0.6.0 - Production on Mon Sep 15 23:12:51 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1190537904, not open) connected to recovery catalog database
RMAN> register database;
database registered in recovery catalog starting full resync of recovery catalog full resync complete
Unregistering a Database
If you are preparing to remove a database, you will want to remove its metadata from the recovery catalog. This is done with the unregister command, as shown in this example:
C:\Documents and Settings\Robert>Rman target=sys/Robert catalog=rcat_user/rcat_user@rcat
Recovery Manager: Release 11.1.0.6.0 - Production on Mon Sep 15 23:13:45 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1190537904, not open) connected to recovery catalog database
RMAN> unregister database;
database name is “ORCL” and DBID is 1190537904
Do you really want to unregister the database (enter YES or NO)? yes database unregistered from the recovery catalog
Unregistering a database from the recovery catalog will cause all recovery catalog–related records to be removed from the recovery catalog. Control-file records for that database will be retained, of course. You might have had older backup records stored in the recovery catalog, though. When you unregister a database, those old records will be lost if the age of the backups exceeds the setting of the CONTROL_FILE_RECORD_KEEP_TIME parameter. Also, any scripts related to the database in the recovery catalog will be lost (we will talk more about scripting later in this chapter).
Using Scripts in the RMAN
Recovery Catalog
One benefit of the recovery catalog is the ability to store RMAN scripts. In the following sections, these topics will be addressed:
NN |
Executing external scripts |
NN |
Creating stored scripts |
Using Scripts in the RMAN Recovery Catalog |
217 |
NN |
Replacing stored scripts |
|
|
NN |
Removing stored scripts |
|
|
NN |
Executing stored scripts |
|
|
NN |
Printing stored scripts |
|
|
NN |
Using script-substitution variables |
|
|
Executing External Scripts |
RMAN provides the ability to execute external scripts. You can do so from the RMAN command line using the cmdfile option, as shown here:
Rman target=/ cmdfile=run_me.rman
You can also run an external script from within RMAN using the @ command, as shown here:
RMAN> @run_me.rman
Creating Stored Scripts
Recovery catalog stored scripts provide the ability to centrally manage your backup and recovery scripts. Using global stored scripts allows you to use common scripts across the entire enterprise.
Use the create script RMAN command to store scripts in the recovery catalog. You will assign a name to the stored script when you create it. Stored scripts can be created to do many RMAN operations, including backups, recoveries, and database-maintenance operations. As mentioned earlier, you must be connected to the recovery catalog to be able to create a script.
Here is an example of using the create script command to create a script. This script does a backup of the database and the archived redo logs:
create script db_backup_script
{ backup database plus archivelog delete input;}
Note that if you are using virtual private catalogs (see more on these later in this chapter), you will need to create the script as a global script as shown here:
create global script db_delete_obsolete { delete obsolete;}
218 Chapter 5 n Using the RMAN Recovery Catalog
Replacing Stored Scripts
The replace script command is used to replace stored RMAN scripts. The following example demonstrates the use of the replace script command:
Replace script db_delete_obsolete { delete noprompt obsolete;}
Removing Stored Scripts
If you need to remove a stored script permanently, you can use the delete script command as shown here:
Delete script db_delete_obsolete;
Executing Stored Scripts
Once you have created the script, it might be nice to actually run it! To run the script, you will use the execute script command. This command must be run within the confines of an RMAN run block, as shown in this example:
Run {execute script db_delete_obsolete;}
Printing Stored Scripts
The print script command will print your script to the standard output device, allowing you to cut and paste its contents. Here is an example of the print script command:
RMAN> Print script db_delete_obsolete; printing stored script: db_delete_obsolete { delete obsolete;}
Using Script Substitution Variables
Oracle Database 11g provides for the use of substitution variables in RMAN scripts or command files. You define the substitution variables using the ampersand (&) character followed by a number, as shown in this example:
Restore database from tag &1;