Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Database recovery is a very complex topic, by practicing recovery techinques regularly will help when the real
thing happens everything should fall into place.
Oracle performs automatic recovery when an instance has crashed or been aborted (using shutdown abort).
Recovery involves a two step process
• roll-forward step - the database applies the committed and uncommitted data in the current online redo
log files to the current online datafiles
• roll-back step - the database removes the uncommitted transactions applied in the previous step using
the undo data in the undo segments
The recovery begins at a point in the redo logs know as thread checkpoint redo byte address. This is the time
when the last checkpoint was done before the crash. You can help in reducing the time recovery happens by
decreasing the time the checkpoint occurs thus reducing the amount of data that has to be recovered. By setting
the parameter fast_start_mttr_target (maximum is 3600 seconds - 1 hour) you can specify how long a recovery
should take, beware that this is only a target and oracle will try its best to meet this target, also decreasing this
threshold will probably impact the performance of the server. There are two other system parameters that can be
used to control when checkpointing occurs log_checkpoint_timeout and fast_start_io_target.
There are two types of recovery possible complete and incomplete recovery
• complete - means a recovery with no loss of data, all changes in the redo and archived redo logs are
reapplied.
• incomplete - implies data loss, because you restore only part of the data, this could be due to data
corruption and you wish only to restore to a point in time
If only a few blocks within a datafile are corrupted, you should consider block media recovery, this can be
performed via RMAN.
Database Recovery
Database Recovery -2-
• Complete recovery
• Recovering non-critical files (temporary tablespaces, redo log files index tablespaces read-only
tablespaces and password file)
• Recovering critical files (control file)
• Incomplete database recovery
• Recovering from user errors
• Flashback Database
• Flashback (flashback query, flashback table query, flashback version query and flashback transaction
query)
There is a table that can be used to identify files needing media recovery
V$RECOVERY_FILE reports missing or corrupted files, the table will identify the file and error.
Recovering a database can be done in three ways RMAN, traditional user-managed recovery (Netbackup,
ufsrestore) or Enterprise Manager.
rman> run {
allocate channel c1 type disk;
shutdown immediate;
startup mount;
restore database;
RMAN complete DB
recover database;
alter database open;
}
Note: you must be in mount mode, the redo logs will rollward the database during recovery
rman> run {
allocate channel c1 type disk;
alter tablespace data01 offline;
RMAN tablespace
restore tablespace data01;
recovery
recover tablespace data01;
alter tablespace online;
}
rman> run {
allocate channel c1 type disk;
sql "alter tablespace data01 offline";
RMAN datafile recovery restore datafile 'c:\oracle\data\data01.dbf';
recover datafile 'c:\oracle\data\data01.dbf';
sql "alter tablespace online";
}
Database Recovery -3-
Flashback