| Oracle® Database Backup and Recovery
Advanced User's Guide 10g Release 1 (10.1) Part Number B10734-01 |
|
|
View PDF |
This c hapter describes how to restore and recover a database. It includes the following topics:
Oracle's flashback features, which let you undo damage to your database after logical data corruption, include the following:
DROP TABLE operation;All of these operations are available within SQL*Plus, and none of them require the use of Recovery Manager. More details about usi ng the flashback features of Oracle in data recovery situations are provided in "Oracle Flashbac k Technology: Overview".
The SQL*Plus FLASHBACK DATABASE command performs the same function as the RMAN FLAS
HBACK DATABASE command: it returns the database to a prior state.
Note that using Fl ashback Database requires that you create a flash recovery area for your database and enable the collection of flashback logs. See "Oracle Flashback Database: Alternative to Point-In-Time Recovery" for more details about how the Flashback Database feature works, requirements for using Flashback Database , and how to enable coll ection of flashback logs required for Flashback Database. The requirements and preparations are the same whether you use RMAN or user -managed backup and recovery.
To perform the FLASHBACK DATABASE operation:
S QL> SELECT CURRENT_SCN FROM V$DATABASE; SQL> SELECT OLDEST_FLASHBACK_SCN, OLDEST_F LASHBACK_TIME FROM V$FLASHBACK_DATABASE_LOG;
FLASHBACK DATABASE statement to return the database to a prior TIMESTAMP or SCN. For example:
FLASHBACK DATABASE TO SCN 46963; FLASHBACK DATABASE TO TIMESTAMP (SYSDA TE-1/24); FLASHBACK DATABASE TO TIMESTAMP timestamp'2002-11-05 14:00:00'; FLASHBACK DATAB ASE TO TIMESTAMP to_timestamp('2002-11-11 16:00:00', 'YYYY-MM-DD HH24:MI:SS');
Open the database read-only to examine the results of the Flashback Database operation. When
the operation completes, you can open the database read-only and perform some queries to make sure you have recovered the data you ne
ed. If you find that you need to perform Flashback Database again to a different target time, then use RECOVER DATABASE
to return the database back to the present time, and then try another FLASHBACK DATABASE statement.
If you are satisfied with the results of Flashback Database, then you can re-open your database with the RESET
LOGS option. If appropriate, you can also use an Oracle export utililty like Data Pump Export to save lost data, use RECOVER DA
TABASE to return the database to the present, and re-import the lost object.
To restore a file is to replace it with a backup file. Typically, you restore a file when a media failure or user error has damaged or deleted the original file. The following files are ca ndidates for restore operations:
In each case, the loss of a primary file and the restore of a backup has the following implications for media recovery.
|
Note: Restore and recovery of Oracle-managed files is no different from restore and rec overy of user-named files. |
You can use the dynamic performance view V$RECOVER_FILE to determine whic
h files to restore in preparation for media recovery. This view lists all files that need to be recovered and explains why they need
to be recovered.
The following query displays the file ID numbers of datafiles that require media recovery as well as the reason for recovery (if known) and the SCN and time when recovery needs to begin:
SELECT * FROM V$RECOVER_FILE; FILE# ONLINE ERROR CHANGE# TIME ---------- ------- ------------------ ---------- --------- 14 ONLINE 0 15 ONLINE FILE NOT FOUND 0 21 OFFLINE OFFLINE NORMAL 0
Query V$DATAFILE and V$TABLESPACE to obtain fi
lenames and tablespace names for datafiles requiring recovery. For example, enter:
SELECT d .NAME, t.NAME AS tablespace_name FROM V$DATAFILE d, V$TABLESPACE t WHERE t.TS# = d.TS# AND d.FILE# IN (14,15,21); # use values obtained from V$RECOVER_FILE query
You can combine these queries in the following SQL*Plus script (sample output show in the following example):
COL df# FORMAT 999 COL df_name FORMAT a20 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, d.STATUS, r.ERROR, r.CHANGE#, r.TI ME FROM V$RECOVER_FILE r, V$DATAFILE d, V$TABLESPACE t WHERE t.TS# = d.TS# AND d.FILE# = r.FILE# /
This section contains the following topics:
If a media failure pe rmanently damages one or more datafiles of a database, then you must restore backups of these datafiles before you can recover the da maged files. If you cannot restore a damaged datafile to its original location (for example, you must replace a disk, so you restore the files to an alternate disk), then you must indicate the new locations of these files to the control file.
< /a>If you are restoring a database file on a raw disk or partition, then the procedure is basically the same as when restoring to a file on a file system. However, be aware of the naming conventions for files on raw devices (which differ depending on the operating system), and use an operating system utility that supports raw devices.
| See Also:
"Making User-Managed Backups to Raw Devices" for an overview of considerations wh en backing up and restoring files on raw devices |
To restore backup datafiles to their default location:
ALTER TABLESPACE users OFFLINE IMMEDIATE;
users01.dbf you might issue:
% cp /disk2/backup/users01.db f $ORACLE_HOME/oradata/trgt/users01.dbf
RECOVER TABLESPACE users
ALTER TABLESPACE users ONLINE;
All archived redo logs generated between the time a restored backup was created and the target recovery time are required for the pending recovery. The archived logs will eventually need to be o n disk so that they are available to the database.
To restore necessar y archived redo logs:
V$ARCHIVED_LOG and V$RECOVERY_LOG. If a datafile requires rec
overy, but no backup of the datafile exists, then you need all redo generated starting from the time when the datafile was added to t
he database.
LOG_ARCHIVE_DEST_1. The database locates the correct log automatically when required during media recovery. For
example, enter:
% cp /disk2/arch/* $ORACLE_HOME/oradata/trgt/arch
LOGSOURCE parameter of the SET statement
in SQL*Plus or the RECOVER ... FROM parameter of the ALTER DATABASE
statement in SQL. For example, enter:
SET LOGSOURCE /tmp # set location using SET statemen t DATABASE RECOVER FROM '/tmp'; # set location in RECOVER statement
% rm /tmp/*.dbf
| See Also:
Oracle Database Reference for more information about the dat a dictionary views, and "About User-Managed Media Recovery" for a n overview of log application during media recovery |
This section contains the following topics:
Use the following proced ures to recover a database if a permanent media failure has damaged one or more control files of a database and at least one control file has not been damaged by the media failure.
If the disk and file system containing the lost con
trol file are intact, then you can simply copy one of the intact control files to the location of the missing control file. In this c
ase, you do not have to alter the CONTROL_FILES initialization parameter setting.
To replace a damaged control file by copying a multiplexed control file:
< a name="1006414">SHUTDOWN ABORT
bad_cf.f with good_cf.f, you might enter:
% cp /oracle/good_cf.f /oracle/dbs/bad_cf.f
STARTUPli>
Assuming that the disk and file system containing the lost control file are not intact, then you cannot copy one of
the good control files to the location of the missing control file. In this case, you must alter the CONTROL_FILES initi
alization parameter to indicate a new location for the missing control file.
To restore a control file to a nondefault location:
SHUTDOWN ABORT
% cp $ORACLE_HOME/oradata/trg t/control01.dbf /new_disk/control01.dbf
CONTROL_FILES parameter reflects the current locations of all contro
l files and excludes all control files that were not restored. Assume the initialization parameter file contains:
< a name="1006442">CONTROL_FILES='/oracle/oradata/trgt/control01.dbf','/bad_disk/control02.dbf'
Then, you can edit it as follows:
CONTROL_FILES='/oracle /oradata/trgt/control01.dbf','/new_disk/control02.dbf'
STARTUP
Use the following procedures to restore a backup control file if a permanent media failure has damaged all control files of a database and y ou have a backup of the control file. When a control file is inaccessible, you can start the instance, but not mount the database. If you attempt to mount the database when the control file is unavailable, then you receive this error message:
ORA-00205: error in identifying controlfile, check alert log for more info
You cannot mount and open the database until the control file is accessible again. If you restore a bac
kup control file, then you must open RESETLOGS.
As indicated in Table 17-1, the procedure for restoring the control file depends on whether the online redo logs are availab le.
If possible, restore the control file to its original loc ation. In this way, you avoid having to specify new control file locations in the initialization parameter file.
To restore a backup control file to its default location:
SHUTDOWN AB ORT
CONTROL_FILES parameter. For example, if ORACLE_HOME/oradata/trgt/control
01.dbf and ORACLE_HOME/oradata/trgt/control02.dbf are the control file locations listed in
the server parameter file, then use an operating system utility to restore the backup control file to these locations:
% cp /backup/control01.dbf ORACLE_HOME/oradata/trgt/control01.dbf % cp /backup/control02.dbf ORACLE_HOME/oradata/trgt/control02.dbf
STARTUP MOUNT
RECOVER command with the USING BACKUP CONTROLFILE clause. Specify UNTIL CANCEL if you are performing incomplete recovery. For example, enter:
RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL
For example, assume that you see the following:
ORA-00279: change 55636 generated at 11/0 8/2002 16:59:47 needed for thread 1 ORA-00289: suggestion : /oracle/work/arc_dest/arcr_1_111.arc ORA-00280: change 55636 for thread 1 is in sequence #111 Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
You can specify the name of an online redo log and press Enter (you may have to try this a few times until you find the correct log):
ORACLE_HOME/oradata/redo01.dbf Log applied. Media recovery complete .
If the online logs are inaccessible, then you can cancel recov ery without applying them. If all datafiles are current, and if redo in the online logs is required for recovery, then you cannot ope n the database without applying the online logs. If the online logs are inaccessible, then you must re-create the control file (refer to "Losing All Current and Backup Control Files").
RESETLOGS option after finishing recover
y:
ALTER DATABASE OPEN RESETLOGS;
If you cannot restore the control file to its original place becau
se the media damage is too severe, then you must specify new control file locations in the server parameter file. A valid control fil
e must be available in all locations specified by the CONTROL_FILES initialization parameter. If not, then the database
prevents you from the mounting the database.
To restore a control file to a nondefault location:
Follow the steps in "Rest oring a Backup Control File to the Default Location", except after step 2 add the following ste p:
Edit all locations specified in the CONTROL_FILES initialization parameter
to reflect the new control file locations. For example, if the control file locations listed in the server parameter file are as foll
ows, and both locations are inaccessible:
CONTROL_FILES='/oracle/oradata/trgt/control01.dbf ', '/oracle/oradata/trgt/control01.dbf'
Then, you can edit the initialization parameter file as follows:
CONTROL_FILES= '/good_disk/control01.dbf','/good_disk/control02.dbf'
If all control files have been lost in a permanent media failure, but all online redo log members remain inta
ct, then you can recover the database after creating a new control file. The advantage of this tactic is that you are not required to open the database with the RESETLOGS option.
Dependin
g on the existence and currency of a control file backup, you have the options listed in Table 17-
2 for generating the text of the CREATE CONTROLFILE statement. Note that changes to the database are re
corded in the alert_SID.log, so check this log when deciding which option to choose
.
| If you . . . | Then . . . |
|---|---|
|
Executed |
Use the |
|
Performed your most recent execution of |
Edit the output of |
|
Backed up the
control file with the |
Use the control file copy to obtain SQL output. Create a temporary database instance, mount the backup control file,
and then run |
|
Do not have a co
ntrol file backup in either |
Execute the |
To create a new control file:
NOMOUNT mode. For example, enter:
STARTUP NOMOUNT
CREATE
code> CONTROLFILE statement, specifying the NORESETLOGS option (refer to Tabl
e 17-2 for options). The following example assumes that the character set is the default US7ASCII:
CREATE CONTROLFILE REUSE DATABASE SALES NORESETLOGS ARCHIVELOG
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXDATAFILES 32
MAXINSTANCES 16
MAXLOGHISTORY 1600
LOGFILE
GROUP 1 (
'/diska/
prod/sales/db/log1t1.dbf',
'/diskb/prod/sales/db/log1t2.dbf'
) SIZE 100K
GROUP 2 (
'/diska/prod/sales/db/log2t1.dbf',
'/disk
b/prod/sales/db/log2t2.dbf'
) SIZE 100K,
DATAFILE
'/disk
a/prod/sales/db/database1.dbf',
'/diskb/prod/sales/db/filea.dbf';
After creating the control file, the instance mounts the database.
USING BACKUP CONTROLFILE clause):
RECOVER DATABASE < a name="1006633">
RESETLOGS option not required):
ALTER DATABASE OPEN; < /pre>
/backup/control01.dbf:
ALTER DATABASE BA CKUP CONTROLFILE TO '/backup/control01.dbf' REUSE;
| <
strong class="NH">See Also:
"Backing Up the Cont rol File to a Trace File", and "Recovering Through RESETLOGS wi th Created Control File: Scenario" |
During complete or incomplete media recovery, the datab ase applies redo log files to the datafiles during the roll forward phase of media recovery. Because changes to undo segments are rec orded in the online redo log, rolling forward regenerates the corresponding undo segments. Rolling forward proceeds through as many r edo log files as necessary to bring the database forward in time.
To perform recovery, Orac
le Corporation recommends that you use the RECOVER SQL statement in SQL*Plus. You can also use the SQL statement A
LTER DATABASE RECOVER, but the RECOVER statement is simpler in most cases.
To start any type of media recovery, you must adhere to the following restrictions:
Oracle Corporation recommends that you use the SQL*Plus RECOVER command rather than the ALTER DATABA
SE RECOVER statement to perform media recovery. In almost all cases, the SQL*Plus method is easier.
When using SQL*Plus to perform media recovery, the easiest strategy is to perform automatic recovery. Au tomatic recovery initiates recovery without manually prompting SQL*Plus to apply each individual archived log.
When using SQL*Plus, you have two options for automating the application of the default filenames of archived red o logs needed during recovery:
SET
AUTORECOVERY ON before issuing the RECOVER commandAUTOMATIC keyword as an option of the RECOVER commandIn either case, no interaction is required when you issue the RECOVER command if the necessary files are
in the correct locations with the correct names. The filenames used when you use automatic recovery are derived from the concatenate
d values of LOG_ARCHIVE_FORMAT with LOG_ARCHIVE_DEST_n, where n
is the highest value among all enabled, local destinations.
For example, assume the follow ing initialization parameter settings are in effect in the database instance:
LOG_ARCHIVE_D EST_1 = "LOCATION=/arc_dest/loc1/" LOG_ARCHIVE_DEST_2 = "LOCATION=/arc_dest/loc2/" LOG_A RCHIVE_DEST_STATE_1 = DEFER LOG_ARCHIVE_DEST_STATE_2 = ENABLE LOG_ARCHIVE_FORMAT = arch _%t_%s.arc
In this case, SQL*Plus automatically suggests the file
name /arc_dest/loc2/arch_%t_%s.arc (where %t is the thread and %s is the sequence).
If you run SET AUTORECOVERY OFF, which is the default option,
then you must enter the filenames manually, or accept the suggested default filename by pressing the Enter key.
Run the SET AUTORECOVERY ON command to enable on automatic recovery.
To automate the re covery using SET AUTORECOVERY:
% cp /backup/datafiles/*.dbf $ORACLE_HOME/oradata/trgt/
STARTUP MOUNT
SET AUTORECOVERY ON
RECOVER DATABASE
The database automatically suggests and applies the necessary archived logs.
ALTER DATABASE OPEN;
Besides using AUTORECOVERY to turn on automatic recovery, you can also simply specify the AUTOMATIC keyword
in the RECOVER command.
To automate the recovery with th e RECOVER AUTOMATIC command:
% cp /bac kup/datafiles/*.dbf $ORACLE_HOME/oradata/trgt/
STARTU P MOUNT
AUTOMATIC keyword. This example performs automatic recovery on the whole database:
RECOVER AUTOMATIC DATABASE
The database autom atically suggests and applies the necessary archived logs.
ALTER DATABASE OPEN;
If you use an Oracle Real Application Clusters configuration, and if you are performing incomplete reco very or using a backup control file, then the database can only compute the name of the first archived redo log file from the first redo thread. You may have to manually apply the first log file from the other redo threads. After the first lo g file in a given thread has been supplied, the database can suggest the names of the subsequent logs in this thread.
| < a name="1006760">See Also: < p class="NB">Your operating system specific Oracle documentation for examples of log file application |
Recovering when the archiv ed logs are in their default location is the simplest case. As a log is needed, the database suggests the filename. If you are runnin g nonautomatic media recovery with SQL*Plus, then the output is displayed in this format:
O RA-00279: Change #### generated at DD/MM/YY HH:MM:SS needed for thread# ORA-00289: Suggestion : logfile ORA-00280: Change #### for thread # is in sequence # Specify log: [<RET> for suggested | AUTO | FROM logsource | CANCEL ]
For example, SQL*Plus displays output similar to the following:
ORA-00279: change 53577 g enerated at 11/26/02 19:20:58 needed for thread 1 ORA-00289: suggestion : /oracle/oradata/trgt/arch/arcr_1_802. arc ORA-00280: change 53577 for thread 1 is in sequence #802 Specify log: [<RET> fo r suggested | AUTO | FROM logsource | CANCEL ]
Similar messages a
re returned when you use an ALTER DATABASE ... RECOVER statement. However, no pro
mpt is displayed.
The database constructs suggested archived log filenames by concatenating
the current values of the initialization parameters LOG_ARCHIVE_DEST_n (where n<
/em> is the highest value among all enabled, local destinations) and LOG_ARCHIVE_FORMAT and using log history data from
the control file. The following are possible settings:
LOG_ARCHIVE_DEST_1 = 'LOCATION = /or acle/oradata/trgt/arch/' LOG_ARCHIVE_FORMAT = arcr_%t_%s.arc SELEC T NAME FROM V$ARCHIVED_LOG; NAME --------------------------------- ------- /oracle/oradata/trgt/arch/arcr_1_467.arc /oracle/oradata/trgt/arch/arcr_1_468.arc /oracle/oradata/trgt/arch/arcr_1_469.arc
T
hus, if all the required archived log files are mounted at the LOG_ARCHIVE_DEST_1 destination, and if the value for
Performing me dia recovery when archived logs are not in their default location adds an extra step. You have the following mutually exclusive optio ns:
LOG_ARCHIVE_DEST_n<
/em> parameter that specifies the location of the archived redo logs, then recover as usual.SET statement in SQL*Plus to specify the nondefault log location before recovery, or the LO
GFILE parameter of the RECOVER commandYou can edit the initialization parameter file or issue ALTER SYSTEM statements
to change the default location of the archived redo logs.
To change th e default archived log location before recovery:
% cp /backup/arch/* /tmp/
ALTER SYSTEM<
/code> statements while the instance is started, or edit the initialization parameter file and then start the database instance. For
example, while the instance is shut down edit the parameter file as follows:
LOG_ARCHIVE_DEST
_1 = 'LOCATION=/tmp/'
LOG_ARCHIVE_FORMAT = arcr_%t_%s.arc
STARTUP MOUNT
< a name="1006816">RECOVER DATABASE
In some cases, you may want to override the current setting for the archiving destination parameter as a source for red o log files.
To recover archived logs in a nondefault location with SE T LOGSOURCE:
% cp $ ORACLE_HOME/oradata/trgt/arch/* /tmp
LOGSOURCE parameter of the SET
code> statement or the RECOVER ... FROM clause of the ALTER DATABASE
statement. For example, start SQL*Plus and run:
SET LOGSOURCE "/tmp"
users do the following:
RECOVER AUTOMATIC TABLESPACE users
SE
T LOGSOURCE and simply run:
RECOVER AUTOMATIC TABLESPACE users FROM "/tmp "
If you are using SQL*Plus's recovery options (not SQL statements), then each time the database successful ly applies a redo log file, the following message is returned:
Log applied.
You are then prompted for the next log in the sequence or, if the most recently applied log is the last required log, terminates recovery.
If the suggested file is incorre ct or you provide an incorrect filename, then the database returns an error message. For example, you may see something like:
Recovery cannot continue until the required redo log is applied. If the database returns an error message after supplying a log filename, then the following responses are possib le.
If you start media recovery and must then interrupt it, for example, because a recovery operation must end for the night and resume the next morning, then take either of the following actions:
After recovery is canceled, you can resume it later with th
e RECOVER command. Recovery resumes where it left off when it was canceled.
When you perform complete recovery, you recover th
e backups to the current SCN. You can either recover the whole database at once or recover individual tablespaces or datafiles. Becau
se you do not have to open the database with the RESETLOGS option after complete recovery as you do after incomplete rec
overy, you have the option of recovering some datafiles at one time and the remaining datafiles later.
This section describes the steps necessary to complete media recovery operations, and includes the following topics:
| See Also:
Oracle Database Backup and Recovery Basics for basic information about media recovery concepts, which apply in both use r-managed and RMAN-based backup and recovery. |
| See Also: Oracle Database Backup and Recovery Basics a> to familiarize yourself with fundamental recovery concepts and strategies: |
This section describes steps to perform complete r ecovery while the database is not open. You can recover either all damaged datafiles in one operation, or perform individual recovery of each damaged datafile in separate operations.
Perform the media recovery in the followi ng stages:
In th is stage, you shut down the instance and inspect the media device that is causing the problem.
To prepare for closed database recovery:
SHUTDOW N IMMEDIATE
In this stage, you restore all necessary backups.
To restore the necessary files:
For example, if ORACLE_HOME/oradata/trgt/users01.db
f is the only damaged file, then you may determine that /backup/users01_10_24_02.dbf is the most recent backup of
this file. If you do not have a backup of a specific datafile, then you may be able to create an empty replacement file that can be
recovered.
users01.dbf to
its default location might enter:
% cp /backup/users01_10_24_02.dbf $ORACLE_HOME/oradata/trgt /users01.dbf
Use the following guidelines when determining where to restore datafile backups.
| < a name="1006961"> If . . . | Then . . . |
|---|---|
|
Th e hardware problem is repaired and you can restore the datafiles to their default locations |
Restore the datafiles to their default locations and begin media recovery. |
|
The hardware problem persists and you canno t restore datafiles to their original locations |
Restore the dataf
iles to an alternative storage device. Indicate the new location of these files in the control file with |
In the final stage, you recover the datafiles that you have restored.
To recover the restored datafiles:
STARTUP MOUNT
V$DATAFILE view. For example, enter:
SELECT NAME,STATUS FROM V$DATAFILE;
ALTER DATABASE DATAFILE '/orac le/dbs/tbs_10.f' ONLINE;
If a specified datafile is already onli ne, then the database ignores the statement. If you prefer, create a script to bring all datafiles online at once as in the following :
SPOOL onlineall.sql SELECT 'ALTER DATABASE DATAFILE '''||name||''' ONLINE;' FROM V$DATAFILE; SPOOL OFF SQL> @onlineall
RECOVER command:
REC OVER DATABASE # recovers whole database RECOVER TABLESPACE users # recovers specific tablespace RECOVER DATAFILE '?/oradata/trgt/users01.dbf'; # recovers specific datafile
Follow these guidelines when deciding which statement to execute:
Media recovery complete.
If no archived redo log files are required for complet e media recovery, then the database applies all necessary online redo log files and terminates recovery.
A LTER DATABASE OPEN;
| See Also:
"About User-Managed Media Recovery" for more information about applying redo log files |
It is possible for a media failure to occur while the database remains open, leaving the undamaged datafiles online and available for use. Damaged datafiles--but not the tablespaces that contain them--are automatically taken offlineif the database writer is unable to write to them. Queries that cannot read damaged file s return errors, but the datafiles are not taken offline because of the failed queries. For example, you may run a query and see outp ut such as:
ERROR at line 1: ORA-01116: error in opening database fil e 3 ORA-01110: data file 11: '/oracle/oradata/trgt/cwmlite02.dbf' ORA-27041: unable to op en file SVR4 Error: 2: No such file or directory Additional information: 3
The procedure in this section cannot be used to perform complete media recovery
on the datafiles of the SYSTEM tablespace while the database is open. If the media failure damages datafiles of the
Perform media reco very in these stages:
See Also:
|
In this stage, you take affected tablespac es offline and inspect the media device that is causing the problem.
T o prepare for datafile recovery when the database is open:
users and tools contain damaged datafiles, enter:
ALTER TABLESPACE users OFFLINE TEMPORARY; ALTER TABLESPACE tools OFFLINE TEMPORARY;
In this stage, you restore all necessary backups in the offline tablespaces.
users you might enter:
ALTER DATABASE RENAME FILE '?/oradata/trgt/users01.dbf' TO '/disk2/users01.dbf';
|
See Also:
Oracle Databas
e SQL Reference for more information about |
In the final stage, you recover the datafiles in the offline tablespaces.
To recover offline tablespaces in an open database:
users and tools:
RECOVER TABLESPACE users, tools # recovers datafiles in users and toolsa>
|
Note: For bes t performance, use parallel recovery to recover the datafiles. See "Performing Media Recovery in Parall el". |
RECOVER AUTOMATIC or SET
AUTORECOVERY ON, the database prompts for each required redo log file.
Recovery continues until all required archived logs have been applied to the datafiles. The online redo logs are th en automatically applied to the restored datafiles to complete media recovery. If no archived redo logs are required for complete med ia recovery, then the database does not prompt for any. Instead, all necessary online redo logs are applied, and media recovery is co mplete.
users and to
ols online, issue the following statements:
ALTER TABLESPACE users ONLINE; ALTER TABLESPACE tools ONLINE;
| See Also:
Oracle Database Administrator's Guide for more information about creating datafiles p> |
This section describes the steps necessary to complete the different types of incomplete media recovery operations, and includes the following topics:
In this ph ase, you examine the source of the media problem.
To prepare for incom plete recovery:
SHUTDOWN ABORT
In this phase, you restore a whole database backup.
< a name="1007213">To restore the files necessary for cancel-based recovery and bring them onl ine:
|
Note: If you are unable to restore a control file backup to one of the |
| If . . . | Then . . .< /th> |
|---|---|
|
You do not have a backup of a datafile |
Create an empty replacemen t file that can be recovered as described in "Restoring Backups of the Damaged or Missing Files". |
|
A datafile was added after the intended time of recovery |
< p class="TB">Do not restore a backup of this file because it will no longer be used for the database after recovery completes. |
|
The hardware probl em causing the failure has been solved and all datafiles can be restored to their default locations |
Restore the files as described in "Restoring Datafiles and Archived Redo Logs" and skip Step 4 of this procedure. |
tr>
|
A hardware problem per sists |
Restore damaged datafiles to an alternative storage device. |
STARTUP MOUNT
ALTER DATABASE RENAME FILE '?/oradata/trgt/users01.dbf' TO '/disk2/users01.dbf';
V$DATAFILE view. For example, enter:
SELE CT NAME,STATUS FROM V$DATAFILE;
NORMAL option or is a read-only tablespace. For example, to guarantee that a datafile named ALTER DATABASE DATAFILE ' ?/oradata/trgt/users01.dbf' ONLINE;
If a specified datafile is a lready online, the statement has no effect. If you prefer, create a script to bring all datafiles online at once as in the following:
SPOOL onlineall.sql SELECT 'ALTER DATABASE DATAFILE '''||name||''' ONLINE;' FROM V$DATAFILE; SPOOL OFF SQL> @onlineall
In cancel-based recovery, recovery proceeds by prompti
ng you with the suggested filenames of archived redo log files. Recovery stops when you specify CANCEL instead of a file
name or when all redo has been applied to the datafiles.
Cancel-based recovery is better th an change-based or time-based recovery if you want to control which archived log terminates recovery. For example, you may know that you have lost all logs past sequence 1234, so you want to cancel recovery after log 1233 is applied.
You should perform cancel-based media recovery in these stages:
To perform cancel-based recovery :
STAR TUP MOUNT
RECOVER DATABASE UNTIL CANCEL
If you are using a backup control file with this incomplete recovery, then specify the US
ING BACKUP CONTROLFILE option in the RECOVER command.
RECOVER DATABASE UNTIL CANCEL USING BACKUP CONTROLFILE
LOG_ARCHIVE_DEST_1
code> and requests you to stop or proceed with applying the log file. Note that if the control file is a backup, then you must supply
the names of the online logs if you want to apply the changes in these logs.
Note:
If you use a Real Application Clus
ters (RAC) configuration, and you are performing incomplete recovery or using a backup control file, then the database can only compu
te the name of the first archived redo log file from the first thread. The first redo log file from the other
threads must be supplied by the user. After the first log file in a given thread has been supplied, the database can suggest the nam
es of the subsequent log files in this thread.
CANCEL
The database indicates whether recovery is successful. If you cancel before all the datafiles have been recovered to a co
nsistent SCN and then try to open the database, you will get an ORA-1113 error if more recovery is necessary. As explain
ed in "Determining Which Datafiles Require Recovery", you can que
ry V$RECOVER_FILE to determine whether more recovery is needed, or if a backup of a datafile was not restored prior to s
tarting incomplete recovery.
RESET
LOGS option. You must always reset the logs after incomplete recovery or recovery with a backup control file. For example:
This section describes how to perfo rm the time-based media recovery procedure in the following stages:
To perform change-based or time-based recovery:
RECOVER DATABASE UNTIL statement to begin recovery. If recovering to an SCN, specify as a decimal number without quotation marks. For example, to recover
through SCN 10034 issue:
RECOVER DATABASE UNTIL CHANGE 10034;
If recovering to a time, the time is always specified using the following format, delimited by
single quotation marks: 'YYYY-MM-DD:HH24:MI:SS'. The following statement recovers the database up to a specified time:
p>
RECOVER DATABASE UNTIL TIME '2000-12-31:12:47:30'
RESETLOGS mode. You must always reset the online logs after incomplete recovery or recovery with a backup
control file. For example:
ALTER DATABASE OPEN RESETLOGS;
| See Also: |
| See Also:
"About User
-Managed Media Recovery Problems" for descriptions of situations that can cause |
After opening the database with the RESETLOGS
option, check the alert_SID.log to see whether the database detected inconsistencies
between the data dictionary and the control file, for example, a datafile that the data dictionary includes but which is not listed i
n the new control file. The following table describes two possible scenarios.
If a media failure damages datafiles in a NOARCHIVELOG database, then the only option fo
r recovery is usually to restore a consistent whole database backup. If you are using logical backups created by an Oracle export uti
lity to supplement regular physical backups, then you can also attempt to restore the database by importing an exported backup of the
database into a re-created database or a database restored from an old backup.
In this scenario, the media failure is repaired so that you are able to restore all database files to their original location.
To restore the most recent whole database backup to the default location:
< /a>SHUTDOWN IMMEDIATE
% cp /backup/*.dbf $ORACLE_HOME/oradata/trgt/ < /pre>
RECOVER DATABASE UNTIL CANCEL CANCEL
RESETLOGS mode:
ALTER DATABASE OPEN RESETLOGS;
In this scenario, you restore the database files to an alternative location because t he original location is damaged by a media failure.
To restore the mos t recent whole database backup to a new location:
SHUTDOWN IMMEDIA TE
% cp /backup/*.dbf /new_disk/oradata/trgt/
CONTROL_FILES = "/new_disk/oradata/trgt/control01.dbf"
STARTUP MOUNT
1 you might enter:
ALTER DATABASE RENAME FILE '?/oradata/trgt/system01.dbf' TO '/new_disk/oradata/system01.dbf';
ALTER DATABASE RENAME FILE '?/oradata/trgt/redo01.lo g' TO '/new_disk/oradata/redo_01.log'; ALTER DATABASE RENAME F ILE '?/oradata/trgt/redo02.log' TO '/new_disk/oradata/redo_02.log';
RECOVER DATABASE UNTIL CANCEL; CANCEL;
RESETLOGS mode. T
his command clears the online redo logs and resets the log sequence to 1:
ALTER DATABASE OPEN RESETLOGS;
Note that restoring a NOARCHIVELOG data
base backup and then resetting the log discards all changes to the database made from the time the backup was taken to the time of th
e failure.
| See Also:
Oracle Database Administrator's Guide for more information about renaming and relocating datafiles, and Oracle Database SQL Reference to l
earn about |
Use parallel media recovery to tune the roll forward phase of media recovery. In parallel media recovery, the database u
ses a "division of labor" approach to allocate different processes to different data blocks while rolling forward, thereby making the
procedure more efficient. For example, if parallel recovery is performed with PARALLEL 4, and only one dat
afile is recovered, then four spawned processes read blocks from the datafile and apply records instead of only one process.
Typically, recovery is I/O-bound on reads to data blocks. Parallelism at the block level may only h elp recovery performance if it increases total I/Os, for example, by bypassing operating system restrictions on asynchronous I/Os. Sy stems with efficient asynchronous I/O see little benefit from parallel media recovery.
The
SQL*Plus RECOVER PARALLEL command specifies parallel media recovery (the default is NOPARALLEL
). This command selects a degree of parallelism equal to the number of CPUs available on all participating instances times the value
of the PARALLEL_THREADS_PER_CPU initialization parameter.
The format for the <
code>RECOVER PARALLEL command is the following:
RECOVER PARALLEL in teger;
The integer variable sets the n
umber of recovery processes used for media recovery. If you use a Real Application Clusters configuration, then the database decides
how to distribute these recovery processes among the instances. If integer is not specified, then the database
picks a default number of recovery processes.
| Note:
The |
See Also:
|