Sei sulla pagina 1di 3

Database Recovery -1-

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.

alter database set fast_start_mttr_target = 600;


set MTTR
Note: the value is in seconds
Display current MTTR select recovery_ios, estimated_mttr, target_mttr from v$instance_recovery;
Other useful system parameters
log buffers are written to disk within this target can have big impact on
performance if to low (default is zero and maximum is 3600 secs – 1 hour)
LOG_CHECKPOINT_TIMEOUT
alter system set fast_start_mttr_target=60 scope=both; (no restart required)
maximum number of seconds that any new or modified block in the buffer cache
FAST_START_IO_TARGET
waits until it is written to disk (overrides fast_start_mttr_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

Block Media Recovery

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-

I have broken down recovery techinques into different key area's

• 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.

Complete Database Recovery

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-

1. Open in mount mode


2. restore the data files (Netbackup or ufsrestore)
3. recover the database
User-Managed
sql> recover database;
4. Open the database
sql> alter database open;
OEM see oracle manual

Recovering non-critical files

see recovering non-critical files for more details

Recovering critical files

see recovering critical files for more details

Incomplete Database Recovery

see incomplete database recovery for more details

Recovering from User Errors

see recovering from user errors for more details

Flashback

see flashback for more details

Potrebbero piacerti anche