Chapter 12 Performing Incomplete Recovery. Background Viewed as one of the more difficult chapters...

Post on 22-Dec-2015

216 views 0 download

Tags:

Transcript of Chapter 12 Performing Incomplete Recovery. Background Viewed as one of the more difficult chapters...

Chapter 12Performing Incomplete Recovery

Background

Viewed as one of the more difficult chapters to write

Thought it was important to put in material such as restoring to a previous incarnation and restoring a subset of datafiles

Debated on how much information to put in on TSPITR, decided to go with one automated example

Incomplete Recovery

Incomplete recovery in Oracle means that you do not recover all transactions that were committed at the time of the failure

Usually performed because you don’t have all redo required to perform complete recovery

Also performed sometimes on purpose due to a user error (like erroneously deleted data)

Three Methods for Initiating Incomplete Recovery Using RMAN

restore database until restore tablespace until flashback database

Restore database until is the main focus of this chapter

Four Types of RMAN Incomplete Recovery Commands

Time Change (sometimes called system change

number [SCN]) Log sequence number Restore point (Oracle Database 10g Release

2 and newer versions)

Determining the Type of Incomplete Recovery to Perform

You know approximately what time you want to stop the recovery

You know the particular log file for which you want to stop the recovery process You know the SCN at which you want to end the recovery

process You want to restore to a defined restore point You want to restore one tablespace to a point in time You want to restore and recover a subset of your database’s

datafiles You have enabled the flashback database feature and want to

flashback your database.

Consider Alternatives to Incomplete Recovery

Flashback drop Flashback table or Flashback query to restore and recover an

erroneously dropped table or deleted data

Performing Time Based Incomplete Recovery

Specify the time as part of the restore and recover commands

Use the set until time command, and then issue unqualified restore and recover commands

Performing Time Based Incomplete Recovery

connect target /RMAN> startup mount;RMAN> run{RMAN> set until time "to_date('05-oct-2006 14:00:00',

'dd-mon-rrrr hh24:mi:ss')";RMAN> restore database;RMAN> recover database;RMAN> }RMAN> alter database open resetlogs;

Performing Log Sequenced Based Incomplete Recovery

connect target /RMAN> startup mount;RMAN> restore database until sequence 50;RMAN> recover database until sequence 50;RMAN> alter database open resetlogs;

Do you have to open the database with resetlogs?

Performing Log Sequenced Based Recovery

RMAN> connect target /

RMAN> startup mount;

RMAN> run{

2> set until sequence 125 thread 1;

3> restore database;

4> recover database;

5> }

RMAN> alter database open resetlogs;

Performing Cancel Based Recovery

Use RMAN to restore datafiles Get out of RMAN to perform the recovery

portion, use SQL*Plus Why would a DBA want to use SQL*Plus

instead of RMAN? Very similar to log sequence based recovery

Performing Cancel Based Recovery

RMAN> connect target /RMAN> startup mount;RMAN> restore database; # restore database from last

backup Once your database is restored, you can start a

SQL*Plus session and initiate a cancel based recovery, as shown here:

SQL> connect / as sysdbaSQL> recover database until cancel;

Using Log-Miner to find an SCN

1. Specify a set of archived redo log files for LogMiner to analyze.

2. Start LogMiner, and specify a data dictionary.

3. Perform analysis.

4. Stop the LogMiner session.

Performing Change or SCN Based Recovery

RMAN> connect target /

RMAN> startup mount;

RMAN> restore database until scn 950;

RMAN> recover database until scn 950;

RMAN> alter database open resetlogs;

Performing Change or SCN Based Recovery

RMAN> connect target /

RMAN> startup mount;

RMAN> run{

2> set until scn 950;

3> restore database;

4> recover database;

5> }

RMAN> alter database open resetlogs;

Recovering to a Restore Point

New feature with Oracle Database 10g or higher

RMAN> connect target /

RMAN> startup mount;

RMAN> restore database until restore point MY_RP;

RMAN> recover database until restore point MY_RP;

RMAN> alter database open resetlogs;

Restoring a Non-Archivelog Mode Database

You can use RMAN to backup up a non-archivelog mode database

Database must be in mount mode when backing up a non-archivelog mode database

You can use that backup to restore the database back to the point in time that it was backed up

There is no roll forward because there are no archive redo logs to apply

Restoring a Non-Archive redo log database

RMAN> connect target /

RMAN> startup nomount;

RMAN> restore controlfile from autobackup;

RMAN> alter database mount;

RMAN> restore database;

RMAN> alter database open resetlogs;

Recovering to a Previous Incarnation

In 9i and lower, this used to be a difficult task Oracle Support would often be called for

assistance When a database is opened with the

resetlogs command, a new incarnation of the database is created

What if you want to restore to a point prior to a resetlogs?

Restoring and Recovering to a Previous Incarnation of the Database

RMAN> connect target /RMAN> startup nomount;RMAN> restore controlfile from autobackup

until time2> "to_date('03-sep-2006 00:00:00', 'dd-mon-

rrrr hh24:mi:ss')";RMAN> alter database mount;RMAN> list incarnation of database;

Restoring and Recovering to a Previous Incarnation of the Database

RMAN> restore database until time2> "to_date('03-sep-2006 00:00:00', 'dd-mon-rrrr

hh24:mi:ss')";RMAN> recover database until time2> "to_date('03-sep-2006 00:00:00', 'dd-mon-rrrr

hh24:mi:ss')";RMAN> alter database open resetlogs;

Note: page 376, that should say “resetlogs” one word not “reset logs”

Performing Tablespace Point in Time Recovery

1. Determine and resolve any dependencies to objects in tablespaces not included in the TSPITR

2. Determine whether there are objects that will not be recovered

3. Create a destination on disk to temporarily hold the auxiliary database

4. Run the recover tablespace until command

5. Back up the restored tablespace and alter it online

RMAN Automates TSPITR

1. Creates an auxiliary instance, starts it, and connects to it2. Takes offline tablespaces that are involved with TSPITR3. Restores the backup control file that corresponds to the target restore time4. Restores datafiles to a destination specified by your AUXILIARY DESTINATION5. Recovers restored datafiles in an auxiliary location6. Opens an auxiliary database with the open resetlogs command7. Exports the auxiliary data dictionary metadata about recovered tablespaces and

shuts down the auxiliary database8. Issues a switch command on the target database to update the control file to

point at the recovered auxiliary datafiles9. Imports objects associated with recovered tablespaces into the target database10. Deletes the auxiliary datafiles

Recovering a Subset of Datafiles

What if you only want to perform an incomplete recovery on a subset of datafiles?

When performing incomplete recovery, you must perform recovery on all online datafiles

Any datafiles that you don’t want to recover must be taken offline first

Incomplete Recovery on a Subset of Datafiles

RMAN> connect target /

RMAN> startup mount;

RMAN> sql 'alter database datafile 7, 8, 9 offline for drop';

RMAN> restore database until SCN 314159;

RMAN> recover database until SCN 314159;

RMAN> alter database open resetlogs;

Troubleshooting Incomplete Recovery

Ensure you follow the correct sequence of events

Ensure the same point is used

1. restore database until <specified point>;

2. recover database until <specified point>;

3. alter database open resetlogs;

Ensure Datafile SCNs are Aligned

select file#, status, checkpoint_change#,

to_char(checkpoint_time,'dd-mon-rrrrhh24:mi:ss')

from v$datafile_header;