Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Oracle Database 11g.pdf
Скачиваний:
78
Добавлен:
10.06.2015
Размер:
12.69 Mб
Скачать

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.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]