Oracle, Life, etc.

Oracle, Life, etc.

Chapter 27 – Incomplete Database Recovery

Complete Recovery

  • Assuming backups of the datafiles, copies of all necessary archive logs, online redo logs and the controlfile are available; the db can suffer any damage to the datafiles without losing any data:
  • Complete Recovery:
    • Take damaged datafiles offline
    • Restore damaged datafiles
    • Recover damaged datafiles
    • Bring recovered datafiles online
  • Syntax:
    • alter tablespace users offline immediate; (immediate is used because the tablespace is damaged and the DBWn will try to write dirty blocks to disk [aka checkpoint the tablespace], which may fail)
    • restore tablespace users;
    • recover tablespace users delete archivelog; (delete archivelog refers to the deletion of the restored logs after they are applied. recovery may also use online log files.)
    • alter tablespace users online;
  • Complete recovery can be done with the database OPEN unless the SYSTEM or UNDO tablespaces are damaged (this will terminate the instance).

When is Incomplete Recovery Necessary?

  • Incomplete recovery means losing data on purpose. It occurs when complete recovery is impossible or you want to lose some information that was entered by mistake.
  • It is not possible to skip the recovery of a bad transaction and recover all other work.
  • There are cases where incomplete recovery won’t be possible with the current controlfile:
    • All copies of the controlfile are lost (and it is not possible to recover with a CREATE CONTROLFILE command)
    • The current controlfile does not accurately describe the database that needs to be restored (typically due to dropped tablespaces)
  • The syntax for recovery using a backup controlfile includes the UNTIL keyword even if the recovery is complete.
  • All datafiles except temporary tablespaces are restored. Undo tablespaces are restored.

The Method for Incomplete Recovery

  • It is often a good idea to perform a complete offline backup before beginning an incomplete recovery to ensure no loss of data.
  • Steps to incomplete recovery:
    • Mount the database
    • Restore all datafiles (they don’t need to be from same backupset / time), and controlfile if necessary
    • Recover the database UNTIL time, cancel or change number
    • OPEN with RESETLOGS
  • OPEN with RESETLOGS initializes the online redo files creating a new incarnation of the database. An incarnation of a database has a new thread of redo, beginning at log switch sequence number 1.
  • Backups and archivelogs are specific to an incarnation and therefore those generated by one incarnation must be kept separate from those generated by a previous incarnation.
  • Only SYSDBA can perform incomplete recoveries

UNTIL TIME Recovery

  • SQL> shutdown immediate;
  • SQL> startup mount;
  • —No restore b/c OS or other means are used to restore necessary files—
  • SQL> recover database UNTIL TIME '2006-08-15:14:07:00'
    • The time format must be in the format YYYY-MM-DD:HH24:MM:SS irrespective of NLS_DATE_FORMAT
  • SQL> alter database open resetlogs;
  • —–ALTERNATIVE in RMAN—–
  • RMAN> run {
  • RMAN> shutdown immediate;
  • RMAN> startup mount;
  • RMAN> sql "alter session set nls_date_format=''dd-mon-yyyy hh24:mi:ss''";
  • RMAN> set until time '15-aug-2006 14:11:00';
  • RMAN> restore database;
  • RMAN> recover database;
  • RMAN> alter database open resetlogs;}

UNTIL CANCEL / UNTIL SEQUENCE (RMAN) Recovery

  • Cancel-based recovery is typically needed after complete recovery has failed: the recovery required an archive or online log that was missing.
  • SQL> shutdown immediate;
  • SQL> startup mount;
  • —No restore b/c OS or other means are used to restore necessary files—
  • SQL> recover database UNTIL CANCEL;
  • SQL> alter database open resetlogs;
  • —–ALTERNATIVE in RMAN—–
  • RMAN> run {
  • RMAN> shutdown immediate;
  • RMAN> startup mount;
  • RMAN> set until sequence 10305 thread 1;
  • RMAN> restore database;
  • RMAN> recover database;
  • RMAN> alter database open resetlogs;}

UNTIL CHANGE / UNTIL SCN Recovery

  • SQL> shutdown immediate;
  • SQL> startup mount;
  • —No restore b/c OS or other means are used to restore necessary files—
  • SQL> recover database UNTIL CHANGE 309121;
  • SQL> alter database open resetlogs;
  • —–ALTERNATIVE in RMAN—–
  • RMAN> run {
  • RMAN> shutdown immediate;
  • RMAN> startup mount;
  • RMAN> set until scn 309121;
  • RMAN> restore database;
  • RMAN> recover database;
  • RMAN> alter database open resetlogs;}

Incomplete Recovery Using EM

  • Maintenance -> Perform Recovery

Recovery of the Controlfile

  • SQL> alter database backup controlfile to trace
    • USER_DUMP_DEST will determine where trace file is created
  • You should always create a trace file whenever you make physical changes to the structure of the database.
  • SQL> alter database backup controlfile to ‘<filename>’

Restore a Controlfile with SQL*Plus

  • startup mount;
  • SQL> recover database until cancel using backup controlfile;

Backup / Restore a Controlfile with RMAN

  • RMAN> backup as copy current controlfile;
  • RMAN> backup as backupset current controlfile;
  • RMAN> backup tablespace system include current controlfile;
  • RMAN> configure controlfile autobackup on;
  • RMAN> restore controlfile from autobackup;

Parameters

  • USER_DUMP_DEST
  • CONTROL_FILES

Advertisement

4 Responses to Chapter 27 – Incomplete Database Recovery

  1. theonmefe December 5, 2007 at 9:32 pm

    To begin with, that I am not a problem-one on my set of problems, which developed as a result of depression and I can never escape from it, precisely vybirayus for a couple of days and then she returns …
    … laugh, I have a child, almost two old. VERY difficult child, from birth has gipervozbudimostyu (most likely because of the small generic trauma, neurology). I love VERY her baby, and fanatically madly, BUT … since she was born, my life has become a nightmare. My life, full of freedom, has ended. Maybe I was not ready for this, I do not represent that of a child may be difficult NASTOLKO. Typically, children godiku to become more calm, but my daughter all of these 2-year daily from morning until night nerves treplet me – it applies to a day, vizzhit, screaming, crying and zakatyvaet siteriki on any issue and without … I slvshaniya standing and waiting her pony vizgov became hysterical woman probably just nerves or to a feature … I am constantly opdavlennoe mood .. I began to suffer from insomnia, about 3-4 nights straight, but woke with such feeling, and that is not asleep (although we prosypaemsya in 11). Woke with a patient’s head, depressed and with the understanding that a new day of nothing but
    yelling and Hysterical not bring my child ……… Even when docha not crying and behaves jail (sometimes), I still suppressed …
    In fact that 8 months ago I dispersed with her husband, simple ovystavila him for the door … it was impossible to live together, the permanent zadvigi were inexcusable … but despite all this, I very much miss it, and one very seriously. mom helps, live together now, but still serious …
    All the time feel loneliness, I need a man to life, but I can not find anyone yet, as I am emotionally drained and in a form with someone familiar unrealistic … everything seemed to me a monster …
    this move as a black stripe??

    P.S. Please administrator mnsinger.wordpress.com. If the thread is not to be in category this, I ask you to move my thread to the correct category.

  2. Hierniliamall October 30, 2008 at 9:13 pm

    Think about it… I want everyone to know about my prickly stone Wanna joke?) What did one worm say to another worm? I know a restaurant where we can eat dirt cheap!!

  3. Pingback: SEO

  4. Dinesh Chandra January 10, 2012 at 4:14 am

    great , really so nice

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.