Subject: Physical Backup and Recovery: An Insider's Perspective
PHYSICAL BACKUP AND RECOVERY: AN INSIDER'S PERSPECTIVE
INTRODUCTION
============
This article discusses the most common concepts of backup and
recovery of the Oracle database.
This article discusses physical backups and not logical backups.
(An export of the database is an example of a logical backup.)
Why do we need backups?
======================
The most important responsibility of a database administrator is to
prepare for the possibility of media, hardware and software failure.
Should any of these failures occur the major goal is to make the
database available to users within an acceptable time, ensuring
that committed data is undamaged.
This paper discusses only physical backups and not logical backups.
An export of the database is an example of a logical backup.
What are the things that go wrong and eventually lead to recovery?
=================================================================
One or more database files are damaged.
One or more redo log files (including online) are damaged.
One or all control files are damaged.
What is recovery?
================
Restoring the files from backup and rolling forward in time is RECOVERY.
AN INTERNAL VIEW
================
Some admnistrative actions can destroy a database beyond repair. This is
particularly true of backup and recovery commands. To understand the
dangers of certain commands, a database administrator should have a
good understanding of the contents and purpose of the control file,
datafiles and log files. The basics are provided here.
Control file
============
A control file reflects the structure of a database at particular points
in time. It contains the checkpoint information, names of log files
and data files, header information of the files and log sequence number,
which is very important for recovery purposes. The recovery is done
only by applying the log files whose sequence number is greater than
log sequence number in the control file.
Datafile information in control file:
------------------------------------
- Names of datafiles and log files with exact path.
- File size.
- Block size.(Oracle block size)
- Whether the datafile is online or offline.
- Whether the datafile was taken offline automatically or not.
- Whether the datafile belongs to the system tablespace or not.
- Entry for each datafile giving a log sequence number when tablespace
was taken offline.
Log file information in control file:
------------------------------------
- Name with exact path.
- File size.
- Block size. (O/S block size)
- Log sequence#
- Has the file been archived.
Information in the datafile header
==================================
- Log sequence number of next log file that could be applied.
- Whether online backup in progress.
Information in the log file header
==================================
- Log sequence#
- Archival information.
BACKUP
======
Offline Backup
==============
A backup taken when the database is shut down normally is known as
offline or a cold backup. Copying of the datafiles, control file and
online redo log files must be done by using an operating system
copy utility. This is a considered as a complete backup of the
database. Any changes made after this backup will be unrecoverable if
the database is running in NOARCHIVELOG mode. All transactions are
recorded in online redo log files whether archiving or not. When redo
logs are archived (ARCHIVELOG mode), ORACLE allows you to apply these
transactions after restoring files that were damaged (assuming an
active Redo log file was not among the files damaged).
Whenever the schema of the database is changed, such as a new datafile
is added or a file is renamed or a tablespace is created or dropped,
shutdown the database and at least make a copy of the control file and
the newly added datafile. A complete backup of the database is
preferred.
Online Backup
=============
At sites where a database must operate 24-hours per day and when it is
not feasible to take offline backups, then an alternative is provided
by Oracle where physical backups are performed while the database remains
available for both reading and updating. For this kind of backup the
database must be in ARCHIVELOG mode. Only data files and current
control file need to be backed up. Unlike offline backups, the unit of
a online backup is a tablespace, and any or all tablespaces can backed
up whenever needed. Different datafiles can be backed up at different
times.
Procedure
---------
ALTER TABLESPACE ts_name BEGIN BACKUP
Then perform an operating system backup of all datafiles in that
tablespace. Once the backup is completed then it is very important
to issue the command:
ALTER TABLESPACE ts_name END BACKUP
All this must be done while the database is open.
Frequency of online backups
---------------------------
In order to determine how frequently to back up the files of a
database, balance the amount of time available for taking backups
and the time available for recovery after media failure. The time for
recovery depends on how old your most recent copy of the damaged file
is. The older your backup, the more redo log files need to be applied,
and the longer recovery will take.
Backup strategies should be tested before being used to protect a
production database. Ensure that backups of all datafiles and of all
necessary redo logs are kept, and that backups are restored correctly.
(If file compression is used, verify that the file is correct after
decompression.)
What happens between BEGIN BACKUP and END BACKUP?
------------------------------------------------
Once the ALTER TABLESPACE ts_name BEGIN BACKUP is issued the status
in the datafile header is changed to indicate that the datafile is
being backed up. Oracle stops recording the occurrence of checkpoints
in the header of the database files. This means that when a database
file is restored, it will have knowledge of the most recent checkpoint
that occurred BEFORE the backup, not any that occurred during the
backup. This way, the system will ask for the appropriate set of redo
log files to apply should recovery be needed. Since vital information
needed for recovery is recorded in the Redo logs, these REDO LOGS are
considered as part of the backup. Hence, while backing up the database
in this way the database must be in ARCHIVELOG mode. Status in the
datafile header is not reset until END BACKUP is issued.
On END BACKUP, the system again begins noting the occurrence of the
checkpoints in each file of the database. The checkpoint in the
datafile header is changed during the next log switch after END BACKUP
is issued. The above information will allow the tablespace to be
recovered as if the database had been offline when the backup took
place.
Critical Files
==============
All the files belonging to the database are important. Along with
other tablespaces, special care should be taken to ensure that the
SYSTEM tablespace and tablespaces containing rollback segments, are
protected by backups. Also backup the control file and datafile
immediately after adding it to a tablespace or after creating
tablespace if archiving is enabled. If media failure damages a datafile
that has not been backed up, recovering it's tablespace is not
possible. After backing up the newly added datafile, include it in the
regular datafile backup rotation.
RECOVERY
========
Instance Failure
================
Instance failure is a hardware, software, or system failure that
prevents an instance from continuing work. It can be caused by
a CPU failure, an operating system failure, a power outage, failure
of one of the ORACLE background processes or a failure to access a
required database file when the file is not lost or damaged.
Instance Recovery
=================
Instance recovery is automatic. Restarting the database performs the
instance recovery. It involves two steps.
1) Rolling forward.
- data that has not been recorded in the database
- the contents of rollback segments
2) Rolling back transactions that have been explicitly rolled
back or have not been committed.
3) Releasing any resources held by transactions in process at the
time of the failure.
4) Instance recovery is not necessary if the database is shutdown
normally.
Media failure
=============
Media failure is a hardware, software, or system failure that prevents
reading or writing to files that are required to operate the database.
Media failure is a failure caused by the loss of the control file,
database files or redo log file.
Media Recovery
==============
What is needed for media recovery?
---------------------------------
The database must be operating in ARCHIVELOG mode. In addition, you must
have the latest backup of database, all online redo log files, archived logs,
current control file.
Performing Recovery
-------------------
You can use different commands to recover your database. They are:
1) RECOVER DATABASE
This command is only used with a current control file. Database must
be mounted, but not OPEN. The control file is compared with the
datafile header and brings the datafiles up to date by applying
archived redo logs to make the control file entries match the datafile
header. Online redo logs are applied to make the datafiles current.
Once the recovery is complete open the database with:
ALTER DATABASE OPEN
2) RECOVER DATAFILE
This command is used when database is up and cannot be stopped. Can also be used when the database is in mounted state. The tablespace which contains these datafiles must be taken offline. Issue RECOVER DATAFILE , command. You will be prompted for log files. The changes will be applied only to these files. Once the media recovery is complete the tablespace can be brought online. Allows 'multi-tasking' recovery. Different datafiles can be recovered parallelly using different sessions or terminals. Very useful when there are several datafiles to be recovered. 3) RECOVER TABLESPACE Tablespace must be offline. Database must be in OPEN state. Recovers a single tablespace to the current state. This command cannot be used on SYSTEM tablespace or a tablespace which has rollback segments having a status "in use". If having database OPEN is not an issue, can recover using standard recovery (RECOVER DATABASE). 4) RECOVER DATABASE MANUAL Manual recovery after media failure enables you to control how many redo log files to apply to the database. This can used to undo an inadvertent change to the database by stopping recovery before the change took place. MANUAL option needed for recovery with a control file backup (old copy) and current control file is not available. Database must be MOUNTed but not OPEN. After MOUNTing the database connect internal and issue RECOVER DATABASE MANUAL command. Then you will be prompted beginning with the earliest redo log file recorded in the header of each database file. The recovery process will continue to prompt for redo log files until CANCEL is typed when prompted for the next redo log file. Recovery can be cancelled at any time of any redo log. 5) RECOVER DATABASE UNTIL Is same as RECOVER DATABASE MANUAL except the granularity is recovery is stopped at a specified in time within a log file. Cannot be used for recovery with an old copy(backup) of control file. 6) RECOVER DATABASE MANUAL UNTIL Can be used for recovery with an old copy(backup) of control file. Everything else is similar as RECOVER DATABASE UNTIL. Opening the Database -------------------- For safety, before starting any recovery action, always backup datafiles, online logs, and control files. If space is a constraint then at least backup the online logs and control files. Open the database with: ALTER DATABASE OPEN [NO]RESETLOGS NORESETLOGS The NORESETLOGS option does not clear the redo log files during startup and the online redo logs to be used for recovery. Only used in scenario where MANUAL RECOVERY started, CANCEL used, and then RECOVER DATABASE is started. RESETLOGS CAUTION: Never use RESETLOGS unless necessary. Once RESETLOGS is used then the redo log files cannot be used and any completed transactions in those redo logs are lost!! Before using the RESETLOGS option take an offline backup of the database. The RESETLOGS option clears all the online redo logs and modifies all the online data files to indicate no recovery is needed. After resetting the redo logs none of the existing log files or data file backups can be used. In the control file, the log sequence number is modified, which is very important for recovery purposes. The recovery will be applied only to the log files whose sequence number is greater than log sequence number in the control file. One has to be very cautious when using RESETLOGS option. It is important to remember that all datafiles must be online otherwise they will become useless once the database up. After Recovery -------------- Take an offline BACKUP after recovering the database using either of the above options. CONCLUSION ========== Oracle provides a Database Administrator with many recovery options to recover from various types of failure. Each option is dependent upon the failure and the available backup files. Hence, good backup strategy is essential for recovery. Subject: Backup and Recovery Scenarios PURPOSE Describe various Backup and Recovery Scenarios SCOPE & APPLICATION All support analysts RELATED DOCUMENTS Backup and Recovery HandBook, Intro to DataServer Course Material Backup and Recovery - an Overview Backup a) Consistent backups A consistent backup means that all data files and control files are consistent to a point in time. I.e. they have the same SCN. This is the only method of backup when the database is in NO Archive log mode. b) Inconsistent backups An Inconsistent backup is possible only when the database is in Archivelog mode and proper Oracle aware software is used. Most default backup software can not backup open files. Special precautions need to be used and testing needs to be done. You must apply redo logs to the data files, in order to restore the database to a consistent state. c) Database Archive mode The database can run in either Archivelog mode or noarchivelog mode. When you first create the database, you specify if it is to be in Archivelog mode. Then in the init.ora file you set the parameter log_archive_start=true so that archiving will start automatically on startup. If the database has not been created with Archivelog mode enabled, you can issue the command whilst the database is mounted, not open. SVRMGR> alter database Archivelog;. SVRMGR> log archive start SVRMGR> alter database open SVRMGR> archive log list This command will show you the log mode and if automatic archival is set. d) Backup Methods Essentially, there are two backup methods, hot and cold, also known as online and offline, respectively. A cold backup is one taken when the database is shutdown. A hot backup is on taken when the database is running. Commands for a hot backup: 1. Svrmgr>alter database Archivelog Svrmgr> log archive start Svrmgr> alter database open 2. Svrmgr> archive log list --This will show what the oldest online log sequence is. As a precaution, always keep the all archived log files starting from the oldest online log sequence. 3. Svrmgr> Alter tablespace tablespace_name BEGIN BACKUP 4. --Using an OS command, backup the datafile(s) of this tablespace. 5. Svrmgr> Alter tablespace tablespace_name END BACKUP --- repeat step 3, 4, 5 for each tablespace. 6. Svrmgr> archive log list ---do this again to obtain the current log sequence. You will want to make sure you have a copy of this redo log file. 7. So to force an archived log, issue Svrmgr> ALTER SYSTEM SWITCH LOGFILE A better way to force this would be: svrmgr> alter system archive log current; 8. Svrmgr> archive log list This is done again to check if the log file had been archived and to find the latest archived sequence number. 9. Backup all archived log files determined from steps 2 and 8. Do not backup the online redo logs. These will contain the end-of-backup marker and can cause corruption if use doing recovery. 10. Back up the control file: Svrmgr> Alter database backup controlfile to 'filename' e) Incremental backups These are backups that are taken on blocks that have been modified since the last backup. These are useful as they don't take up as much space and time. There are two kinds of incremental backups Cumulative and Non cumulative. Cumulative incremental backups include all blocks that were changed since the last backup at a lower level. This one reduces the work during restoration as only one backup contains all the changed blocks. Noncumulative only includes blocks that were changed since the previous backup at the same or lower level. Using rman, you issue the command "backup incremental level n" f) Support scenarios When the database crashes, you now have a backup. You restore the backup and then recover the database. Also, don't forget to take a backup of the control file whenever there is a schema change. RECOVERY ========= There are several kinds of recovery you can perform, depending on the type of failure and the kind of backup you have. Essentially, if you are not running in archive log mode, then you can only recover the cold backup of the database and you will lose any new data and changes made since that backup was taken. If, however, the database is in Archivelog mode you will be able to restore the database up to the time of failure. There are three basic types of recovery: 1. Online Block Recovery. This is performed automatically by Oracle.(pmon) Occurs when a process dies while changing a buffer. Oracle will reconstruct the buffer using the online redo logs and writes it to disk. 2. Thread Recovery. This is also performed automatically by Oracle. Occurs when an instance crashes while having the database open. Oracle applies all the redo changes in the thread that occurred since the last time the thread was checkpointed. 3. Media Recovery. This is required when a data file is restored from backup. The checkpoint count in the data files here are not equal to the check point count in the control file. This is also required when a file was offlined without checkpoint and when using a backup control file. Now let's explain a little about Redo vs Rollback. Redo information is recorded so that all commands that took place can be repeated during recovery. Rollback information is recorded so that you can undo changes made by the current transaction but were not committed. The Redo Logs are used to Roll Forward the changes made, both committed and non- committed changes. Then from the Rollback segments, the undo information is used to rollback the uncommitted changes. Media Failure and Recovery in Noarchivelog Mode In this case, your only option is to restore a backup of your Oracle files. The files you need are all datafiles, and control files. You only need to restore the password file or parameter files if they are lost or are corrupted. Media Failure and Recovery in Archivelog Mode In this case, there are several kinds of recovery you can perform, depending on what has been lost. The three basic kinds of recovery are: 1. Recover database - here you use the recover database command and the database must be closed and mounted. Oracle will recover all datafiles that are online. 2. Recover tablespace - use the recover tablespace command. The database can be open but the tablespace must be offline. 3. Recover datafile - use the recover datafile command. The database can be open but the specified datafile must be offline. Note: You must have all archived logs since the backup you restored from, or else you will not have a complete recovery. a) Point in Time recovery: A typical scenario is that you dropped a table at say noon, and want to recover it. You will have to restore the appropriate datafiles and do a point-in-time recovery to a time just before noon. Note: you will lose any transactions that occurred after noon. After you have recovered until noon, you must open the database with resetlogs. This is necessary to reset the log numbers, which will protect the database from having the redo logs that weren't used be applied. The four incomplete recovery scenarios all work the same: Recover database until time '1999-12-01:12:00:00'; Recover database until cancel; (you type in cancel to stop) Recover database until change n; Recover database until cancel using backup controlfile; Note: When performing an incomplete recovery, the datafiles must be online. Do a select name, status from v$datafile to find out if there are any files which are offline. If you were to perform a recovery on a database which has tablespaces offline, and they had not been taken offline in a normal state, you will lose them when you issue the open resetlogs command. This is because the data file needs recovery from a point before the resetlogs option was used. b) Recovery without control file If you have lost the current control file, or the current control file is inconsistent with files that you need to recover, you need to recover either by using a backup control file command or create a new control file. You can also recreate the control file based on the current one using the 'backup control file to trace' command which will create a script for you to run to create a new one. Recover database using backup control file command must be used when using a control file other that the current. The database must then be opened with resetlogs option. c) Recovery of missing datafile with rollback segment The tricky part here is if you are performing online recovery. Otherwise you can just use the recover datafile command. Now, if you are performing an online recovery, you must first ensure that in the init.ora file, you remove the parameter rollback_segments. Otherwise, oracle will want to use those rollback segments when opening the database, but can't find them and wont open. Until you recover the datafiles that contain the rollback segments, you need to create some temporary rollback segments in order for new transactions to work. Even if other rollback segments are ok, they will have to be taken offline. So, all the rollback segments that belong to the datafile need to be recovered. If all the datafiles belonging to the tablespace rollback_data were lost, you can now issue a recover tablespace rollback_data. Next bring the tablespace online and check the status of the rollback segments by doing a select segment_name, status from dba_rollback_segs; You will see the list of rollback segments that are in status Need Recovery. Simply issue alter rollback segment online command to complete. Don't forget to reset the rollback_segments parameter in the init.ora. d) Recovery of missing datafile without rollback segment There are three ways to recover in this scenario, as mentioned above. 1. recover database 2. recover datafile 'c:\orant\database\usr1orcl.ora' 3. recover tablespace user_data e) Recovery with missing online redo logs Missing online redo logs means that somehow you have lost your redo logs before they had a chance to archived. This means that crash recovery cannot be performed, so media recovery is required instead. All datafiles will need to berestored and rolled forwarded until the last available archived log file is applied. This is thus an incomplete recovery, and as such, the recover database command is necessary. (i.e. you cannot do a datafile or tablespace recovery). As always, when an incomplete recovery is performed, you must open the database with resetlogs. Note: the best way to avoid this kind of a loss, is to mirror your online log files. f) Recovery with missing archived redo logs If your archives are missing, the only way to recover the database is to restore from your latest backup. You will have lost any uncommitted transactions which were recorded in the archived redo logs. Again, this is why Oracle strongly suggests mirroring your online redo logs and duplicating copies of the archives. g) Recovery with resetlogs option Reset log option should be the last resort, however, as we have seen from above, it may be required due to incomplete recoveries. (recover using a backup control file, or a point in time recovery). It is imperative that you backup up the database immediately after you have opened the database with reset logs. The reason is that oracle updates the control file and resets log numbers, and you will not be able to recover from the old logs. The next concern will be if the database crashes after you have opened the database with resetlogs, but have not had time to backup the database. How to recover? Shut down the database Backup all the datafiles and the control file Startup mount Alter database open resetlogs This will work, because you have a copy of a control file after the resetlogs point. Media failure before a backup after resetlogs. If a media failure should occur before a backup was made after you opened the database using resetlogs, you will most likely lose data. The reason is because restoring a lost datafile from a backup prior to the resetlogs will give an error that the file is from a point in time earlier, and you don't have its backup log anymore. h) Recovery with corrupted/missing rollback segments. If a rollback segment is missing or corrupted, you will not be able to open the database. The first step is to find out what object is causing the rollback to appear corrupted. If we can determine that, we can drop that object. If we can't we will need to log an iTar to engage support. So, how do we find out if it's actually a bad object? 1. Make sure that all tablespaces are online and all datafiles are online. This can be checked through v$datafile, under the status column. For tablespaces associated with the datafiles, look in dba_tablespaces. If this doesn't show us anything, i.e., all are online, then 2. Put the following in the init.ora: event = "10015 trace name context forever, level 10" This event will generate a trace file that will reveal information about the transaction Oracle is trying to roll back and most importantly, what object Oracle is trying to apply the undo to. Stop and start the database. 3. Check in the directory that is specified by the user_dump_dest parameter (in the init.ora or show parameter command) for a trace file that was generated at startup time. 4. In the trace file, there should be a message similar to: error recovery tx(#,#) object #. TX(#,#) refers to transaction information. The object # is the same as the object_id in sys.dba_objects. 5. Use the following query to find out what object Oracle is trying to perform recovery on. select owner, object_name, object_type, status from dba_objects where object_id = ; 6. Drop the offending object so the undo can be released. An export or relying on a backup may be necessary to restore the object after the corrupted rollback segment goes away. 7. After dropping the object, put the rollback segment back in the init.ora parameter rollback_segments, remove the event, and shutdown and startup the database. In most cases, the above steps will resolve the problematic rollback segment. If this still does not resolve the problem, it may be likely that the corruption is in the actual rollback segment. If in fact the rollback segment itself is corrupted, we should see if we can restore from a backup. However, that isn't always possible, there may not be a recent backup etc. In this case, we have to force the database open with the unsupported, hidden parameters, you will need to log an iTar to engage support. Please note, that this is potentially dangerous! When these are used, transaction tables are not read on opening of the database Because of this, the typical safeguards associated with the rollback segment are disabled. Their status is 'offline' in dba_rollback_segs. Consequently, there is no check for active transactions before dropping the rollback segment. If you drop a rollback segment which contains active transactions then you will have logical corruption. Possibly this corruption will be in the data dictionary. If the rollback segment datafile is physically missing, has been offlined dropped, or the rollback segment header itself is corrupt, there is no way to dump the transaction table to check for active transactions. So the only thing to do is get the database open, export and rebuild. Log an iTar to engage support to help with this process. If you cannot get the database open, there is no other alternative than restoring from a backup. i) Recovery with System Clock change. You can end up with duplicate timestamps in the datafiles when a system clock changes. A solution here is to recover the database until time 'yyyy-mm-dd:00:00:00', and set the time to be later than the when the problem occurred. That way it will roll forward through the records that were actually performed later, but have an earlier time stamp due to the system clock change. Performing a complete recovery is optimal, as all transactions will be applied. j) Recovery with missing System tablespace. The only option is to restore from a backup. k) Media Recovery of offline tablespace When a tablespace is offline, you cannot recover datafiles belonging to this tablespace using recover database command. The reason is because a recover database command will only recover online datafiles. Since the tablespace is offline, it thinks the datafiles are offline as well, so even if you recover database and roll forward, the datafiles in this tablespace will not be touched. Instead, you need to perform a recover tablespace command. Alternatively, you could restored the datafiles from a cold backup, mount the database and select from the v$datafile view to see if any of the datafiles are offline. If they are, bring them online, and then you can perform a recover database command. l) Recovery of Read-Only tablespaces If you have a current control file, then recovery of read only tablespaces is no different than recovering read-write files. The issues with read-only tablespaces arise if you have to use a backup control file. If the tablespace is in read-only mode, and hasn't changed to read-write since the last backup, then you will be able to media recovery using a backup control file by taking the tablespace offline. The reason here is that when you are using the backup control file, you must open the database with resetlogs. And we know that Oracle wont let you read files from before a resetlogs was done. However, there is an exception with read-only tablespaces. You will be able to take the datafiles online after you have opened the database. When you have tablespaces that switch modes and you don't have a current control file, you should use a backup control file that recognizes the tablespace in read-write mode. If you don't have a backup control file, you can create a new one using the create controlfile command. Basically, the point here is that you should take a backup of the control file every time you switch a tablespaces mod Subject: Common Causes and Solutions on ORA-1113 Error ( occurs when datafile needs recovery ) Found in Backup & Recovery PURPOSE ------- To consolidate the common reasons & solutions for the ORA-1113 error. SCOPE & APPLICATION -------------------- Customers facing ORA-1113 and analysts requiring information on known issues with ORA-1113 errors. ORA-1113 ======== An ORA-1113 occurs when a datafile needs recovery. Error Explanation: ------------------ 01113, 00000, "file %s needs media recovery" Cause: An attempt was made to online or open a database with a file that is in need of media recovery. Action: First apply media recovery to the file. This error is usually followed with ORA-1110 error which will indicate the name of the datafile that needs media recovery. Eg: ORA-01113: file 28 needs media recovery ORA-01110: data file 28: '/h04/usupport/app/oracle/oradata/v817/nar.dbf' This error message indicates that a datafile that is not up-to-date with respect to the controlfile and other datafiles. Oracle's architecture is tightly coupled in the sense that all database files i.e., datafiles, redolog files, and controlfiles -- must be in sync when the database is opened or at the end of a checkpoint. This implies that the checkpoint SCN (System Commit Number) of all datafiles must be the same. If that is not the case for a particular datafile, an ORA-1113 error will be generated. For example, when you put a tablespace in hot backup mode, the checkpoint SCN of all its datafiles is frozen at the current value until you issue the corresponding end backup. If the database crashes during a hot backup and you try to restart it without doing recovery, you will likely get ORA-1113 for at least one of the datafiles in the tablespace that was being backed up, since its SCN will probably be lower than that of the controlfile and the datafiles in other tablespaces. Likewise, offlining a datafile causes its checkpoint SCN to freeze. If you simply attempt to online the file without recovering it first, its SCN will likely be much older than that of the online datafiles, and thus an ORA-1113 will result. ********************************************** Before Starting these actions do the following: ********************************************** Note : If you are using Oracle9i, use SQL*Plus, instead of Server Manager to execute the mentioned commands, since Server Manager is not available in Oracle9i. Query the V$LOG and V$LOGFILE. 1. If the database is down, you need to mount it first. SVRMGR> STARTUP MOUNT PFILE=; 2. Then connect internal Server Manager and issue the query: SVRMGR> CONNECT INTERNAL; or SQL> connect / as sysdba (for Oracle9i) SVRMGR> SELECT V1.GROUP#, MEMBER, SEQUENCE#, FIRST_CHANGE# FROM V$LOG V1, V$LOGFILE V2 WHERE V1.GROUP# = V2.GROUP# ; This will list all your online redolog files and their respective sequence and first change numbers. The steps to take next depend on the scenario in which the ORA-1113 was issued. This is discussed in the following sections. POSSIBLE CAUSES AND SOLUTIONS SUMMARY: ===================================== I. AT STARTUP AFTER CRASH WITH TABLESPACE(S) IN HOT BACKUP II. AT STARTUP AFTER RESTORING A DATAFILE OR TABLESPACE FROM A BACKUP III. TRYING TO ONLINE A DATAFILE OR TABLESPACE IV. WHEN RECOVERING ' USING BACKUP CONTROLFILE' OPTION TO DO INCOMPLETE RECOVERY I. AT STARTUP AFTER CRASH WITH TABLESPACE(S) IN HOT BACKUP ********************************************************** A. WITH ORACLE 7.1 OR LOWER 1. Mount the database.(If the database is NOT already mounted) SVRMGR> STARTUP MOUNT PFILE=; 2. Apply media recovery to the database. SVRMGR> RECOVER DATABASE; 3. Confirm each of the archived logs that you are prompted for until you receive the message "Media recovery complete". If you are prompted for an archived log that does not exist, Oracle probably needs one or more of the online logs to proceed with the recovery. Compare the sequence number referenced in the ORA-280 message with the sequence numbers of your online logs. Then enter the full path name of one of the members of the redo group whose sequence number matches the one you are being asked for. 4. Open the database. SVRMGR> ALTER DATABASE OPEN; B. WITH ORACLE 7.2 OR HIGHER 1. Mount the database. SVRMGR> STARTUP MOUNT; 2. Find out which datafiles were in hot backup mode when the database crashed or was shutdown abort or the machine was rebooted by running the query: SVRMGR> SELECT V1.FILE#, NAME FROM V$BACKUP V1, V$DATAFILE V2 WHERE V1.STATUS = 'ACTIVE' AND V1.FILE# = V2.FILE# ; 3. For each of the files returned by the above query, issue the command: SVRMGR> ALTER DATABASE DATAFILE '' END BACKUP; 4. Open the database. SVRMGR> ALTER DATABASE OPEN; II. AT STARTUP AFTER RESTORING A DATAFILE OR TABLESPACE FROM A BACKUP ********************************************************************* A. WITH THE DATABASE IN ARCHIVELOG MODE 1. Mount the database. SVRMGR> STARTUP MOUNT; 2. Recover the datafile: SVRMGR> RECOVER DATAFILE ''; If recovering more than one datafile in a tablepace issue a SVRMGR> RECOVER TABLESPACE; If recovering more than one tablespace issue a SVRMGR> RECOVER DATABASE; 3. Confirm each of the archived logs that you are prompted for until you receive the message "Media recovery complete". If you are prompted for an archived log that does not exist, Oracle probably needs one or more of the online logs to proceed with the recovery. Compare the sequence number referenced in the ORA-280 message with the sequence numbers of your online logs. Then enter the full path name of one of the members of the redo group whose sequence number matches the one you are being asked for. 4. Open the database. SVRMGR> ALTER DATABASE OPEN; B. WITH THE DATABASE IN NOARCHIVELOG MODE In this case, you will only succeed in recovering the datafile or tablespace if the redo to be applied to it is within the range of your online logs. Issue the query: SVRMGR> SELECT FILE#, CHANGE# FROM V$RECOVER_FILE; Compare the change number you obtain with the FIRST_CHANGE# of your online logs. If the CHANGE# is GREATER than the minimum FIRST_CHANGE# of your logs, the datafile can be recovered. In this case, the procedure to be followed is analogous to that of scenario II.A above, except that you must always enter the appropriate online log when prompted, until recovery is finished. If the CHANGE# is LESS than the minimum FIRST_CHANGE# of your logs, the file cannot be recovered.Your options at this point include: - If the datafile is in a temporary or index tablespace, you may drop it with an ALTER DATABASE DATAFILE '' OFFLINE DROP statement and then open the database. Once the database is up, you must drop the tablespace to which the datafile belongs and recreate it. - If the datafile is in the SYSTEM or in a rollback tablespace, restore an up-to-date copy of the datafile (if available) or your most recent full backup.In case you do not have either of this, then it might not be possible to recover the database fully. For more details or to assist you in your decision, please contact Oracle Customer Support. For all other cases in this scenario, you must weigh the cost of going to a backup versus the cost of recreating the tablespace involved, as described in the two previous cases.For more details or to assist you in your decision, please contact Oracle Customer Support. III. TRYING TO ONLINE A DATAFILE OR TABLESPACE ********************************************** 1. Recover the datafile: SVRMGRL> RECOVER DATAFILE ''; If recovering a tablespace, do SVRMGRL> RECOVER TABLESPACE ; If recovering a database, do SVRMGRL> RECOVER DATABASE; 2. Confirm each of the archived logs that you are prompted for until you receive the message "Media recovery complete". If you are prompted for an archived log that does not exist, Oracle probably needs one or more of the online logs to proceed with the recovery. Compare the sequence number referenced in the ORA-280 message with the sequence numbers of your online logs. Then enter the full path name of one of the members of the redo group whose sequence number matches the one you are being asked for. 3. Open the database. SVRMGR> ALTER DATABASE OPEN; IV. WHEN RECOVERING ' USING BACKUP CONTROLFILE' OPTION TO DO INCOMPLETE RECOVERY ******************************************************************************* If the database is recovered with the "RECOVER DATABASE USING BACKUP CONTROLFILE;" option without specifying the "UNTIL CANCEL" option, then upon "ALTER DATABASE OPEN RESETLOGS;" you will encounter the ORA-1113 error. Steps to workaround this issue: 1. Recover database again using: SVRMGR> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL; 2. Cancel recovery by issuing the "CANCEL" command. 3. Open the database using: SVRMGR> ALTER DATABASE OPEN RESETLOGS; Subject: Recover database after disk loss *** This article is being delivered in Draft form and may contain errors. Please use the MetaLink "Feedback" button to advise Oracle of any issues related to this article. *** PURPOSE ------- This article aims at walking you through some of the common recovery techniques after a disk failure SCOPE & APPLICATION ------------------- All Oracle support Analysts, DBAs and Consultants who have a role to play in recovering an Oracle database Loss due to Disk Failure ------------------------ What can we lose due to disk failure: A) Control files B) Redo log files C) Archivelog files D) Datafiles E) Parameter file or SPFILE F) Oracle software installation Detecting disk failure ----------------------- 1) Run copy utilities like "dd" on unix 2) If using RAID mechanisms like RAID 5, parity information may mask the disk failure and more vigorous check would be needed 3) As always, check the Operating system log files 4) Another obvious case would be when the disk could not be seen or mounted by the OS. 5) On the Oracle side, run dbverify if the file affected is a datafile 6) The best way to detect disk failure is by running Hardware diagnostic tools and OS specific disk utilities. Next Action ------------ Once the type of failure is identified, the next step is to rectify them. Options could be: (1) Replace the corrupted disk with a new one and mount them with the same name (say /oracle or D:\) (2) Replace the corrupted disk with a new one and mount them with a different name (say /oracle1 as the new mount point) (3) Decide to use another existing disk mounted with a different name (say /oracle2) The most common methods are (1) AND (3). Oracle Recovery --------------- Once the disk problem is sorted, the next step is to perform recovery at the Oracle level. This would depend on the type of files that is lost (see "Loss due to Disk Failure" section) and also on the type of disk recovery done as mentioned in the "Next Action" section above. (A) Control Files ------------------ Normally, we have multiplexing of controlfiles and they are expected to be placed in different disks. If one or more controlfile is/are lost,mount will fail as shown below: SQL> startup Oracle Instance started .... ORA-00205: error in identifying controlfile, check alert log for more info You can verify the controlfile copies using: SQL> select * from v$controlfile; **If atleast one copy of the controlfile is not affected by the disk failure, When the database is shutdown cleanly: (a) Copy a good copy of the controlfile to the missing location (b) Start the database Alternatively, remove the lost control file location specified in the init parameter control_files and start the database. **If all copies of the controlfile are lost due to the disk failure, then: Check for a backup controlfile. Backup controlfile is normally taken using either of the following commands: (a) SQL> alter database backup controlfile to '/backup/control.ctl'; -- This would have created a binary backup of the current controlfile -- -->If the backup was done in binary format as mentioned above, restore the file to the lost controlfile locations using OS copying utilities. --> SQL> startup mount; --> SQL> recover database using backup controlfile; --> SQL> alter database open; (b) SQL> alter database backup controlfile to trace; -- This would have created a readable trace file containing create controlfile script -- --> Edit the trace file created (check user_dump_dest for the location) and retain the SQL commands alone. Save this to a file say cr_ctrl.sql --> Run the script SQL> @cr_ctrl This would create the controlfile, recover database and open the database. ** If no copy of the controlfile or backup is available, then create a controlfile creation script using the datafile and redo log file information. Ensure that the file names are listed in the correct order as in FILE$. Then the steps would be similar to the one followed with cr_ctrl.sql script. Note that all controlfile related SQL maintenance operations are done in the database nomount state (B) Redo logs --------- In normal cases, we would not have backups of online redo log files. But the inactive logfile changes could already have been checkpointed on the datafiles and even archive log files may be available. SQL> startup mount Oracle Instance Started Database mounted ORA-00313: open failed for members of log group 1 of thread 1 ORA-00312: online log 1 thread 1: '/ORACLE/ORADATA/H817/REDO01.LOG' ORA-27041: unable to open file OSD-04002: unable to open file O/S-Error: (OS 2) The system cannot find the file specified. ** Verify if the lost redolog file is Current or not. SQL> select * from v$log; SQL> select * from v$logfile; --> If the lost redo log is an Inactive logfile, you can clear the logfile: SQL> alter database clear logfile '/ORACLE/ORADATA/H817/REDO01.LOG'; Alternatively, you can drop the logfile if you have atleast two other logfiles: SQL> alter database drop logfile group 1; --> If the logfile is the Current logfile, then do the following: SQL> recover database until cancel; Type Cancel when prompted SQL>alter database open resetlogs; The 'recover database until cancel' command can fail with the following errors: ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below ORA-01194: file 1 needs more recovery to be consistent ORA-01110: data file 1: '/ORACLE/ORADATA/H817/SYSTEM01.DBF' In this case , restore an old backup of the database files and apply the archive logs to perform incomplete recovery. --> restore old backup SQL> startup mount SQL> recover database until cancel using backup controlfile; SQL> alter database open resetlogs; If the database is in noarchivelog mode and if ORA-1547, ORA-1194 and ORA-1110 errors occur, then you would have restore from an old backup and start the database. Note that all redo log maintenance operations are done in the database mount state (C) Archive logs ----------------- If the previous archive log files alone have been lost, then there is not much to panic. ** Backup the current database files using hot or cold backup which would ensure that you would not need the missing archive logs (D) Datafiles -------------- This obviously is the biggest loss. (1) If only a few sectors are damaged, then you would get ora-1578 when accessing those blocks. --> Identify the object name and type whose block is corrupted by querying dba_extents --> Based on the object type, perform appropriate recovery --> Check metalink Note 28814.1 for resolving this error (2) If the entire disk is lost, then one or more datafiles may need to be recovered . SQL> startup ORACLE instance started. ... Database mounted. ORA-01157: cannot identify/lock data file 3 - see DBWR trace file ORA-01110: data file 3: '/ORACLE/ORADATA/H817/USERS01.DBF' Other possible errors are ORA-00376 and ORA-1113 The views and queries to identify the datafiles would be: SQL> select file#,name,status from v$datafile; SQL> select file#,online,error from v$recover_file; ** If restoring to a replaced disk mounted with the same name, then : (1) Restore the affected datafile(s) using OS copy/restore commands from the previous backup (2) Perform recovery based on the type of datafile affected namely SYSTEM, ROLLBACK or UNDO, TEMP , DATA or INDEX. (3) The recover commands could be 'recover database', 'recover tablespace' or 'recover datafile' based on the loss and the database state ** If restoring to a different mount point, then : (1) Restore the files to the new location from a previous backup (2) SQL> STARTUP MOUNT (3) SQL> alter database rename file '/old path_name' to 'new path_name'; -- Do this renaming for all datafiles affected. -- (4) Perform recovery based on the type of datafile affected namely SYSTEM, ROLLBACK or UNDO, TEMP , DATA or INDEX. (5) The recover commands could be 'recover database', 'recover tablespace' or 'recover datafile' based on the loss and the database state The detailed steps of recovery based on the datafile lost and the Oracle error are outlined in the following articles : Note 184327.1 Note 198640.1 Note 183327.1 Note 183367.1 NOARCHIVELOG DATABASE ===================== The loss mentioned in (A),(B) and (D) would be different in this case wherever archive logs are involved. We will discuss the datafile loss scenarios here: (a) If the datafile lost is a SYSTEM datafile, restore the complete database from the previous backup and start the database. (b) If the datafile lost is Rollback related datafile with active transactions, restore from the previous backup and start the database. (c) If the datafile contains rollback with no active rollback segments, you can offline the datafile (after commenting the rollback_segments parameter assuming that they are private rollback segments) and open the database. (d) If the datafile is temporary, offline the datafile and open the database. Drop the tablespace and recreate the tablespace. (e) If the datafile is DATA or INDEX, **Offline the tablespace and start the database. **If you have a previous backup, restore it to a separate location. **Then export the objects in the affected tablespace ( using User or table level export). **Create the tablespace in the original database. **Import the objects exported above. If the database is 8i or above, you can also use Transportable tablespace feature. (E) Parameter file --------------- This is not a major loss and can be easily restored. Options are: (1) If there is a backup, restore the file (2) If there is no backup, copy sample file or create a new file and add the required parameters. Ensure that the parameters db_name, control_files, db_block_size, compatible are set correctly (3) If the spfile is lost, you can create it from the init parameter file (F) Oracle Software Installation ---------------------------- There are two ways to recover from this scenario: (1) If there is a backup of the Oracle home and Oracle Inventory, restore them to the respective directories. Note if you change the Oracle Home, the inventory would not be aware of thid new path and you would not be able to apply patchsets. Also restore to the same OS user and group. (2) Perform a fresh Install PRACTICAL SCENARIO ================== In most cases, when a disk is lost, more than one type of file could be lost. The recovery in this scenario would be: (1) A combination of each of these data loss recovery scenarios (2) Perform entire database restore from the last backup and apply archive logs to perform recovery. This is a highly preferred method but could be time consuming.
adidas eqt support adv
ReplyDeletekobe 11
timberland shoes
true religion
air jordan 11
adidas neo online shop
yeezy sneakers
kyrie 3
cheap jordan shoes
baseball jerseys