home *** CD-ROM | disk | FTP | other *** search
- ...
- ... $Header: recovery.doc,v 6002701.1 89/06/15 23:00:54 rcs Exp $ recovery.doc Copyr (c) 1989 Oracle
- ...
-
- Manual Recovery
- ---------------
-
-
- This note describes the external view of manual recovery and how it relates
- to other forms of recovery. There is no background given - a complete
- understanding of V6 is assumed.
-
- There are two forms of recovery in V6:
-
- Crash Recovery - Normal recovery of a database after a crash
- using online logs. This happens atomatically
- when bringing up a crashed database.
-
- Media Recovery - Recovery of a database using one or more backup
- copies of database files; may require the use of
- archived logs. This form of recovery is envoked
- by issuing
-
- RECOVER DATABASE
-
- from SQLDBA. Media recovery is done on a database
- that is mounted but NOT open. It is done to all
- online tablespaces (offline tablespaces can be
- recovered using "RECOVER TABLESPACE" on an open
- database).
-
- There are two options to media recovery that allow the DBA to stop recovery
- before the end of the most current log. They may be used together or
- seperately:
-
- RECOVER DATABASE [MANUAL] [UNTIL <time>]
-
- <time> is of the form DD-MON-YY:HH:MM:SS (no quotes!)
-
- There are several side effects from doing either type of incomplete
- recovery:
-
- 1) All past logs become invalid after
- recovery is complete.
-
- 2) Recovery cannot stop in the middle of the
- backup of any file. All redo generated between
- typing the BEGIN BACKUP and END BACKUP commands
- must be applied.
-
- 3) Any offline files WILL BE LOST.
-
- 4) All files must be restored from backups taken
- before the point where recovery is terminated.
-
- 5) If the control file is a backup, the control file
- schema can not have changed since the backup was
- taken. No data files or log files may be dropped
- or added since the control file backup was taken.
- Note that the MANUAL option is required if the
- control file is a backup.
-
-
- Recover Until - Like media recovery, except that the recovery process
- is stopped at a particular time. This form of
- recovery is envoked by issuing:
-
- RECOVER DATABASE UNTIL <time>
-
-
- Recover Manual - This option will cause the system to prompt for
- every log. (For logs that were never archived give
- the name of the online log file.) It is used
- so the DBA can stop recovery at the end of a
- particular logfile and/or to restore the control
- file from a backup. (This form of recovery allows
- recovery beyond the "end" of the current
- control file):
-
- RECOVER DATABASE MANUAL
-
- After performing incomplete recovery, ALL log files become invalid, so the
- DBA must open the database using:
-
- ALTER DATABASE OPEN RESETLOGS
-
- The keywords RESETLOGS must be used after either manual or time based
- recovery has been envoked. This clears all the online logs to zero, and
- modifies all the online data files to indicate no recovery is needed.
- After resetting the logs none of the existing log files or data file
- backups can be used. A new backup must be taken before any data is protected
- from media failures.
-
- A NORESETLOGS option also exists but should be used with caution. It informs
- the system that even though the DBA used an incomplete recovery option,
- recovery did in fact go to the end of the log, so the logs are valid. It also
- implies that the control file was not a backup.
-
-
- The following additional SQLDBA commands exist:
-
- ALTER DATABASE DATAFILE <file spec> [ONLINE | OFFLINE]
-
- This command can be used to take an idividual file on or offline - it is
- only valid on a mounted but unopened database. It is useful for forcing
- data files online for an offline tablespace before manual recovery. It is
- also useful for taking a file offline so that the database can be opened
- when the file is on a broken disk drive.
-
- ALTER DATABASE BACKUP CONTROLFILE TO <backup file name>
-
- This command allows the hot backup of a control file - this is the ONLY
- way to backup a control file on an opened database!
-
-
-
- How to use a control file backup
- --------------------------------
-
- It is possible to use manual recovery to make a backup control file current.
- The backup must be more recent than the last add or drop of a log or data
- file. Thus it is prudent to always take a new control file backup after any
- of those operations. Although not strictly required, it is advisable to
- backup the control file after any log or data file renames. Since it is not
- possible to discover the names of data files when the database is closed, it
- is also advisable to keep a list of them in case they need to be named in an
- ALTER DATABASE command. It is best to only take control file backups when all
- data files are online. The following assumes that all online log files are
- intact and all necesssary archived logs are available. If not, see below for
- incomplete recovery.
-
- 1) Make a backup: Make a copy of all the about to be recovered data files and
- online logs. This procedure will make the current files unuseable. Should
- something go wrong, these backups will allow retrying this procedure.
-
- 2) Restore backups: The database must be shutdown. Restore the backup control
- file to all files listed as control files in the init.ora file. Restore
- any necessary data file backups. It is alright to restore to a different
- file name if the correct file is inaccessable (see 4).
-
- 3) Mount the database: Do a STARTUP MOUNT to get the instance started and the
- backup control file opened.
-
- 4) Insure all data files are correctly named: Use the ALTER DATABASE RENAME
- FILE command to correct any file names. This will be needed if a backup
- was restored to a different file or if a rename was done since the control
- file backup was taken. Note that rename does not change the name of the
- file used by the operating system. It changes the name that the database
- uses when it attempts to open the file. It is best to give the fully
- expanded name, in the proper case, for the old file name. This is the name
- as it appears in SELECT * FROM V$DBFILE. The problem is that the name can
- not be translated to the fully expanded version if the file does not exist.
-
- 5) Insure all data files are online: If any data files are offline, either due
- to an i/o error or DBA command, they will never be recoverable after this
- procedure. The offline status is in the control file so the status at the
- time of the control file backup is what counts. Use the ALTER DATABASE
- DATAFILE <file spec> ONLINE command to bring files online. If in doubt put
- a file online, there is no harm in doing it twice. It may be desirable to
- have a file offline to avoid recovering it, but once the database is opened
- it will be necessary to drop the tablespace containing the file. This will
- lose all data in that tablespace as well as any data in the file.
-
- 6) Do manual recovery: Use the RECOVER DATABASE MANUAL command to do manual
- recovery. If you restored any data files from backups it may request logs
- that were archived. Eventually you will be prompted for a log that is not
- archived, enter the name of an online log file. If you get the wrong one
- you will get an error indicating the sequence number of the file you named.
- Keep trying online logs till you get it right. After that log is processed
- you will be prompted for the next sequence number. Keep naming the online
- logs until it requests a sequence number higher than any of the logs.
- Recovery is now complete to the present, so enter CANCEL for the log name.
-
- 7) Open the database: Use ALTER DATABASE OPEN RESETLOGS to open the database.
- This will destroy the contents of the online logs and the start rba's of
- the online data files. The software will accept the NORESETLOGS option but
- this may result in a corrupted database.
-
- 8) Make new backups: All data files must be backed up before media recovery can
- work. Resetting the logs marked the database to prevent the use of any logs
- from before the reset. Thus any data file backups from before the reset can
- not be recovered. The old logs and data file backups are only useful for
- repeating this procedure.
-
-
- How to do incomplete recovery
- -----------------------------
-
- Situations can arise where it is desirable to recover to some point in the
- past. For example, an important table may be accidentally dropped, or a log
- file needed for recovery may be lost. The database can be restored to a
- particular point in time or to the end of a particular redo log. If necessary,
- a backup control file may also be used. See above for restrictions on the use
- of backup control files.
-
- 1) Make a backup: Make a copy of all the online logs. This procedure will make
- the current logs unuseable. Should something go wrong, these backups will
- allow retrying this procedure. Note that the current data files can not be
- used in this procedure, but it might be prudent to take a copy of them
- anyway.
-
- 2) Restore backups: The database must be shutdown. All data files must be
- restored from image backups taken before the point where recovery will be
- stopped. This is necessary to insure that all the files in the database
- are recovered to the same point in time. Unfortunately there is no check to
- enforce this restriction. Failure to do this will result in a corrupt
- database. However the corruption may not be noticed until a long time after
- the recovery is completed and the database is in use. It is alright to
- restore a data file to a different file name if the correct file is
- inaccessable (see 4).
-
- 3) Mount the database: Do a STARTUP MOUNT to get the instance started and the
- control file opened.
-
- 4) Insure all data files are correctly named: Use the ALTER DATABASE RENAME
- FILE command to correct any file names. This will be needed if a backup
- was restored to a different file or if a backup control file is used and a
- rename was done since the backup was taken. Note that rename does not
- change the name of the file used by the operating system. It changes the
- name that the database uses when it attempts to open the file. It is best
- to give the fully expanded name, in the proper case, for the old file name.
- This is the name as it appears in SELECT * FROM V$DBFILE. The problem is
- that the name can not be translated to the fully expanded version if the
- file does not exist.
-
-
- 5) Insure all data files are online: If any data files are offline, either due
- to an i/o error or DBA command, they will never be recoverable after this
- procedure. The offline status is in the control file so the status at the
- time of the control file is what counts. Use the ALTER DATABASE DATAFILE
- <file spec> ONLINE command to bring files online. If in doubt put a file
- online, there is no harm in doing it twice. It may be desirable to have
- a file offline to avoid recovering it, but once the database is opened
- it will be necessary to drop the tablespace containing the file. This will
- lose all data in that tablespace as well as any data in the file.
-
- 6) Do incomplete recovery: To recover to the end of a particular log use the
- RECOVER DATABASE MANUAL command. To recover to a point in time use the
- RECOVER DATABASE UNTIL DD-MON-YY:HH:MM:SS command. If the control file is
- a backup then add the MANUAL option as well. You will be prompted by
- sequence number for the names of log files. If necessary give the name of
- one of the online logs. If you get the wrong one you will get an error
- indicating the sequence number of the file you named. Keep trying online
- logs till you get it right. You may enter CANCEL at any time to end
- recovery. After cancelling you may enter the recover command again to
- resume where you left off, or you can just end recovery there. If the UNTIL
- option was given recovery will end when that time is found in the logs.
- Otherwise cancelling is the only way to end recovery.
-
- 7) Open the database: Use ALTER DATABASE OPEN RESETLOGS to open the database.
- This will destroy the contents of the online logs and the start rba's of
- the online data files. The software will accept the NORESETLOGS option but
- this may result in a corrupted database. The only valid use of the no reset
- option is if you did not use a control file backup, changed your mind about
- incomplete recovery, cancelled incomplete recovery, and did a normal
- RECOVER DATABASE command to complete recovery.
-
- 8) Make new backups: All data files must be backed up before media recovery can
- work. Resetting the logs marked the database to prevent the use of any logs
- from before the reset. Thus any data file backups from before the reset can
- not be recovered. The old logs and data file backups are only useful for
- repeating this procedure.
-