- •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
Backup and recovery is one of the central themes in the Oracle Database 11g OCP exam. In Chapters 2 and 3 we talked about user-managed backup and recovery in Oracle, and now we
will move on to what is termed server-managed backups, which are managed by RMAN. RMAN is like SQL*Plus in some ways. RMAN is a client. It connects to the Oracle database and issues a few commands to the server, and the server actually does the work (hence the term server-based backups). The server reports the results to RMAN and RMAN reports those results to you.
In this chapter we will introduce you to RMAN. We will discuss the features and configuration of RMAN, including configuration of the flash recovery area (FRA). We will also discuss using RMAN to back up your Oracle database. In Chapter 5 we will continue with a discussion of using RMAN to restore and recover your Oracle database.
Exam objectives are subject to change at any time without prior notice and at Oracle’s sole discretion. Please visit Oracle’s Training and Certification website (http://www.oracle.com/education/certification/) for the most current exam-objectives listing.
Why Use RMAN?
RMAN has many capabilities to facilitate the backup and recovery process. It comes in both web-based GUI and command-line versions. In general, RMAN performs and standardizes the backup and recovery process, which can reduce mistakes made during this process. The following are just a few of the exciting RMAN features:
NN |
It’s free with the Oracle license. |
NNYou can perform full and incremental backups of the entire database, specific tablespaces, and datafiles. You can also back up control files and archive logs.
NN |
RMAN offers persistent parameter configuration for easy backup and recovery. |
NN |
RMAN offers automated backups of control files and spfiles. |
NN |
You can validate your database backups without actually recovering your database. |
|
|
NN |
RMAN offers actual compression of backup images through various means. |
NN |
RMAN offers actual encryption of database backups. |
NN |
RMAN provides various backup reporting capabilities. |
|
Exploring the RMAN Architecture |
155 |
NN |
RMAN provides scripting capabilities when you are using a recovery catalog. |
NNWith the Media Management Library (MML) you can integrate easily with third-party tape media software.
NN |
RMAN provides for parallel processing of backups and restores. |
NN |
With RMAN, you can create duplicate databases. |
NN |
RMAN helps you migrate datafiles across operating-system platforms. |
|
|
NN |
With RMAN, you can perform tablespace point-in-time recovery (TSPITR). |
NN |
RMAN allows you to recover datafiles that aren’t backed up. |
NN |
RMAN will automatically recover tempfiles during a database recovery. |
|
Exploring the RMAN Architecture
As you can see, RMAN has a rich feature set, and with each version of Oracle, the feature set becomes even richer. Oracle Database 11g offers a very full-featured backup and recovery tool in the form of RMAN.
RMAN is based on a robust architecture consisting of the following main components:
NN |
The RMAN client interface |
|
|
NN |
The database server |
NN |
The database control file |
NN |
The optional recovery catalog |
|
|
NN |
Database pfile or spfile |
NN |
Backup media and the Media Management Library (MML) |
NN |
Backup sets and backup set pieces |
|
|
NN |
RMAN channels |
NN |
Snapshot control file |
Let’s look at each component in a bit more detail:
RMAN client interface The RMAN command-line interface (RCLI) provides access to Recovery Manager. This process spawns off-server sessions that connect to the target database, which is the database that will be backed up. From the RMAN client interface you will issue RMAN commands to execute RMAN backup, recovery, and restore operations.
Previous versions of this text (and OCP exams) contained significant coverage of Oracle Enterprise Manager (OEM). The Oracle Database 11g OCP exam contains no coverage specific to OEM, and much more coverage on user-based backup and recovery. As a result, there is little coverage of OEM within this text.
156 Chapter 4 n Configuring and Backing Up Using RMAN
Database server The database server is the principal mechanism used to back up the database. Built into the core of the Oracle kernel code are stored packages used by RMAN to back up, restore, and recover the database. RMAN cannot execute back up, restore, or recover operations without having first attached to the database server. Depending on the operation, the database will need to be opened in NOMOUNT, MOUNT, or OPEN mode.
Control file The database control file is used to store RMAN-related information for each database. The control file is the principal storage mechanism for all RMAN-related records. All records with respect to database backups, archive-log backups, and controlfile backups are stored in the control file. Control files have limitations with respect to how many RMAN records they can hold, and as a result, certain retention requirements may call for the use of a recovery catalog to augment a control file. RMAN provides an automated means of backing up the control file and restoring it when a control file is not readily available. This method is called a control-file autobackup.
Recovery catalog The recovery catalog is an optional component that stores RMANrelated information inside an Oracle database. This is similar to the RMAN repository stored in the control file, but the recovery catalog provides some additional features and longer-term storage of RMAN records. The recovery catalog is a special schema that contains backup-related information in a set of tables. During normal database operations, RMAN will synchronize the database control file with the recovery catalog, ensuring that the recovery-catalog schema is in synchronization with the database control file.
Database pfile or spfile You should already be familiar with the database parameter file (pfile) and the server parameter file (spfile). These files are critical to RMAN operations because they contain parameters that impact RMAN operations. RMAN can be used to back up and recover an spfile using an option called autobackups. Pfiles can not be backed up with RMAN.
Backup media and the Media Management Library Obviously, if RMAN is going to back up your database, it needs to back it up somewhere. RMAN, out of the box, allows you
to back up your database to disk. This can be the local disk, or a network-attached disk (in other words, NFS) can be used. RMAN also offers the Media Management Library (MML). The MML is an API set that media vendors (for example, tape-drive vendors) can write to and that allows RMAN to communicate directly with their products.
Backup sets and backup set pieces Backup sets are logical entities that consist of one or more backup set pieces. Backup set pieces are physical files that actually store the RMAN backup data.
RMAN channels Channels are used in RMAN to indicate the device to back up to. They are also used to partition a backup operation, essentially parallelizing the operation. For example, if you had two tape units, you could create two different RMAN channels and stream your backup to the two different tape devices in parallel. This can reduce backup and recovery times significantly.
Connecting to RMAN |
157 |
RMAN offers automated channel failover for both backup and recovery operations. With automated channel failover, if a channel in a multichannel backup fails, the other channels will continue to back up the remainder of the database. This can be helpful when, for example, a tape device fails. In addition, Oracle will retry to back up the data that was on the failed channel across the remaining channels.
Snapshot control file When RMAN does its business, it bases its knowledge of the database on information in the database control file. That’s fine and well, but if the control file changes during an RMAN operation, what is RMAN to do, use the old information or the new information? The answer to this dilemma is the snapshot control file.
When RMAN performs any operation that requires a consistent view of the control file (such as a backup), it will first create a copy of the control file. This copy is called the snapshot control file. The snapshot control file will be used for the duration of that operation and will be overwritten by any subsequent operation. Even related operations (say, during a backup database plus archive-log operation that does an archive log backup, a database backup, and then another archive log backup) will use newly created snapshot control files, one for each operation.
Connecting to RMAN
Connecting to the RMAN client is quite simple. RMAN is a command-line tool, so you would want to open a command-line window for your operating system. Once you have done that you will set your ORACLE_HOME environment to the database that you want to connect to. Now you can start RMAN and connect to the target database (or the database that you want to backup and recover). Here is an example of connecting to a database with the RMAN client:
C:\oracle\admin\ORCL\wallet>set oracle_sid=orcl C:\oracle\admin\ORCL\wallet>rman target=/
Recovery Manager: Release 11.1.0.6.0 - Production on Thu Sep 11 18:28:24 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1190537904)
Sometimes you may need to connect to your target database using Oracle Net connection strings. If you are using a recovery catalog or an auxiliary database you will normally connect to those using Oracle Net connection strings, as seen in these examples:
C:\oracle\admin\ORCL\wallet>rman target=sys/robert@orcl C:\oracle\admin\ORCL\wallet>rman target=sys/robert@orcl catalog=rcat_user/robert@rcat
158 Chapter 4 n Configuring and Backing Up Using RMAN
The RMAN command line contains a number of different command-line parameters. You will see many of these in use throughout these next few chapters. Table 4.1 provides an overview of the most commonly used command-line parameters you might use:
Putting Files in ORACLE_HOME Is Not a Best Practice
You might have noticed that RMAN puts the snapshot control file in an ORACLE_HOME location by default. This is not unusual; Oracle does this for other types of files (for example, the FRA defaults to ORACLE_HOME) by default.
In the real world, defaults like this are never acceptable, and we never allow ORACLE_HOME to be the destination for any type of file other than those associated with the Oracle install and certain configuration files (thus its size is fairly static). This is because you do not want the disk space in ORACLE_HOME to unexpectedly become exhausted because Oracle databases are writing files into it. This becomes even more important as you add more databases to your server and those databases are using the same ORACLE_HOME concurrently. Allowing those databases to write to ORACLE_HOME can cause problems for all databases on the server.
RMAN snapshot control files, files and directories associated with the Automatic Diagnostic Repository (ADR), database datafiles, and most other database-related files should be created in directories specific to each database other than ORACLE_HOME. (See Chapter 10 for more on ADR.)
The real-world solution generally involves the creation of different mount points for data- base-specific data. These mount points might be shared among different databases, or there might be a unique mount point for each database (or perhaps several mount points for one or more databases). For example, if your database is ORCL, you might have the following mount points/directories created:
NN /oracle01/oracle/product/11.1.0/db_1: ORACLE_HOME
NN |
/oracle02/oracle/oradata/orcl (for Oracle Database datafiles) |
NN |
/oracle03/oracle/oradata/orcl (for Oracle Database datafiles) |
NN |
/oracle04/oracle/diag (for the ADR) |
For more information, you may want to review Oracle’s OFA recommendations. OFA is outside the scope of the OCP exam and this book, but it provides some guidance from Oracle on directory naming and placement for Oracle-related files.