| Oracle® Database Backup and Recovery Advanced User's Guide 10g< /i> Release 1 (10.1) Part Number B10734-01 |
|
![]() Previous |
![]() Next |
This chapter describes the basic concepts involved in using the Recovery M anager (RMAN) utility.
This chapter contains these topics:
The RMAN repository contains extensive records of about backups as
well as other useful information such as database schema and configuration settings. You can use RMAN commands LIST, SHOW to access this repository information.
In addition
to these general reporting commands, you can also make use of the RESTORE... PREVIEW command to see which
backup files are required to restore specific database objects from backup. See Oracle Database Backup and Recovery Basics for more details on RESTORE... PREVIEW.
The LIST command is used to query the RMAN repository and obtain data about:
BACKUP command;BACKUP-generated files, that is, archived logs, datafiles, control files,
and server parameter files;RMAN LIST output is sent either to standard outp ut or to the message log (though not to both at the same time). You can also control how the output is organized as well as the level of detail in the output.
You can also list backups by querying V$BACKUP_FILES
and the RC_BACKUP_FILES recovery catalog view. These views provide access to the same information as the LIST BACKUPSET command.
The LIST command displays the same files t
hat the CROSSCHECK and DELETE commands operate on. Consequently, you can issue LIST to see wha
t is in the repository, and then run CROSSCHECK to ensure that these files exist on disk or tape.
See Also:
|
RMAN reports are i ntended to provide analysis of your backup and recovery situation. An RMAN report can answer questions such as:
RMAN's reporting can be used to monitor and val
idate your ongoing backup strategy. The REPORT NEED BACKUP and REPORT UNRECOVERABLE commands let you ensure
that the necessary backups are available for media recovery, and that you can perform media recovery within a reasonable amount of t
ime.
Also, if you are managing backup storage yourself instead of using a flash recovery ar
ea, then you should run REPORT OBSOLETE regularly to identify backups no longer needed to meet your retention policy. Yo
u can then delete these backups with DELETE OBSOLETE.
The REPORT OBSOLETE ORPHAN com
mand displays orphaned backups. To understand orphaned backups, you must understand the ide aof
a database incarnation.
A new incarnation of a database is created whenever each time the database is opened wi
th the RESETLOGS option. Performing an OPEN RESETLOGS archives the current online redo logs, resets the log
sequence number to 1, and then gives the online redo logs a new time stamp and SCN.
RMAN i
s able to restore backups from direct ancestor incarnations and recover to the current time, even across OPEN RESETLOGS
operations, as long as a continuous path of archived logs exists from the earliest backups to the point to which you want to recover.
When a database goes through multiple incarnations, some backups can become orphaned. Orph aned backups are backups that are unusable because they belong to incarnations of the database that are not direct ancestors of the c urrent incarnation. That is, they are not in an unbroken incarnation path from the current incarnation.
< p class="BP">Figure shows a database that goes through three incarnations.
Text description of the illustration bradv034.gif
Incarnation A of the database
started at SCN 1. At SCN 10, assume that you performed a RESETLOGS operation and created incarnation B. At SCN 20, you
performed another RESETLOGS operation on incarnation B and created a new incarnation C.
The following table explains which backups in this example are orphans, depending on which incarnation is current.
| Current Incarnation | Usable Backups (Nonorphaned) | Orph aned Backups |
|---|---|---|
|
Incarnation A |
All backups from incar nation A |
All backups from incarnations B and C |
|
Incarnation B |
||
|
Incarnation C |
td> |
| See Also:
Oracle Database Backup and Recovery Basics to learn how to generate reports, an
d Oracle Database Recovery Man
ager Reference for |
The SHOW command can display any configuration set by the CONFIGURE command. For exam
ple, to display the CONFIGURE CHANNEL settings, run SHOW CHANNEL. You can run ALL to display all current configurations. This configuration data is also stored in the V$RMAN_CON
FIGURATION view.
| See Also:
Oracle Database Recovery Manager Reference for |
RMAN's re cord of backups can become out of step with the actual backups that exist on tape or disk. For example, a user may inadvertently dele te backup pieces from disk using operating system commands, or one of the tapes used by the media manager may become corrupted.
< a name="1006366">To ensure that data about backups in the recovery catalog or control file is synchronized with a
ctual files on disk or in the media management catalog, perform a crosscheck. The CROSSCH
ECK command operates only on files that are recorded in the RMAN repository.
Figure 4-2 illustrates a crosscheck of the media manager. RMAN queries the RMAN repository for the n
ames and locations of the four backup pieces to be checked. RMAN sends this information to the target database server, which queries
the media management software about the backups. The media management software then checks its media catalog and reports back to the
server that backup set 3 is missing. RMAN updates the status of backup set 3 to EXPIRED in the
repository. The record for backup set 3 will now be deleted if you run DELETE EXPIRED.
Text description of the illustration bradv031.gif
Crosschecks are useful because they can
Use the crosschec
k feature to check the status of a backup on disk or tape. If the backup is on disk, then CROSSCHECK checks whether the
header of the file is valid. If a backup is on tape, then the command checks that the backups exist in the media management software'
s catalog.
Backup pieces and image copies can have the status AVAILABLE, EXPIRED, or UNAVAILABLE. You can view the status information in the output of the LIST command and
the recovery catalog views.
You can issue the DELETE EXPIRED comm
and to delete all expired backups. RMAN removes the record for the expired file from the repository. If for some reason the file stil
l exists on the media, then RMAN issues warnings and lists the mismatched objects that cannot be deleted.
|
< /a>Note: The |
CROSSCHECK syntax and a description of th
e possible status valuesDELETE syntax
li>When LIST, REPORT and SHOW do not provide all the information you need on RMAN activities, there are a number of useful V$ views that can provide more details.
Sometimes it is useful to identify exactly what a server session performing a backup or recovery task is doing. You have access to several views that can assist in monitoring t he progress of or obtaining information about RMAN jobs, as described in the following table.
Asynchronous I/O is obtained either through the use of slave I/O processes or because it is supported by the underly ing operating system.
You can use RMAN to perform the checks discussed in the following sec tions:
To identify
which server sessions correspond to which RMAN channels, you can query V$SESSION and V$PROCESS. The S
PID column of V$PROCESS identifies the operating system ID number for the process or thread. For example, on UNIX
the SPID column shows the process ID, whereas on Windows the SPID column shows the thread ID. You have two
basic methods for obtaining this information, depending on whether you have multiple RMAN sessions active concurrently.
When only one RMAN session is active, the easiest method for determining the server session ID for an RMAN channel is to execute the following query on the target database while the RMAN job is executing:
COLUMN CLIENT_INFO FORMAT a30 COLUMN SID FORMAT 999 COLUMN SPID FORMAT 9999 SELEC T s.SID, p.SPID, s.CLIENT_INFO FROM V$PROCESS p, V$SESSION s WHERE p.ADDR = s.PADDR AND CLIENT_INFO LIKE 'rman%' ;
If you do not run the SET COMMAND ID command in the RMAN job, then the CLIENT_INFO<
/code> column displays in the following format:
rman channel=channel_id
For example, the following shows sample output:
SID SPID CLIENT_INFO ---- ------------ ------------------------------ 14 8374 rman channel=ORA_SBT_TAPE_1
If more than one RMAN session is active, it is possible for the V$SESS
ION.CLIENT_INFO column to yield the same information for a channel in each session. For example:
SID SPID CLIENT_INFO ---- ------------ ------------------------------ < /a> 14 8374 rman channel=ORA_SBT_TAPE_1 9 8642 rman channel=ORA_SBT_TAPE_1
In this case, you have the following methods for determining which channel corres
ponds to which SID value.
In this method, you must first obtain the sid values from the RMAN output and then use these values in your SQL
query.
To correlate a process with a channel during a backup:
sid for the channel. For example, the output may show:
Starting backup at 21-AUG-01 allocated channel: ORA_SBT_TAPE_1 chan nel ORA_SBT_TAPE_1: sid=14 devtype=SBT_TAPE
V$SESSION and V$PROCESS views whi
le the RMAN job is executing. For example, enter:
COLUMN CLIENT_INFO FORMAT a30 COLUMN SID FORMAT 999 COLUMN SPID FORMAT 9999 SELECT s.SID, p.SPID, s.CLIENT_INFO FROM V$PROCESS p, V$SESSION s WHERE p.ADDR = s.PADDR AND CLIENT_INFO LIKE 'rman%' /
Use the sid value obtained from the first step to determine which channel corresponds to which server session:
SID SPID CLIENT_INFO ---------- ------------ ------------ ------------------ 14 2036 rman channel=ORA_SBT_TAPE_1 12 2066 rman channel=ORA_SBT_TAPE_1
In this method, you specify a command ID string in the RMAN backup script. You can then query
To correlate a proces s with a channel during a backup:
COMMAND ID to a different value after allocating the channels
and then back up the desired object. For example, enter the following in session 1:
RMAN> RUN { ALLOCATE CHANNEL c1 TYPE sbt; SET COMMAND ID TO 'sess1' ; BACKUP DATABASE; }
Set the command ID to a string such as sess2 in the job running in session 2:
RUN { ALLOCATE CHANNEL c1 TYPE sbt; SET COMMAND ID TO 'ses s2'; BACKUP DATABASE; }
V$SESSION and V$PROCESS vi
ews while the RMAN job is executing. For example, enter:
SQL> SELE CT SID, SPID, CLIENT_INFO FROM V$PROCESS p, V$SESSION s WHERE p.ADDR = s.PADDR AND CLIENT_INFO LIKE '%id=sess%';
If you ru
n the SET COMMAND ID command in the RMAN job, then the CLIENT_INFO column display
s in the following format:
id=command_id,rman channel=channel_id
For example, the following shows sample o utput:
SID SPID CLIENT_INFO ---- ------------ ------------- ----------------- 11 8358 id=sess1 15 8638 id=sess2 14 8374 id=sess1,rman channel=c1 9 8642 id=sess2,rman channel=c1 a>
The rows that contain the string rman channel show the channel performi
ng the backup. The remaining rows are for the connections to the target database.
Oracle Database Recovery Manager Reference f
or SET COMMAND ID syntax, and Oracle Database Reference for more information on V$SESSION and V$PROCESS
Monitor the progre
ss of backups and restores by querying the view V$SESSION_LONGOPS. RMAN uses two types of rows in V$SESSION_LONGOP
S: detail and aggregate rows. Detail rows describe the files being processed by one job step, while aggregate rows describe th
e files processed by all job steps in an RMAN command. A job step is the creation or restore of one backup set or datafile copy. Deta
il rows are updated with every buffer that is read or written during the backup step, so their granularity of update is small. Aggreg
ate rows are updated when each job step completes, so their granularity of update is large.
Table 4-1 describes column in V$SESSION_LONGOPS that are most relevant for RMAN
. Typically, you will view the detail rows rather than the aggregate rows to determine the progress of each backup set.
Each server session performing a backup or restore reports its pro gress compared to the total amount of work required for a job step. For example, if you perform a database restore that uses two chan nels, and each channel has two backup sets to restore (a total of four sets), then each server session reports its progress through a single backup set. When that set is completely restored, RMAN begins reporting progress on the next set to restore.
To monitor job progress:
longops) con
taining the following SQL statement:
SELECT SID, SERIAL#, CONTEXT, SOFAR, TOTALWORK, ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE" FROM V$SESSION_LONGOPS WHE RE OPNAME LIKE 'RMAN%' AND OPNAME NOT LIKE '%aggregate%' AND TOTALWORK != 0 AND SOFAR <> TOTALWORK ;
RESTORE DATABASE;
SQL> @longops SID SERIAL# CONTEXT SOFAR TOTALWORK %_COMPLETE ---------- ---------- ---------- ---------- ---------- ---------- 8 19 1 10377 36617 28.34 SQL& gt; @longops SID SERIAL# CONTEXT SOFAR TOTALWORK % COMPLETE ---------- ---------- ---------- ---------- ---------- ---------- 8 19 1 21513 36617 58.75 SQL> @longops SID SERIAL# CONTEXT SOFAR TOTALWORK % COMPLETE ---------- ---------- ---------- ---------- ---------- ---------- 8 19 1 29641 36617 80.95 SQL> @longops SID SERIAL# CONTEXT SOFAR TOTALWORK % COMPLETE ---------- ---------- - --------- ---------- ---------- ---------- 8 19 1 35849 36617 97.9 SQL> @longops no rows selected
%<
/code>_COMPLETE column does not increase, then RMAN is encountering a problem. Refer to "
Monitoring RMAN Interaction with the Media Manager" to obtain more information.If you frequently monitor the execution of long-running tasks, you could create a shell script or b atch file under your host operating system that runs SQL*Plus to execute this query repeatedly.
You can use the event names in the dynamic performance event vi ews to monitor RMAN calls to the media management API. The event names have one-to-one correspondence with sbt functions, as shown in the following examples:
sbtinit sbtopen sbtrea d sbtwrite sbtbackup
Before making a call to any of functions in the media management API, the server adds a row in V$SESSION_WAIT, with the
STATUS column including the string WAIT. The V$SESSION_WAIT.SECONDS_IN_WAIT column shows the n
umber of seconds that the server has been waiting for this call to return. After an sbt function is returned from the me
dia manager, this row disappears.
A row in V$SESSION_WAIT corresponding to an
sbt event name does not indicate a problem, because the server updates these rows at runtime. The rows appear and disapp
ear as calls are made and returned. However, if the SECONDS_IN_WAIT column is high, then the media manager may be hung.<
/p>
To monitor the sbt events, you can run the following SQL query:
COLUMN EVENT FORMAT a10 COLUMN SECONDS_IN_WAIT FORMAT 999 COL UMN STATE FORMAT a20 COLUMN CLIENT_INFO FORMAT a30 SELECT p.SPID, EVENT, SECONDS_IN_WAIT AS SEC_WAIT, STATE, CLIENT_INFO FROM V$SESSION_WAIT sw, V$ SESSION s, V$PROCESS p WHERE sw.EVENT LIKE 'sbt%' AND s.SID=sw.SID AND s.PADDR=p.ADDR /
Examine
the SQL output to determine which sbt functions are waiting. For example, the following output indicates that RMAN has b
een waiting for the sbtbackup function to return for ten minutes:
SPID EVENT SEC_WAIT STATE CLIENT_INFO ---- ---------- ---------- -------------------- --------------- --------------- 8642 sbtbackup 600 WAITING rman channel=ORA_SBT_TAPE_1
| See Also:
Oracle Database Reference for descriptions of |
Monitor backup and restore performance by querying V$BACKUP_SYNC_IO and V$BACKUP_ASY
NC_IO.
| See Also:
Oracle
Database Reference for more information on these |
You can oft
en use the dynamic performance view V$RECOVER_FILE to determine which files need to be recovered and why they need to be
recovered. The following query shows the file numbers of datafiles that require recovery, as well as the reason for recovery (if kno
wn) and the SCN and time when recovery needs to begin:
COL FILE# FORMAT 999 COL ERROR FORMAT a10 SELECT * FROM V$RECOVER_FILE; FILE# ON LINE ONLINE_ ERROR CHANGE# TIME ----- ------- ------- ---------- ---------- -------------------- 4 ONLINE ONLINE FILE NOT 0 FOUND 5 ONLINE ONLINE FILE NOT 0 FOUND 8 OFFLINE OFF LINE OFFLINE 0 NORMAL< /a>
You canperform a useful join between V$RECOVER_FILE, V$DATAFILE and V$TABLESPACE to see which datafiles and tablespaces are in need of recovery, as shown in the following example:
COL df# FORMAT 999 COL df_name FORMAT a35 COL tbsp_name FORMAT a10 COL status FORMAT a7 COL error FORMAT a10 SELECT r.FILE# AS df#, d.NAME AS df_name, t.NAME AS tbsp_name, < /a> d.STATUS, r.ERROR, r.CHANGE#, r.TIME FROM V$RECOVER_FILE r, V$DATAFILE d, V$TABLESPACE t WHERE t.TS# = d.TS# AND d.FILE# = r.FILE# ;
Sample output follows:
DF# DF_NAME TBSP_NAME STATUS ERROR CHANGE# TIME ---- ------------------------- ---------- ------- ---------- ---------- ----- 4 /oracle/oradata/trgt/drsys01.dbf DRSYS ONLINE FILE NOT 0 < a name="1008464"> FOUND 5 /oracle/oradata/trg t/example01.dbf EXAMPLE ONLINE FILE NOT 0 FOUND 8 /oracle/oradata/trgt/users01.dbf USERS OFFLINE OFFLINE 0 a> NORMAL
Every RMAN backup produces a corresponding record in the RMAN repository. This record is s tored in the control file. If a recovery catalog is used, the record can also be found in the recovery catalog after the recovery cat alog is resynced from the control file.
For example, if you generate a full database backup
set, then you can view the record for this backup set in the V$BACKUP_SET control file view. If you use a recovery cata
log, then you can also access the record in the RC_BACKUP_SET catalog view.
Th
e V$ control file views and recovery catalog tables differ in the way that they store information, and this affects how
RMAN handles repository records. The recovery catalog RMAN repository is stored in actual database tables, while the control file ver
sion of the repository is stored in an internal structure in the control file.
When you use an RMAN command to delete a backup, RMAN performs the following steps:
DELETEDBecause o
f the way that control file data is stored, RMAN cannot remove the record from the control file, only update it to DELETED status. However, because the catalog tables are ordinary database tables, RMAN removes rows from them.
Table 4-2 describes the functio nality of the various RMAN deletion commands. All of these work whether you store the RMAN repository only in the control file or use a recovery catalog.
The DELETE command can remove any file that the LIST and CROSSCHECK
commands can operate on. For example, you can delete backup sets, archived redo logs, and datafile copies. The DELETE
code> command removes both the physical file and the catalog record for the file.
Always use DELETE command within RMAN to remove RMAN
backups, rather than an operating system or media manager utility or command. Otherwise, the RMAN repository can contain records of
backups that are no longer available for use in restore operations.
If you delete backups w ithout using RMAN, you can use one of the following methods within RMAN to update the RMAN repository directly without performing a c rosscheck:
CROSSCHECK to change the status of
these files to EXPIRED and then run DELETE EXPIRED to delete the records from the RMAN reposi
toryCHANGE ... UNCATALOG to remove
the catalog recordsThe DELETE OBSOLETE command provides a convenient way to delete backups that are no longer needed. It uses the same REDUND
ANCY, RECOVERY WINDOW, and ORPHAN options as the REPORT OBSOLETE command.
If you have configured a retention policy, then you can run DELETE OBSOLETE periodically to delete all backups considered obsolete by this policy. For example, you can run DELETE<
/code> OBSOLETE in a script every night with a scheduling utility, freeing disk and tape space used by backups that are
no longer needed.
Note that using a flash recovery area as the destination for all backups eliminates the need to manage obsolete backups. Obsolete backups will be deleted from the flash recovery area automatically as disk s pace is needed to store backup-related files.
The CROSSCHECK command updates the repository status for a backup to EXPIRED when it cannot
locate it at the location to which it was backed up. This condition could occur if, for example, a backup was deleted from disk at t
he operating system level. You can identify expired backups by running the CROSSCHECK command as in the following exampl
e:
RMAN> CROSSCHECK BACKUP; crosschecked ba ckup piece: found to be 'AVAILABLE' backup piece handle=0ad8d32i_1_1 recid=10 stamp=445025363 crosschecked backup piece: found to be 'AVAILABLE' backup piece handle=c-1334876723-20011105-00 recid=11 s tamp=445025367 crosschecked backup piece: found to be 'EXPIRED' backup piece handle=0cd8d 361_1_1 recid=12 stamp=445025473 crosschecked backup piece: found to be 'AVAILABLE' backu p piece handle=c-1334876723-20011105-01 recid=13 stamp=445025475 Crosschecked 4 objects
If you run CROSSCHECK while some backup device is temporarily not accessibl
e. This can happen if a disk is unmounted or if RMAN does not correctly connect to a media manager. In such a case, fix the problem t
hat prevented RMAN from finding the backups and rerun CROSSCHECK.
The DE
LETE EXPIRED command removes the recovery catalog records for expired backups, and updates their control file rec
ords to status DELETED.
This command is especially useful if a user inadverten
tly deletes RMAN backups or archived logs from disk with an operating system utility. In such a case, the RMAN repository is not sync
hronized with the actual contents of disk. By running the CROSSCHECK command, RMAN marks the backups that it cannot find
as expired. Then, you can run DELETE EXPIRED to remove the records for these files.
You may want to delete files such as arch
ived logs only if they have been backed up a specified number of times to tape. The DELETE command supports this behavio
r. The following example deletes all archived redo logs that have already been backed up at least two times to tape:
RMAN> DELETE ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE sbt;
The repository record for an object can sometimes fail to reflect the physical status of the object. For example, you backup
an archived redo log to disk and then use an operating system utility to delete the object. If you do not run the CROSSCHECK
code> command to update the repository, and if you then run DELETE against the object, then the repository shows that th
e object is AVAILABLE while the object is in fact missing. The following table indicates the behavior of DELETE in such situations.
If you use the FORCE option of DELETE, RMAN w
ill remove the repository record and delete the file if it exists. All I/O errors are ignored, and RMAN displays the number of object
s deleted at the end of the job.
The BACKUP ... DELETE INPUT command can delete archived redo logs
, datafile copies, and backup sets after backing them up. This functionality is especially useful when backing up archived logs on di
sk to tape. RMAN backs up one copy of each log sequence number, and then deletes the file that it backs up. For example, assume that
you issue:
RMAN> BACKUP ARCHIVELOG ALL DELETE INPUT;
In this command, RMAN backs up one copy of each log for each available sequence number, and then del etes only the archived redo log file that it actually backs up. If you have multiple redo log archiving destinations, the other copie s of the same log sequence number are not deleted.
If you specify the DELETE <
code>ALL INPUT option, then RMAN deletes whichever files match the criteria that you specify, even if there are s
everal files of the same log sequence number. For example, assume that you archive to three different directories. Then, you issue th
is command:
RMAN> BACKUP ARCHIVELOG ALL FROM SEQUENCE 1200 DELETE ALL INPUT;
In this case, RMAN backs up only one copy of each log sequence between 1200 and the most recent sequence, but deletes all logs with these sequence numbers contained in the three archive destinations.
During backup of archived redo logs, RMAN checks the file being backed up for corruption. If corrupt
ion is found, RMAN automatically switches to reading another copy of the same archived redo log, if one exists. For example, assume t
hat /log1 and /log2 are the only enabled archiving destinations, and that they contain logs with sequence n
umber up through 150. You run this command:
RMAN> BACKUP ARCHIVELOG FROM SEQUENCE 123 DE LETE ALL INPUT;
RMAN can start reading from any cpoy of a given l
og. For example, if RMAN starts reading the copy of log sequence 123 from /log1 and discovers corruption in the file, it
continues reading from the copy in /log2. Because DELETE ALL INPUT is specified,
RMAN deletes all copies of logs on disk of sequence 123 and higher.
See Also:
|
RMAN can update the repository to show backups as AVAIL
ABLE or UNAVAILABLE. An unavailable backup is one that cannot be accessed at a particular moment but that has not
been deleted. For example, you may have backups on tape that are temporariliy stored offsite and are inaccesible. You can use the ... UNAVAILABLE command to update the repository status for these backups to UNAVAI
LABLE so that RMAN will not try to use them for its backup and recovery operations.
When the tapes become available again, you can issue the CHANGE ... AVAILABLE command to updat
e the RMAN repository to show that these backups now can be used. After setting the files back to status AVAILABLE, you
can also run a CROSSCHECK to verify that RMAN can access the files.
CHANGE syntaxUse CHANGE... KEEP or CHANGE... NOKEEP to spec
ify whether a backup should be subject to the configured retention policy or kept until a different date or even indefinitely.
The KEEP option exempts a backup from the current retention policy either indefinite
ly or until the specified UNTIL time. RMAN does not mark the files as obsolete even if they would be considered obsolete
under the retention policy. Such backups are called long-term backups. CHANGE NOKEEP is used to undo the effects of CHANGE ... KEEP, so that the configured re
tention policy applies to the backup.
For example, the following command blocks RMAN from c
onsidering backupsets with the tag 'year_end_2002' as obsolete under the retention policy:
RMAN> CHANGE BACKUPSET TAG year_end_2002 KEEP;
To
allow backupsets with the tag year_end_2002 to be marked as obsolete based on the retention policy, use this command:
p>
RMAN> CHANGE BACKUPSET TAG year_end_2002 NOKEEP;
If you want to prevent the use of a backup marked with KEEP in restore and recovery operatio
ns, then mark these backups as UNAVAILABLE. RMAN will not delete the records for these backups from the RMAN repository,
but will not try to use them in restore and recovery until they are marked AVAILABLE again.
See Also:
|