Oracle9i Recovery Manager User's Guide Release 1 (9.0.1) Part Number A90135-01 |
|
This chapter describes how to get started using RMAN. This chapter contains these topics:
As explained in "Authentication for Database Connections", you must connect RMAN to the target database using the SYSDBA
role. 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.
If you connect using . . . | Then . . . |
---|---|
Operating system authentication |
You must have
See Also: Oracle9i Database Administrator's Guide to learn about authentication, and your operating system specific documentation to learn about adding |
Oracle Net |
You must create a password file using the ORAPWD utility, set
Also, you must add the net service name of the target database to the See Also: Oracle9i Database Administrator's Guide, and Oracle9i Net Services Administrator's Guide |
See Also:
Chapter 2, "Connecting to Databases with RMAN" for a complete explanation of how to start RMAN and connect to target, recovery catalog, and auxiliary databases |
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:
ARCHIVELOG
mode.
NOCATALOG
mode.
This section contains these topics:
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.0.1.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
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 uses the parameter file initPROD1.ora
:
RMAN> STARTUP MOUNT PFILE=/oracle/dbs/temp/initPROD1.ora 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 PFILE = initPROD1.ora # specify a parameter file if necessary
See Also:
Oracle9i Recovery Manager Reference for |
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 Name ---- ---------- -------------------- ------- ------------------- 1 47104 SYSTEM *** /oracle/dbs/tbs_01.f 2 978 SYSTEM *** /oracle/dbs/tbs_02.f 3 978 TBS_1 *** /oracle/dbs/tbs_11.f 4 978 TBS_1 *** /oracle/dbs/tbs_12.f 5 978 TBS_2 *** /oracle/dbs/tbs_21.f 6 978 TBS_2 *** /oracle/dbs/tbs_22.f
See Also:
Chapter 17, "Querying the RMAN Repository" to learn how to make reports, and Oracle9i Recovery Manager Reference for |
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 $ORACLE_HOME/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.
Run the backup
command at the RMAN prompt as follows to make a full backup of the database using the default disk channel:
RMAN> BACKUP DATABASE;
When RMAN backs up to disk, it generates 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:
allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=11 devtype=DISK channel ORA_DISK_1: starting full datafile backupset set_count=3 set_stamp=406292757 creation_time=22-AUG-00 channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/oracle/dbs/tbs_01.f input datafile fno=00016 name=/oracle/dbs/tbs_03.f input datafile fno=00017 name=/oracle/dbs/tbs_14.f input datafile fno=00018 name=/oracle/dbs/tbs_25.f . . . channel ORA_DISK_1: piece 1 created piece handle=/oracle/dbs/03c3f28l_1_1 comment=NONE
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:
|
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;
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;
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 '/oracle/dbs/df1.copy'; # 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 18-APR-01 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=8 devtype=DISK channel ORA_DISK_1: copied datafile 1 output filename=/oracle/dbs/df1.copy recid=1 stamp=422887273 Finished copy at 18-APR-01
See Also:
|
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:
List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 190 Full 67M SBT_TAPE 00:00:18 28-FEB-01 BP Key: 191 Status: AVAILABLE Tag: Piece Name: 02cj8rmg_1_1 List of Datafiles in backup set 190 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 54983 28-FEB-01 /ade/lashdown_main/oracle/dbs/tbs_01.f 2 Full 54983 28-FEB-01 /ade/lashdown_main/oracle/dbs/tbs_02.f 3 Full 54983 28-FEB-01 /ade/lashdown_main/oracle/dbs/tbs_11.f 4 Full 54983 28-FEB-01 /ade/lashdown_main/oracle/dbs/tbs_12.f 5 Full 54983 28-FEB-01 /ade/lashdown_main/oracle/dbs/tbs_21.f
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 ------- ---- - --------------- ---------- --------------- ---- 241 1 A 28-FEB-01 55152 28-FEB-01 /ade/lashdown_ main/oracle/work/df1.copy List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - --------- ---- 173 1 161 A 28-FEB-01 /ade/lashdown_main/oracle/work/arc_dest/arcr_1_161.arc 174 1 162 A 28-FEB-01 /ade/lashdown_main/oracle/work/arc_dest/arcr_1_162.arc 175 1 163 A 28-FEB-01 /ade/lashdown_main/oracle/work/arc_dest/arcr_1_163.arc
See Also:
|
Check that you are able to restore the backups that you created. Run the list backup
command to determine the key for the backup sets. The following is an example entry for a backup set:
List of Backup Sets Key Recid Stamp LV Set Stamp Set Count Completion Time ------- ---------- ---------- -- ---------- ---------- ---------------------- 3 3 352382231 0 352382211 49 18-APR-01
In this example, the primary key for the backup set is 3
. Use the key value for this backup set in the validate backupset
command as follows:
RMAN> VALIDATE BACKUPSET 3;
You should see output similar to the following:
allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=11 devtype=DISK channel ORA_DISK_1: starting validation of datafile backupset set_count=49 set_stamp=352382211 creation_time=18-DEC-00 channel ORA_DISK_1: restored backup piece 1 piece handle=/oracle/dbs/1hag1r83_1_1 params=NULL channel ORA_DISK_1: validation complete
If there are no error messages, then RMAN confirms that it is able to restore the backup set. When there is an error, RMAN always displays an error banner and provides messages indicating the nature of the error. For example, if you validate a backup set that no longer exists, then RMAN displays an error stack such as the following:
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-00579: the following error occurred at 02/26/2001 15:10:01 RMAN-03007: retryable error occurred during execution of command: validate RMAN-12004: unhandled exception during command execution on channel ORA_SBT_TAPE_1 RMAN-10035: exception raised in RPC: ORA-19507: failed to retrieve sequential file, handle="02cj4erl_1_1", parms="" ORA-27029: skgfrtrv: sbtrestore returned error ORA-19511: Error received from media manager layer, error text: sbtpvt_open_input: file /oracle/work/02cj4erl_1_1 does not exist or cannot be accessed, errno = 2 RMAN-10031: ORA-19624 occurred during call to DBMS_BACKUP_RESTORE.RESTOREBACKUPPIECE
See Also:
"Performing a Backup Validation with RMAN" to learn how to restore backups and copies, and Oracle9i Recovery Manager Reference for |
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 example on a UNIX platform temporarily renames four datafiles:
% mv /oracle/dbs/tbs_12.f /oracle/dbs/tbs_12.bak % mv /oracle/dbs/tbs_21.f /oracle/dbs/tbs_21.bak % mv /oracle/dbs/tbs_22.f /oracle/dbs/tbs_22.bak % mv /oracle/dbs/tbs_13.f /oracle/dbs/tbs_13.bak
Now, start RMAN and attempt to open the database as in the following example:
% rman TARGET / RMAN> STARTUP PFILE = initPROD1.ora
You should receive errors as in this example:
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-06003: ORACLE error from target database: ORA-01157: cannot identify/lock data file - see DBWR trace file RMAN-06097: text of failing SQL statement: alter database open RMAN-06099: error occurred in source file: krmk.pc, line: 3859
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;
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 the datafiles 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 tbs_2
tablespace.
While the database is open, rename one or more datafiles in the tablespace that you selected. This UNIX example temporarily renames two datafiles in tbs_2
tablespace:
% mv /oracle/dbs/tbs_21.f /oracle/dbs/tbs_21.bak % mv /oracle/dbs/tbs_22.f /oracle/dbs/tbs_22.bak
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 tbs_2 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 tbs_2; RMAN> RECOVER TABLESPACE tbs_2;
After recovery is complete, bring the tablespace online with the following command:
RMAN> SQL 'ALTER TABLESPACE tbs_2 ONLINE';
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 |
The $ORACLE_HOME/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 executable RMAN command files that are fully documented so that you can understand the features used. Edit them to customize them for your site.
See Also:
|
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 |
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:
CONTROL_FILE_RECORD_KEEP_TIME
setting, you can keep historical metadata.
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:
Chapter 16, "Managing the Recovery Manager Repository" to learn how to manage the recovery catalog
See Also:
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|