Skip Headers

Oracle9i Recovery Manager User's Guide
Release 2 (9.2)

Part Number A96566-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to next page

3
Quick Start to Recovery Manager

This chapter describes how to get started using RMAN. This chapter contains these topics:

Using Sample RMAN Scripts and Scenarios

The ?/rdbms/demo subdirectory (the location differs depending on your operating system) contains a number of sample RMAN scripts. The scripts are suffixed with the .rcv filename extension.

These files are case studies of RMAN commands that are fully documented so that you can understand the features used. You can customize them for your use in your own backup and recovery plan, or simply read them to learn how RMAN is used.

See Also:

Choosing an RMAN Authentication Method

As explained in "Authentication for Database Connections", to run RMAN commands you must first connect RMAN to the target database with the SYSDBA role to a dedicated server process. You can either connect using operating system authentication or using Oracle Net. An Oracle Net connection as SYSDBA requires that you create a password file.

Table 3-1 Deciding on an RMAN Authentication Method
If you connect using . . . Then . . .

Operating system authentication

You must have SYSDBA privileges on your operating system, and the initialization parameter REMOTE_LOGIN_PASSWORDFILE must be set to NONE.

See Also: Oracle9i Database Administrator's Guide to learn about authentication, and your operating system specific documentation to learn about adding SYSDBA privileges

Oracle Net

You must create a password file using the ORAPWD utility, set REMOTE_LOGIN_PASSWORDFILE to EXCLUSIVE, and add the user who connects to the target database to the password file.

Also, you must add the net service name of the target database to the tnsnames.ora file and configure the listener.ora file so that the target database can receive connections.

See Also: Oracle9i Database Administrator's Guide, and Oracle9i Net Services Administrator's Guide

See Also:

Using Basic RMAN Commands

After you have learned how to connect to a target database, you can immediately begin performing backup and recovery operations. Use the examples in this section to go through a basic backup and restore scenario using a test database. These examples assume the following:

This section contains these topics:

Connecting to the Target Database

The first task is to connect to the target database. If you have created a recovery catalog, then you can connect to it as well--although these examples assume you are connecting in the default NOCATALOG mode.

At the operating system command line, enter the following to connect to the target database in the default NOCATALOG mode:

% rman TARGET /

If the database is already mounted or open, then RMAN displays output similar to the following:

Recovery Manager: Release 9.2.0.0.0

connected to target database: RMAN (DBID=1237603294)

The DBID value displayed is the database identifier for the target database.

If the target database is not started, then RMAN shows the following message:

connected to target database (not started)

RMAN>   # the RMAN prompt is displayed
See Also:

Oracle9i Recovery Manager Reference for connection options

Starting Up and Shutting Down the Database

If the database is not started, then run the startup command at the RMAN prompt, specifying an initialization parameter file only if you do not use a server parameter file. This example starts the instance with the server parameter file:

RMAN> STARTUP MOUNT

Oracle instance started
database mounted

If the database is open, then you can run the following RMAN commands to close it cleanly and then mount it:

RMAN> SHUTDOWN IMMEDIATE

database closed
database dismounted
Oracle instance shut down

RMAN> STARTUP MOUNT
See Also:

Oracle9i Recovery Manager Reference for STARTUP syntax and Oracle9i Recovery Manager Reference for SHUTDOWN syntax

Reporting the Current Schema of the Target Database

In this example, you generate a report describing the target datafiles. Run the report schema command as follows:

RMAN> REPORT SCHEMA;

RMAN displays the datafiles currently in the target database. Depending on the contents of the database, you will see output similar to the following:

Report of database schema
File K-bytes    Tablespace           RB segs Datafile Name
---- ---------- -------------------- ------- -------------------
1        204800 SYSTEM               ***     /oracle/oradata/trgt/system01.dbf
2         20480 UNDOTBS              ***     /oracle/oradata/trgt/undotbs01.dbf
3         10240 CWMLITE              ***     /oracle/oradata/trgt/cwmlite01.dbf
4         10240 DRSYS                ***     /oracle/oradata/trgt/drsys01.dbf
5         10240 EXAMPLE              ***     /oracle/oradata/trgt/example01.dbf
6         10240 INDX                 ***     /oracle/oradata/trgt/indx01.dbf
7         10240 TOOLS                ***     /oracle/oradata/trgt/tools01.dbf
8         10240 USERS                ***     /oracle/oradata/trgt/users01.dbf
See Also:

Chapter 17, "Querying the RMAN Repository" to learn how to make reports, and Oracle9i Recovery Manager Reference for REPORT syntax

Backing Up the Database

In this task, you back up the database to the default disk location. The default location is port-specific. For example, on most UNIX systems the location is ?/dbs. Because you do not specify the format parameter in this example, RMAN assigns the backup a unique filename. If you do not manually allocate a channel, then RMAN uses a preconfigured disk channel by default.

You can make two basic types of backups: full and incremental. In a full backup, RMAN backs up all blocks of the target database files. In an incremental backup, RMAN backs up only the blocks that have changed since a previous backup.

Making a Full Backup

Run the backup command at the RMAN prompt as follows to make a full backup of the datafiles, control file, and current server parameter file (if the instance is started with a server parameter file) to the default device type:

RMAN> BACKUP DATABASE;

Unless you explicitly configure the default device to tape with the CONFIGURE command, the default device is disk.

When you run the BACKUP command, RMAN creates a backup set, which is a logical object that contains one or more backup pieces. The backup command output contains the essential information about the backup, as shown in the following example:

Starting backup at OCT 12 2001 19:09:48
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=10 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
including current controlfile in backupset
input datafile fno=00001 name=/oracle/oradata/trgt/system01.dbf
input datafile fno=00002 name=/oracle/oradata/trgt/undotbs01.dbf
input datafile fno=00003 name=/oracle/oradata/trgt/cwmlite01.dbf
input datafile fno=00004 name=/oracle/oradata/trgt/drsys01.dbf
input datafile fno=00005 name=/oracle/oradata/trgt/example01.dbf
input datafile fno=00006 name=/oracle/oradata/trgt/indx01.dbf
input datafile fno=00007 name=/oracle/oradata/trgt/tools01.dbf
input datafile fno=00008 name=/oracle/oradata/trgt/users01.dbf
channel ORA_DISK_1: starting piece 1 at OCT 12 2001 19:09:56
channel ORA_DISK_1: finished piece 1 at OCT 12 2001 19:10:31
piece handle=/oracle/dbs/lvd6dtk1_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:39
Finished backup at OCT 12 2001 19:10:33

Making an Incremental Backup

Incremental backups are a convenient way to conserve storage space because they back up only database blocks that have changed. RMAN compares the current datafiles to a base backup, also called a level 0 backup, to determine which blocks to back up.

For example, you can make a full backup as a base backup and then make some updates to the test database and commit them. Then, when you run the following command, RMAN backs up only those blocks that have changed since the previous full backup:

RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;

Note that you will see lines such as the following in the output:

no parent backup or copy of datafile 1 found

This line does not indicate a problem, but simply means that no base LEVEL 0 incremental backup exists. RMAN automatically creates a LEVEL 0 backup for its base incremental backup.

See Also:

Backing Up a Tablespace

Besides backing up the whole database, you can back up a tablespace or datafile. In this example, back up the SYSTEM tablespace to disk using the preconfigured disk channel. Of course, you can choose to back up a different object.

Run the backup command at the RMAN prompt as follows:

RMAN> BACKUP TABLESPACE SYSTEM;
See Also:

"Backing Up Tablespaces with RMAN" to learn how to back up tablespaces

Backing Up Archived Logs

Typically, database administrators back up archived logs on disk to a third-party storage medium such as tape. You can also back up archived logs to disk. In either case, you can delete the input logs automatically after the backup completes.

To back up all archived logs and delete the input logs (from the primary archiving destination only), run the backup command at the RMAN prompt as follows:

RMAN> BACKUP ARCHIVELOG ALL DELETE INPUT;
See Also:

"Backing Up Archived Redo Logs with RMAN" to learn how to back up archived redo logs

Copying a Datafile

In this example, make an image copy of datafile 1 to a new location. An image copy differs from a backup set in that it is not in an RMAN-specific format. It is the equivalent of a copy made using an operating system command such as the UNIX cp command.

This example uses an automatically allocated disk channel to create a datafile copy named df1.bak. Run the copy command as follows from the RMAN prompt, specifying the path name for the backup:

RMAN> COPY DATAFILE 1 TO '/tmp/df1.cpy';   # specify any filename that you choose

RMAN displays the full filename of the created file in the output, as in this example:

Starting copy at OCT 12 2001 19:11:28
using channel ORA_DISK_1
channel ORA_DISK_1: copied datafile 1
output filename=/tmp/df1.cpy recid=141 stamp=442955509
Finished copy at OCT 12 2001 19:11:59
Finished copy at 18-APR-01
See Also:

Listing Backups and Copies

To list the backup sets and image copies that you have created, run the list command as follows:

RMAN> LIST BACKUP;

RMAN displays which backup sets and pieces it created as well as which datafiles it included in those sets, as in the following example:

BS Key  Type LV Size       Device Type Elapsed Time Completion Time     
------- ---- -- ---------- ----------- ------------ --------------------
699     Full    122M       DISK        00:00:30     OCT 12 2001 19:10:23
        BP Key: 1293   Status: AVAILABLE   Tag: TAG20011012T191001
        Piece Name: /oracle/dbs/lvd6dtk1_1_1
  Controlfile Included: Ckp SCN: 322170       Ckp time: OCT 12 2001 19:09:53
  SPFILE Included: Modification time: OCT 12 2001 19:09:53
  List of Datafiles in backup set 699
  File LV Type Ckp SCN    Ckp Time             Name
  ---- -- ---- ---------- -------------------- ----
  1       Full 322172     OCT 12 2001 19:09:56 /oracle/oradata/trgt/system01.dbf
  2       Full 322172     OCT 12 2001 19:09:56 /oracle/oradata/trgt/undotbs01.dbf
  3       Full 322172     OCT 12 2001 19:09:56 /oracle/oradata/trgt/cwmlite01.dbf
  4       Full 322172     OCT 12 2001 19:09:56 /oracle/oradata/trgt/drsys01.dbf
  5       Full 322172     OCT 12 2001 19:09:56 /oracle/oradata/trgt/example01.dbf
  6       Full 322172     OCT 12 2001 19:09:56 /oracle/oradata/trgt/indx01.dbf
  7       Full 322172     OCT 12 2001 19:09:56 /oracle/oradata/trgt/tools01.dbf
  8       Full 322172     OCT 12 2001 19:09:56 /oracle/oradata/trgt/users01.dbf

To list image copies, run the following command:

RMAN> LIST COPY;

RMAN displays both datafile and control file copies as well as archived redo logs (an archived redo log is considered a type of copy):

List of Datafile Copies
Key     File S Completion Time      Ckp SCN    Ckp Time             Name
------- ---- - -------------------- ---------- -------------------- ----
141     1    A OCT 12 2001 19:11:49 322204     OCT 12 2001 19:11:29 /tmp/df1.copy

List of Archived Log Copies
Key     Thrd Seq     S Low Time             Name
------- ---- ------- - -------------------- ----
1105    1    70      A OCT 10 2001 17:55:49 /oracle/oradata/trgt/arch/archive1_70.dbf
1106    1    71      A OCT 11 2001 05:12:06 /oracle/oradata/trgt/arch/archive1_71.dbf
1107    1    72      A OCT 11 2001 14:54:36 /oracle/oradata/trgt/arch/archive1_72.dbf
1108    1    73      A OCT 11 2001 14:55:48 /oracle/oradata/trgt/arch/archive1_73.dbf
1109    1    74      A OCT 11 2001 15:13:27 /oracle/oradata/trgt/arch/archive1_74.dbf
1110    1    75      A OCT 12 2001 06:56:22 /oracle/oradata/trgt/arch/archive1_75.dbf
See Also:

Validating the Restore of a Backup

Check that you are able to restore the backups that you created without actually restoring them. Run the RESTORE ... VALIDATE command as follows:

RMAN> RESTORE DATABASE VALIDATE;

You should see output similar to the following:

Starting restore at 07-DEC-01

allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=9 devtype=DISK
channel ORA_DISK_1: starting validation of datafile backupset
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/dbs/07db39tr_1_1 tag=TAG20011012T191001 params=NULL
channel ORA_DISK_1: validation complete
Finished restore at 07-DEC-01

If there are no error messages, then RMAN confirms that the database backup can be restored. When there is an error, RMAN always displays an error banner and provides messages indicating the nature of the error. For example, if you attempt to restore the database when some backups do not exist, then RMAN displays an error stack such as the following:

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/07/2001 17:28:24
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 8 found to restore
RMAN-06023: no backup or copy of datafile 7 found to restore
See Also:

"Performing a Backup Validation with RMAN" to learn how to restore backups and copies, and Oracle9i Recovery Manager Reference for VALIDATE syntax

Restoring and Recovering the Database

The primary aspect of developing a backup and recovery strategy is learning what to do in case of a media failure. In this scenario, you simulate a media failure. First, shut down the database and then exit RMAN with the following commands:

RMAN> SHUTDOWN IMMEDIATE;
RMAN> EXIT;

After the database is shut down, use the output from the REPORT SCHEMA command in "Reporting the Current Schema of the Target Database" to identify the filenames of your datafiles. Temporarily rename some or all of your database files with operating system commands (but make sure not to rename your control files). This action simulates a media failure because Oracle is able to find the datafiles during startup.

This UNIX example temporarily renames the datafile in the tools tablespace:

% mv $ORACLE_HOME/oradata/trgt/tools01.dbf $ORACLE_HOME/oradata/trgt/tools01.bak

Now, start RMAN and attempt to open the database as in the following example:

% rman TARGET /
RMAN> STARTUP

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 08/29/2001 13:46:04
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/oracle/oradata/trgt/tools01.dbf'

The database mounts but does not open because some datafiles require recovery. To restore and recover the database using the default disk channel, simply run the following commands from the RMAN prompt:

RMAN> RESTORE DATABASE;
RMAN> RECOVER DATABASE;

RMAN uses the backups and copies that you made earlier and restores the files to their default locations. Then, it uses archived redo logs (if needed) to recover the database. After recovery is complete, open the database:

RMAN> ALTER DATABASE OPEN;

Restoring and Recovering a Tablespace

It is not uncommon for a media failure to affect some but not all files in a database. In this scenario, you simulate a media failure to a datafile in a single tablespace. Use the output from the REPORT SCHEMA command in the previous example to identify the filenames of datafiles in a tablespace other than the SYSTEM tablespace. This example renames datafiles in the tools tablespace.

While the database is open, rename one or more datafiles in the tablespace that you selected. This UNIX example temporarily renames a datafile in tools tablespace:

% mv $ORACLE_HOME/oradata/trgt/tools01.dbf /tmp/tools01.dbf

If you attempt to update a table located in one of the renamed datafiles, Oracle generates an error message because the datafile is unavailable. You need to restore and recover the missing datafiles. First, start RMAN and then take the tablespace offline using the SQL command, making sure to specify the name of the tablespace:

RMAN> SQL 'ALTER TALBESPACE tools OFFLINE IMMEDIATE';

To restore and recover the tablespace with the default disk channel, simply run the following commands from the RMAN prompt:

RMAN> RESTORE TABLESPACE tools;
RMAN> RECOVER TABLESPACE tools;

After recovery is complete, bring the tablespace online with the following command:

RMAN> SQL 'ALTER TABLESPACE tools ONLINE';

Showing the RMAN Configuration

RMAN contains some default configuration settings. These settings apply to all RMAN sessions until you explicitly change or disable them with another CONFIGURE command. You can always return to a default configuration setting by running the CONFIGURE ... CLEAR command.

Of the possible configurations, perhaps the most important are the automatic channels and the retention policy. RMAN is preconfigured with an automatic disk channel so that you can make backups and copies to disk without manually allocating channels.

To see all the current RMAN configuration settings, run this command:

RMAN> SHOW ALL;
See Also:

Chapter 8, "Configuring the Recovery Manager Environment" to learn how to create RMAN configurations

Deciding Whether to Use RMAN with a Recovery Catalog

By default, RMAN connects to the target database in NOCATALOG mode, meaning that it uses the control file in the target database as the sole repository of RMAN metadata. Perhaps the most important decision you make when using RMAN is whether to create a recovery catalog as the RMAN repository for normal production operations. A recovery catalog is a schema created in a separate database that contains metadata obtained from the target control file.

In general, Oracle Corporation advises using a catalog when you manage multiple databases. If you have more than one database to back up, then you can create one systemwide recovery catalog and store metadata for all the databases in this catalog. Hence, you avoid the extra space requirements and memory overhead of maintaining multiple databases, each with a single catalog. You need to take extra precautions when backing up the catalog, however, because if you lose the catalog then you lose the metadata for multiple target databases.

This section outlines some of the costs and benefits associated with using and not using a recovery catalog. If you decide to create a catalog, refer to "Creating the Recovery Catalog" for instructions.

See Also:

"RMAN Repository" for an overview of the function of the RMAN repository in the RMAN environment

Benefits of Using the Recovery Catalog as the RMAN Repository

When you use a recovery catalog, RMAN can perform a wider variety of automated backup and recovery functions than when you use the control file in the target database as the sole repository of metadata. The following features are available only with a catalog:

Costs of Using the Recovery Catalog as the RMAN Repository

The main cost of using a catalog is the maintenance overhead required for this additional database. For example, you have to:

Hence, unless you manage a network of databases, you may choose to avoid the overhead and use the control file as the exclusive repository of metadata. When you use a control file as the RMAN repository, RMAN still functions effectively. If you do not use a catalog, read the section "Managing the RMAN Repository Without a Recovery Catalog". Specifically, make sure you:


Go to previous page Go to next page
Oracle
Copyright © 1996, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback