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

Maintaining the Recovery Catalog 

219

The RMAN executable includes the using command-line parameter that allows you to define the value of the substitution variable. For example, if the previous restore command were in a file called restore.cmd and you wanted to restore a backup with the tag MINE, you would call RMAN in this manner:

Rman target=/ @restore.cmd using MINE

You can also use substitution variables with stored scripts. For example, you can create a script to back up your database and use a tag as shown here:

RMAN> create script db_backup_script

2> { backup database tag ‘&1’ plus archivelog delete input;} Enter value for 1: test

created script db_backup_script

You can then execute the script, setting the variable with the using command, as shown here:

RMAN> Run {execute script db_backup_script using ‘TEST’;}

Maintaining the Recovery Catalog

If you are running the recovery catalog, you will need to know how to synchronize it with the control file of the database. Additionally, you will need to back up the recovery catalog. We briefly cover these two topics next.

Synchronizing the Recovery Catalog

Typically during an RMAN operation, the recovery catalog will be synchronized with the control file. New records will be updated or added during this synchronization process. There may be times you will want to synchronize the recovery catalog yourself manually. You can use the resync catalog command to perform manual catalog synchronization. Here is an example of using the resync command:

RMAN> resync catalog;

starting full resync of recovery catalog full resync complete

Backing Up the Recovery Catalog

You can actually back up the recovery catalog using RMAN. You would simply use the control file of the recovery catalog to store the backup-related information. You can do online or offline backups and complete or point-in-time restores as your needs dictate.

220  Chapter 5  n  Using the RMAN Recovery Catalog

You can also use Oracle’s flashback features (see Chapter 9 for more on Oracle Flashback Database) on the recovery catalog.

Why Resync the Catalog?

You might be asking yourself, “If RMAN resynchronizes the catalog automatically after a backup, why would I ever need to use the resync catalog command?” That’s a fair question.

One place where one of us was employed had a large number of databases and used RMAN and the recovery catalog. As more and more records were added to the recovery catalog, we found our backups were taking longer. This ended up being because of a bug in RMAN. To work around the problem until Oracle could give us a fix, we did our backups without connecting to the recovery catalog. These made the backups perform much faster. We would then connect to the recovery catalog in a different operation and resync the control file to the recovery catalog.

This corrected the performance problem while still allowing us to use the recovery catalog to store our database backup metadata.

Using the RMAN Virtual Private Catalog

You might have noticed that the catalog-schema owner has access to all data in the recovery catalog. You may want to allow other users access to the recovery catalog, but you may want them to see information on only specific databases. Oracle provides the RMAN virtual private catalog for just such cases. In the following sections, we will discuss how to create a virtual catalog and how to grant users access to databases contained within it. We will discuss how to create the RMAN virtual private catalog first, and then we will discuss administration of the virtual private catalog.

Creating the RMAN Virtual Private Catalog

If you want to use the RMAN virtual private catalog (RVPC), you start with a regular recovery catalog. The recovery-catalog schema should have been created and the databases registered (you can, of course, register databases later), and it can be brand-new or already have been in use.

Using the RMAN Virtual Private Catalog 

221

Now that you have a recovery catalog, let’s assume you have registered two databases in the recovery catalog; one is called orcl and one is called secret. Let’s assume you have a DBA named Ed who you don’t quite trust (he’s a seedy-looking guy with tattoos of the Smurfs all over his arms). Because you don’t trust him, you want him to be able to access

only the orcl database RMAN records. The secret database records will remain a mystery to him (you assume, of course, that he does not have SYS access to your recovery catalog, or all is lost!).

To create the RVPC account for Ed, you would execute the following steps:

Step 1: Create the RVPC database account.  ​  First​ you create the RVPC database account log in the recovery-catalog database as a privileged user (for example, SYS) and issue the create user command. You will also need to grant the recovery_catalog_owner privilege to the new user.

Step 2: Create the RVPC.  ​  ​Once the RVPC user has been created, you need to create the virtual catalog. To do this, you log into RMAN and use the create virtual catalog command, as shown here:

Create virtual catalog;

Step 3: Grant the RVPC access to the appropriate catalog databases.   ​  Now​ that you have created the RVPC account, you need to indicate to the recovery-catalog database which databases this account will have access to. You will use the RMAN command to perform this operation as shown here, where we grant access to the ORCL database catalog metadata:

grant catalog for database orcl to rcat_001;

Administering the RMAN Virtual Private Catalog

Once you have set up RVPC, there are other administrative activities you can perform. For example, you can grant the register database privilege to RVPC owners using the RMAN grant command as shown here:

RMAN> grant register database to rcat_002;

Grant succeeded.

The revoke RMAN command is used to revoke privileges to databases in the RVPC or other privileges, such as the register database privilege, as shown here:

RMAN>Revoke catalog for database abcs;

RMAN>Revoke register database from rcat_002;

222  Chapter 5  n  Using the RMAN Recovery Catalog

Finally, you can drop the RVPC with the drop catalog command as shown in this example:

RMAN>connect catalog rcat_002/rcat002@rcat;

RMAN> drop catalog;

After using the drop catalog command, it’s safe to drop the RVPC catalog user with the drop user SQL command:

SQL> drop user rcat_001;

Summary

The recovery catalog is an optional but very powerful tool in your RMAN arsenal. It can make your life as a DBA easier by providing a centralized repository for all your RMANrelated data. The recovery catalog is easy to create and maintain. Oracle’s new virtual private catalog features make the recovery catalog even more powerful, increasing the security within the catalog.

Exam Essentials

Identify situations that will require the RMAN recovery catalog.  ​  Understand​ that the recovery catalog is largely optional. A recovery catalog will be needed for storing scripts, and it will be required if you want to store backup records longer than one year or beyond the setting of CONTROL_FILE_RECORD_KEEP_TIME.

Create and configure an RMAN recovery catalog.  ​  Understand​ the process required to create the RMAN recovery catalog. Know how to create the recovery-catalog user and what privileges are required. Understand how to register and unregister databases with the recovery catalog and how to create a virtual private catalog and configure users to use it.

Maintain the RMAN recovery catalog.  ​  ​Understand how to back up the recovery catalog. Know how to synchronize the target database with the recovery catalog.

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