Oracle® Database Backup and Recovery Basics 10g Release 1 (10.1) Part Number B10735-01 |
|
|
View PDF |
This chapter introduces the tools that RMAN makes available for recovering your database from backup. It includes the following topics:
The focus of this chapter is on how you use RMAN and backups created with RMAN to return your database to normal operation after the loss of one or more database files needed for its normal operation. The database files that RMAN backs up and can recover include the control file, server parameter file, datafiles and archived redo log files.
The chapter is organized as follows:
The two most important RMAN commands used in database recovery are:
Typically, you will set the state of the database appropriately for the data recovery operation to be performed, allocate or configure channels required to communicate with the disk and media manager, and then run a series of RESTORE and RECOVER commands. RMAN retrieves all needed files from backup and performs media recovery on all restored datafiles, to return your database to the desired state.
This chapter introduces the techniques which will cover the most common restore and recovery scenarios. Anyone performing restore and recovery, even in complex scenarios not covered here, should be familiar with the techniques outlined in this chapter. Note, however, the following limitations on the scope of this discussion:
See Also:
|
Enterprise Manager provides access to much of the database restore and recovery functionality provided by RMAN through a set of recovery wizards, that lead the DBA through a variety of recovery procedures based on an analysis of your database, your available backups and your data recovery objectives.
Using RMAN through Enterprise Manager, you can perform the simpler restore and recovery scenarios outlined in this chapter, as well as much more sophisticated restore and recovery techniques such as point-in-time recovery and even use of the flashback features of the Oracle database, which allow for efficent repair of both media failure and user errors.
While the underlying functionality is the same, and the command-line client provides more flexibility, in many common situations, use of the Enterprise Manager interface to RMAN's restore and recovery features will be simpler than using the RMAN command line client directly.
See Oracle Database 2 Day DBA for more details on the restore and recovery features of Enterprise Manager.
While RMAN makes carrying out most database restore and recovery tasks much simpler, you still have to plan your database restore and recovery actions based on which database files have been lost and what your recovery goal is.
RMAN can make most of the important decisions about the restore process for you, but you may want to preview and even override its decisions in some circumstances. For example, if you know a given backup is unavailable, due to a tape being stored offsite or a device being inaccessible, you can direct RMAN to not use that backup during the restore process.
RMAN provides tools to let you preview which backups will be used in a restore, and to validate the contents of the backups to ensure that they can be used in future restore operations.
The basic procedure for performing restore and recovery with RMAN is as follows:
RESTORE
command. You may restore files to their original locations, or you may have to restore them to other locations if, for instace, a disk has failed. You may also have to update the SPFILE if you have changed the control file locations, or the control file if you have changed the locations of datafiles or redo logs.RECOVER
command.This outline is intended to encompass a wide range of different scenarios. Depending upon your situation, some of the steps described may not apply. For example, you do not need to perform media recovery if the only file restored from backup is the SPFILE. You will have to devise your final recovery plan based on your particular situation.
It is generally obvious when the control file of your database must be restored, because the database shuts down immediately if any of the control file copies becomes inaccessible and the database cannot be started without a valid control file.
Loss of some but not all copies of your control file does not require recovery of the control file from backup. When one copy of the control file is lost, the database will automatically shut down. You can either copy an intact copy of the control file over the damaged or missing control file, or update the parameter file so that CONTROL_FILES
does not refer to the damaged or missing control file. Once the CONTROL_FILES
parameter references only present, intact copies of the control file, you can restart your database.
Note that if you restore the control file from backup, you must perform media recovery of the whole database and then perform an OPEN RESETLOGS
, even if no datafiles have to be restored.
The need to restore the SPFILE is also easy to determine-- if the instance cannot read the SPFILE during startup, then you should restore it from backup.
When and how to recover depends on the state of the database and the location of its datafiles. To determine which if any files require media recovery, use the following procedure:
trgt
:
% sqlplus 'SYS/oracle@trgt AS SYSDBA'
SELECT STATUS FROM V$INSTANCE;
If the status is OPEN
, then the database is open. However, some datafiles may require media recovery.
V$DATAFILE_HEADER
view to determine the status of your datafiles. Run the following SQL statements to check the datafile headers:
COL FILE# FORMAT 999 COL STATUS FORMAT A7 COL ERROR FORMAT A10 COL TABLESPACE_NAME FORMAT A10 COL NAME FORMAT A30 SELECT FILE#, STATUS, ERROR, RECOVER, TABLESPACE_NAME, NAME FROM V$DATAFILE_HEADER WHERE RECOVER = 'YES' OR (RECOVER IS NULL AND ERROR IS NOT NULL);
If the ERROR
column is not NULL
or the RECOVER
column is not NO
, then check for a temporary hardware or operating system problem causing the error. If there is no such problem, you must restore the file or switch to a copy.
A NULL
value in the RECOVER
column indicates that some hardware error prevented RMAN from reading the file's header or verifying its checksum.
If the ERROR
column is NULL
and the RECOVER
column is YES
, then the file can be recovered.
When you run the RMAN RECOVER
command, incremental backups and archived redo logs are restored from backup as needed, and applied to the datafile to recover it to the current SCN.
You can query V$RECOVER_FILE
to list datafiles requiring recovery by datafile number with their status and error information.
SELECT FILE#, ERROR, ONLINE, ONLINE_STATUS, CHANGE#, TIME FROM V$RECOVER_FILE;
You can also perform useful joins using the datafile number and the V$DATAFILE
and V$TABLESPACE
views, to get the datafile and tablespace names. Use the following SQL*Plus commands to format the output of the query:
COL DF# FORMAT 999 COL DF_NAME FORMAT A35 COL TBSP_NAME FORMAT A7 COL STATUS FORMAT A7 COL ERROR FORMAT A10 COL CHANGE# FORMAT 99999999 SELECT r.FILE# AS df#, d.NAME AS df_name, t.NAME AS tbsp_name, 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# ;
The ERROR
column identifies the problem for each file requiring recovery.
See Also:
Oracle Database Reference for information about the V$ views |
In situations requiring the recovery of your SPFILE or control file from autobackup, such as disaster recovery when you have lost all database files, you will need to determine your DBID. Your DBID should be recorded along with other basic information about your database, as recommended in "Keeping Records of the Hardware and Software Configuration of the Server".
If you do not have a record of the DBID of your database, there are two places you can easily find it.
% rman TARGET / Recovery Manager: Release 10.1.0.2.0 - Production Copyright (c) 1995, 2003, Oracle. All rights reserved. connected to target database: RDBMS (DBID=774627068) RMAN>
The RESTORE
command supports a PREVIEW
option, which identifies the backups (backup sets or image copies, on disk or sequential media like tapes) required to carry out a given restore operation, based on the information in the RMAN repository. Use RESTORE
... PREVIEW
when planning your restore and recovery operation, to ensure that all required backups are available or to identify situations in which you may want to direct RMAN to use or avoid specific backups.
For example, RESTORE
... PREVIEW
can show you that RMAN will request a tape during the restore process which you know is stored offsite. You can then use the CHANGE
... UNAVAILABLE
command (described in "Marking a Backup AVAILABLE or UNAVAILABLE") to set the backup status to UNAVAILABLE. If you then run RESTORE
... PREVIEW
again, RMAN will show you the backups it would use to perform a restore operation without using the unavailable backup.
RESTORE
... PREVIEW
can be applied to any RESTORE
operation to create a detailed report of every backup to be used in the requested RESTORE
operation. Here are a few examples of RESTORE
commands using the PREVIEW
option:
RESTORE DATABASE PREVIEW; RESTORE TABLESPACE users PREVIEW; RESTORE DATAFILE 3 PREVIEW; RESTORE ARCHIVELOG FROM LOGSEQ 200 PREVIEW; RESTORE ARCHIVELOG FROM TIME 'SYSDATE-7' PREVIEW; RESTORE ARCHIVELOG FROM SCN 234546 PREVIEW;
RESTORE
... PREVIEW
output is in the same format as the output of the LIST
command. See Oracle Database Recovery Manager Reference for details on interpreting the output of RESTORE
... PREVIEW
.
If the detailed report produced by RESTORE
... PREVIEW
provides more information than is needed, use the RESTORE
... PREVIEW
SUMMARY
option to suppress much of the detail about specific files used and affected by the restore process. Here are some examples of RESTORE
used with the PREVIEW
SUMMARY
option:
RESTORE DATABASE PREVIEW SUMMARY; RESTORE TABLESPACE users PREVIEW SUMMARY; RESTORE DATAFILE 3 PREVIEW SUMMARY; RESTORE ARCHIVELOG FROM LOGSEQ 200 PREVIEW SUMMARY; RESTORE ARCHIVELOG FROM TIME 'SYSDATE-7' PREVIEW SUMMARY; RESTORE ARCHIVELOG FROM SCN 234546 PREVIEW SUMMARY;
RESTORE
... PREVIEW
SUMMARY
reports are in the same format as the output from the LIST SUMMARY
command. See Oracle Database Recovery Manager Reference for details on interpreting the output of RESTORE
... PREVIEW SUMMARY
.
The RESTORE
...
VALIDATE
and VALIDATE BACKUPSET
commands test whether you can restore from your backups. You can test the restore of either the entire database or individual tablespaces, datafiles, or control files. The contents of the backups are actually read to ensure that the objects to be restored can be restored from them. You have these options:
RESTORE
...
VALIDATE
tests whether RMAN can restore a specific object from a backup. RMAN chooses which backups to use.VALIDATE BACKUPSET
tests the validity of a backup set that you specify.See Also:
|
Validating with RESTORE ... VALIDATE
To validate backups with RESTORE... VALIDATE
, the database can be mounted or open. You do not have to take datafiles offline when validating them.
This example illustrates validating the restore of the backup control file, SYSTEM
tablespace, and all archived logs:
RESTORE CONTROLFILE VALIDATE; RESTORE TABLESPACE SYSTEM VALIDATE; RESTORE ARCHIVELOG ALL VALIDATE;
If you see error messages in the output and the following message, then RMAN cannot restore one of one of the specified files from your available backups:
RMAN-06026: some targets not found - aborting restore
If you see an error message stack and output similar to the following, for example, then RMAN encountered a problem restoring the specified file:
RMAN-03009: failure of restore command on c1 channel at 12-DEC-01 23:22:30 ORA-19505: failed to identify file "oracle/dbs/1fafv9gl_1_1" ORA-27037: unable to obtain file status SVR4 Error: 2: No such file or directory Additional information: 3
If you do not see an error stack, then RMAN successfully tested restore of the specified objects from the available backups.
The BACKUP
VALIDATE
command requires that you know the primary keys of the backup sets that you want to validate.
To specify which backup sets to validate:
LIST
commands, noting primary keys:
LIST BACKUP;
VALIDATE BACKUPSET 1121,1122;
validation
complete
message then RMAN successfully validated the restore of the specified backup set. For example:
using channel ORA_DISK_1 channel ORA_DISK_1: starting validation of archive log backupset channel ORA_DISK_1: restored backup piece 1 piece handle=/oracle/dbs/0mdg9v8l_1_1 tag=TAG20020208T155604 params=NULL channel ORA_DISK_1: validation complete
You can plan a strategy for recovering from most data losses using the process outlined in "Preparing and Planning Database Restore and Recovery" and the task-specific procedures in "Restoring Different Types of Lost Database Files with RMAN". However, some of the most common scenarios for database restore and recovery are presented in full here:
The procedures outlined here will restore the whole database or individual tablespaces to their original locations.
To use the procedures in this section, the following requirements must be met:
If automatic channels are configured, then RMAN allocates all channels configured for the available device types according to their parallelism settings. Otherwise, you must enclose your RESTORE and RECOVER command in a RUN block, and begin by manually allocating the appropriate DISK
or sbt
channels. Otherwise, your RESTORE command will fail on attempting to retrieve backups from that device.
In this scenario, you have a current control file and SPFILE but all datafiles are damaged or lost. You must restore and recover the whole database.
The database in this example has one read-only tablespace, history
, which must be restored from backup but which does not need media recovery.
To restore and recover the database when the current control file is available:
RMAN> STARTUP MOUNT
SHOW
ALL
command to see what channels are configured for access to backup devices. If automatic channels are not configured, then manually allocate one or more channels.RESTORE
command, and recover it using the RECOVER
command.This example performs restore and recovery of the database, using automatic channels.
RMAN> RESTORE DATABASE; RMAN> RECOVER DATABASE DELETE ARCHIVELOG MAXSIZE 25MB;
The RECOVER DATABASE
command as used here illustrates two useful options:
DELETE ARCHIVELOG
causes RMAN to delete restored log files after they have been applied to the datafiles, to save disk space.MAXSIZE 25MB
limits space occupied by restored logs at any given moment to 25MB. This gives you more control over disk space usage by the restored logs. Note that if a single achived redo log file is larger than the specified MAXSIZE
value, you will get an error. You will have to try your command again with a larger MAXSIZE
value.Read-only tablespaces may require special handling in a restore and recover operation. By default, the restore operation will skip read-only tablespaces. If a read-only tablespace is at the SCN where it became read-only after it is restored from backup, no redo will be applied to it when the rest of the database is recovered. You can force RMAN to restore any missing datafiles belonging to read-only tablespaces by using the CHECK READONLY
option to the RESTORE
command:
RMAN> RESTORE DATABASE CHECK READONLY; RMAN> RECOVER DATABASE DELETE ARCHIVELOG;
If RMAN completes the recovery without error, you can open the database:
RMAN> ALTER DATABASE OPEN;
In this scenario, some but not all of the datafiles are damaged. You want to leave the database open so that the undamaged datafiles remain available.
Using the procedure described in "Determining Which Database Files to Restore or Recover" to identify datafiles needing recovery, you discover that the damaged datafiles are from the tablespaces users
.
The following restore and recovery procedure can be used if the database is mounted or open.
To recover a tablespace to its current location:
ALTER
TABLESPACE
...
OFFLINE
IMMEDIATE
if they are not already offline.SHOW
ALL
to see the current configuration, including configured default channels for the device where the backup is stored. If necessary, allocate one or more channels manually. (Note that if you manually allocate channels you must use a RUN block around your command.)RESTORE
command, and recover it with the RECOVER
command.This example restores and recovers the users
tablespace, letting RMAN choose the backup to use on disk or tape:
RMAN> SQL 'ALTER TABLESPACE users OFFLINE IMMEDIATE'; RMAN> RESTORE TABLESPACE users; RMAN> RECOVER TABLESPACE users;
If RMAN reported no errors during the recovery, then bring the tablespace back online:
RMAN> SQL 'ALTER TABLESPACE users ONLINE';
This section discusses how to restore the different types of database file backed up by RMAN. Once you have an overall plan for restoring the lost parts of your database, look here for details on how to execute the individual tasks in your plan.
Loss or corruption of all copies of your control file requires restore of the control file from backup. The RESTORE CONTROLFILE
command is used to restore the control file.
Note: After restoring the control files of your database from backup, you must perform complete media recovery as described in "Performing Media Recovery of a Database, Tablespace or Datafile", and then open your database with the RESETLOGS option. The only exception is the case described in "Restore of the Control File to a New Location", where you restore your control file to a location not listed in the |
Except as noted, the procedures in this section assume that you are not using a recovery catalog. Restore and recovery procedures for the control file when using a recovery catalog are covered in Oracle Database Backup and Recovery Advanced User's Guide.
RMAN can restore it to its default location (determined by rules described in the following section) or to one or more different locations of your choice, using the RESTORE CONTROLFILE... TO
destination
option.
When restoring the control file, the default destination is all of the locations defined in the CONTROL_FILES
initialization parameter. If you do not set the CONTROL_FILES
initialization parameter, the database uses the same rules to determine the destination for the restored control file as it uses when creating a control file if the CONTROL_FILES
parameter is not set. These rules are described in Oracle Database SQL Reference in the description of the CREATE CONTROLFILE
statement.
If you are not using a recovery catalog, you must restore your control file from an autobackup. If you want to restore the control file from autobackup, the database must be in a NOMOUNT state. You must first set the DBID for your database, and then use the RESTORE CONTROLFILE FROM AUTOBACKUP
command:
RMAN> SET DBID 320066378; RMAN> RUN { SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'autobackup_format'; RESTORE CONTROLFILE FROM AUTOBACKUP; }
RMAN uses the autobackup format and DBID to determine where to hunt for the control file autobackup. If one is found, RMAN restores the control file from that backup to all of the control file locations listed in the CONTROL_FILES
initialization parameter.
For information on how to determine the correct value for autobackup_format
, see the description of CONFIGURE CONTROLFILE AUTOBACKUP FORMAT
in the entry for CONFIGURE
In Oracle Database Recovery Manager Reference
See "Determining your DBID" for details on how to determine your DBID.
The commands used for restoring your control file are the same, whether or not you are using a flash recovery area. However, if you are using a flash recovery area, RMAN implicitly crosschecks backups and image copies listed in the control file, and catalogs any files in the flash recovery area not recorded in the restored control file. This improves the usefulness of the restored control file in the restoration of the rest of your database.
Note that tape backups are not automatically crosschecked after the restore of a control file. If you are using tape backups, then after restoring the control file and mounting the database you must crosscheck the backups on tape, as shown here:
RMAN> CROSSCHECK BACKUP DEVICE TYPE SBT;
If you have a recovery catalog, you do not have to set the DBID or use the control file autobackup to restore the control file. You can use the RESTORE CONTROLFILE
command with no arguments, as shown here:
RMAN> RESTORE CONTROLFILE;
The instance must be in NOMOUNT state when you perform this operation, and RMAN must be connected to the recovery catalog. The restored control file will be written to all locations listed in the CONTROL_FILES
initialization parameter.
You can restore the control file from a known control file copy using this form of the command:
RMAN> RESTORE CONTROLFILE from 'filename';
The control file copy found at the location specified by filename
will be written to all locations listed in the CONTROL_FILES
initialization parameter.
One way to restore the control file to one or more new locations is to change the CONTROL_FILES
initialization parameter, and then use the RESTORE CONTROLFILE
command with no arguments to restore the control file to the default locations. For example, if you are restoring your control file after a disk failure made some but not all CONTROL_FILES
locations unusable, you can change CONTROL_FILES
to replace references to the failed disk with pathnames pointing to another disk, and then run RESTORE CONTROLFILE
with no arguments.
You can also restore the control file to any location you choose other than the CONTROL_FILES
locations, by using the form RESTORE CONTROLFILE TO '
filename' [FROM AUTOBACKUP]
:
RESTORE CONTROLFILE TO '/tmp/my_controlfile';
You can perform this operation with the database in NOMOUNT, MOUNT or OPEN states, because you are not overwriting any of the control files currently in use. Any existing file named '
filename
'
is overwritten. After restoring the control file to a new location, you can then update the CONTROL_FILES
initialization parameter to include the new location.
See Also:
Oracle Database Recovery Manager Reference for |
Note the following requirements after restoring the control file from backup:
RECOVER DATABASE
and perform an OPEN RESETLOGS
on the database.OPEN RESETLOGS
. If you do not, then Oracle can display the error "ORA-25153: Temporary Tablespace is Empty
" when attempting to sort.For more details on restrictions on using RESTORE CONTROLFILE
in different scenarios (such as when using a recovery catalog, or restoring from a specific backup), see the discussion of RESTORE CONTROLFILE
in Oracle Database Recovery Manager Reference.
If you lose your server parameter file (SPFILE), RMAN can restore it to its default location or to a location of your choice.
Unlike the loss of the control file, the loss of your SPFILE does not cause your instance to immediately stop. Your instance may continue operating, although you will have to shut it down and restart it after restoring the SPFILE.
Note the following when restoring the SPFILE:
TO
clause is not used. The default location is platform-specific (for example, ora_home/dbs/spfile.ora
on Solaris).RMAN can also create a client-side initialization parameter file based on a backup of an SPFILE.
To restore the server parameter file:
% rman TARGET /
If the database is not up when the SPFILE is lost, and you are not using a recovery catalog, then you must set the DBID of the target database. See "Determining your DBID" for details on determining your DBID.
RMAN> STARTUP FORCE NOMOUNT;
RMAN> RESTORE SPFILE FROM AUTOBACKUP;
If restoring to a nondefault location, then you could run commands as in the following example:
RMAN> RESTORE SPFILE TO '/tmp/spfileTEMP.ora' FROM AUTOBACKUP;
SPFILE=
new_location, where new_location
is the path name of the restored server parameter file. Then, restart the instance with the client-side initialization parameter file.
For example, create a file /tmp/init.ora which contains the single line:
SPFILE=/tmp/spfileTEMP.ora
Then use this RMAN command, to restart the instance based on the restored SPFILE:
RMAN> STARTUP FORCE PFILE=/tmp/init.ora; # startup with /tmp/spfileTEMP.ora
If you have configured control file autobackups, the SPFILE is backed up with the control file whenever an autobackup is taken.
If you want to restore the SPFILE from the autobackup, you must first set the DBID for your database, and then use the RESTORE SPFILE FROM AUTOBACKUP
command. The procedure is similar to restoring the control file from autobackup. You must first set the DBID for your database, and then use the RESTORE CONTROLFILE FROM AUTOBACKUP
command:
RMAN> SET DBID 320066378; RMAN> RUN { SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'autobackup_format'; RESTORE SPFILE FROM AUTOBACKUP; }
RMAN uses the autobackup format and DBID to hunt for control file autobackups, and if a control file autobackup is found, restores the SPFILE from that backup to its default location.
For information on how to determine the correct value for autobackup_format
, see the description of CONFIGURE CONTROLFILE AUTOBACKUP FORMAT
in the entry for CONFIGURE
In Oracle Database Recovery Manager Reference
See "Determining your DBID" for details on how to determine your DBID.
You can also restore the server parameter file as a client-side initialization parameter file with the TO
PFILE
'filename'
clause. The filename you specify should be on a filesystem accessible from the host where the RMAN client is running. This file need not be accessible directly from the host running the instance. This command creates a PFILE called /tmp/initTEMP.ora
on the system running the RMAN client:
RMAN> RESTORE SPFILE TO PFILE '/tmp/initTEMP.ora';
To restart the instance using the client-side PFILE, use the following command, again running RMAN on the same client machine:
RMAN> STARTUP FORCE PFILE='/tmp/initTEMP.ora';
Restoring a tablespace to its original location is described in "Restore and Recovery of Individual Tablespaces or Datafiles: Scenario". However, you may need to restore a datafile to a location other than its original location if, for example, the disk containing the original location of the datafiles has failed.
The important step in restoring datafiles from backup to a new location is to update the control file to reflect the new locations of the datafiles. The following example shows the use of the RMAN SET NEWNAME
command to specify the new names, and the SWITCH
command to update the control file to start referring to the datafiles by their new names.
As with restoring datafiles from backup to their original locations, you should take the affected tablespaces offline at the start of restoring datafiles from backup to a new location.
Then, create a RUN
block to encompass your RESTORE
and RECOVER
commands. For each file to be moved to a new location, use the SET
NEWNAME
command to specify the new location for that file.
Then, still within the RUN block, run the RESTORE
TABLESPACE
or RESTORE
DATAFILE
as normal. RMAN restores each datafile to the location specified with SET NEWNAME
, rather than its original location.
After the RESTORE
command but before the RECOVER
command in your RUN
block, use a SWITCH
command to update the control file with the new filenames of the datafiles. The SWITCH
command is equivalent to the SQL statement ALTER
DATABASE
RENAME
FILE
. SWITCH
DATAFILE
ALL
updates the control file to reflect the new names for all datafiles for which a SET
NEWNAME
has been issued in the RUN block.
This example restores the datafiles in tablespaces users
and tools
to a new location, then performs recovery. Assume that the old datafiles were stored in directory /olddisk
and the new ones will be stored in /newdisk
.
RUN { SQL 'ALTER TABLESPACE users OFFLINE IMMEDIATE'; SQL 'ALTER TABLESPACE tools OFFLINE IMMEDIATE'; # specify the new location for each datafile SET NEWNAME FOR DATAFILE '/olddisk/users01.dbf' TO '/newdisk/users01.dbf'; SET NEWNAME FOR DATAFILE '/olddisk/tools01.dbf' TO '/newdisk/tools01.dbf'; # to restore to an ASM disk group named dgroup, use: # SET NEWNAME FOR DATAFILE '/olddisk/trgt/tools01.dbf' # TO '+dgroup'; RESTORE TABLESPACE users, tools; SWITCH DATAFILE ALL; # update control file with new filenames RECOVER TABLESPACE users, tools; }
If recovery is successful, then bring the tablespaces online:
SQL 'ALTER TABLESPACE users ONLINE'; SQL 'ALTER TABLESPACE tools ONLINE';
See Also:
Oracle Database Recovery Manager Reference for |
Media recovery reapplies all changes from the archived and online redo logs and available incremental backups to datafiles restored from backup.
The simplest way to perform media reccovery is to use the RECOVER DATABASE
command, with no arguments:
RMAN> RECOVER DATABASE;
You can also perform media recovery of individual tablespaces or datafiles, or skip certain tablespaces while recovering the rest of the database, as shown in the following examples:
RMAN> RECOVER DATABASE SKIP TABLESPACE users; RMAN> RECOVER TABLESPACE users, tools; RMAN> RECOVER DATAFILE '/newdisk/users01.dbf','/newdisk/tools01.dbf'; RMAN> RECOVER DATAFILE 4;
RMAN will restore from backup any archived redo logs required during the recovery operation. If backups are stored on a media manager, channels must be configured or allocated for use in accessing backups stored there.
One very useful option in managing disk space associated with these restored files is the DELETE ARCHIVELOG
option, which causes the deletion of restored archived redo logs from disk once they are no longer needed for the RECOVER
operation:
RMAN> RECOVER TABLESPACE users, tools DELETE ARCHIVELOG;
Note that when RMAN restores archived redo log files to the flash recovery area in order to perform a RECOVER
operation, the restored logs are automatically deleted after they are applied to the datafiles, even if you do not use the DELETE ARCHIVELOG
option.
See Oracle Database Recovery Manager Reference for more details on options for the RECOVER
command.
The procedure shown here is a convenient way to restore a datafile to a new location and perform media recovery on it.
RUN { SET NEWNAME FOR DATAFILE 3 to 'new_location'; RESTORE DATAFILE 3; SWITCH DATAFILE 3; RECOVER DATAFILE 3; }
If you want to store a datafile to a new Oracle Managed Files location, you can use this variation:
RUN { SET NEWNAME FOR DATAFILE 3 to NEW; RESTORE DATAFILE 3; SWITCH DATAFILE 3; RECOVER DATAFILE 3; }
Oracle will store the restored file in an OMF location, generating a filename for it.
Point-in-time recovery lets you apply only those changes to your database or tablespace which occured before a particular moment in time. Use point-in-time recovery to undo unwanted changes to your database, or to recover as many changes as possible when you do not have a complete set of archived redo log files. See Oracle Database Backup and Recovery Advanced User's Guide for details on database point-in-time recovery, and Oracle Database Backup and Recovery Advanced User's Guide for details on tablespace point-in-time recovery.
RMAN will restore archived redo log files from backup automatically as needed to perform recovery.
However, you can restore archived redo logs manually if you wish, in order to save the time needed to restoroe these files later during the RECOVER command, or if you want to store the restored archived redo log files in some new location.
By default, RMAN restores archived redo logs with names constructed using the LOG_ARCHIVE_FORMAT
and the LOG_ARCHIVE_DEST_1
parameters of the target database. These parameters are combined in a platform-specific fashion to form the name of the restored archived log.
You can override the default location for restored archived redo logs with the SET
ARCHIVELOG
DESTINATION
command. This command manually stages archived logs to different locations while a database restore is occurring. During recovery, RMAN knows where to find the newly restored archived logs; it does not require them to be in the location specified in the initialization parameter file.
To restore archived redo logs to a new location:
RUN
block, as shown in the following example script:
SET
ARCHIVELOG
DESTINATION
.This example restores all backup archived logs to a new location:
RUN { SET ARCHIVELOG DESTINATION TO '/oracle/temp_restore'; RESTORE ARCHIVELOG ALL; # restore and recover datafiles as needed . . . }
You can specify restore destinations for archived logs multiple times in one RUN block, in order to distribute restored logs among several destinations. (You cannot, however specify multiple destinations simultaneously to produce multiple copies of the same log during the restore operation.) You can use this feature to manage disk space used to contain the restored logs.
This example restores 300 archived redo logs from backup, distributing them across the directories /fs1/tmp
, /fs2/tmp
, and /fs3/tmp
:
RUN { # Set a new location for logs 1 through 100. SET ARCHIVELOG DESTINATION TO '/fs1/tmp'; RESTORE ARCHIVELOG FROM SEQUENCE 1 UNTIL SEQUENCE 100; # Set a new location for logs 101 through 200. SET ARCHIVELOG DESTINATION TO '/fs2/temp'; RESTORE ARCHIVELOG FROM SEQUENCE 101 UNTIL SEQUENCE 200; # Set a new location for logs 201 through 300. SET ARCHIVELOG DESTINATION TO '/fs3/tmp'; RESTORE ARCHIVELOG FROM SEQUENCE 201 UNTIL SEQUENCE 300; # restore and recover datafiles as needed . . . }
When you issue a RECOVER
command, RMAN finds the needed restored archived logs automatically across the multiple destinations to which they were restored, and applies them to the datafiles.