• No results found

Database Recovery For Newbies

N/A
N/A
Protected

Academic year: 2021

Share "Database Recovery For Newbies"

Copied!
29
0
0

Loading.... (view fulltext now)

Full text

(1)

Database

Recovery For

Newbies

Paper #521

Database

Recovery For

Newbies

Paper #521

Bonnie Bizzaro, Susan McClain Bonnie Bizzaro, Susan McClain

(2)

Objectives

Objectives

ƒ Provide basic understanding of recovery processes and terms

ƒ Define different types of recovery

ƒ Discuss common recovery strategies ƒ Demo of Recovery Manager (RMAN)

ƒ Provide basic understanding of recovery processes and terms

ƒ Define different types of recovery

ƒ Discuss common recovery strategies ƒ Demo of Recovery Manager (RMAN)

(3)

Basic Recovery Types

Basic Recovery Types

ƒ Instance recovery ƒ Media recovery ƒ Data recovery ƒ Disaster recovery ƒ Instance recovery ƒ Media recovery ƒ Data recovery ƒ Disaster recovery

(4)

Basic Recovery Terms

Basic Recovery Terms

ƒ Data block

ƒ Data file

ƒ Tablespace

ƒ System change number (SCN)

ƒ Data block ƒ Data file

ƒ Tablespace

(5)

Basic Recovery Terms, cont’d

Basic Recovery Terms, cont’d

ƒ Rollback segment / Undo segment

ƒ Online redo log ƒ Archive redo log

ƒ (No)Archivelog mode ƒ Offline backup

ƒ Online backup

ƒ Rollback segment / Undo segment ƒ Online redo log

ƒ Archive redo log

ƒ (No)Archivelog mode ƒ Offline backup

(6)

ƒ What is instance recovery ƒ When database crashes

ƒ Automatically brings to consistent state ƒ Should shutdown/restart database before

resuming normal activity

ƒ What is instance recovery ƒ When database crashes

ƒ Automatically brings to consistent state ƒ Should shutdown/restart database before

resuming normal activity

Instance Recovery

(7)

Instance Recovery, cont’d

Instance Recovery, cont’d

Entries in the alert log

Entries in the alert log Database mounted in Exclusive Mode.

Completed: alter database mount Sun Feb 23 05:50:20 2003

alter database open

Beginning crash recovery of 1 threads Sun Feb 23 05:50:24 2003

Thread recovery: start rolling forward thread 1

Recovery of Online Redo Log: Thread 1 Group 2 Seq 35417 Reading mem 0 Mem# 0 errs 0: u05/oradata/LPROD/redoLPROD2.log

Sun Feb 23 05:50:27 2003

Thread recovery: finish rolling forward thread 1

Thread recovery: 241 data blocks read, 241 data blocks written, 3771 redo blocks read

Crash recovery completed successfully

Database mounted in Exclusive Mode. Completed: alter database mount

Sun Feb 23 05:50:20 2003 alter database open

Beginning crash recovery of 1 threads Sun Feb 23 05:50:24 2003

Thread recovery: start rolling forward thread 1

Recovery of Online Redo Log: Thread 1 Group 2 Seq 35417 Reading mem 0 Mem# 0 errs 0: u05/oradata/LPROD/redoLPROD2.log

Sun Feb 23 05:50:27 2003

Thread recovery: finish rolling forward thread 1

Thread recovery: 241 data blocks read, 241 data blocks written, 3771 redo blocks read

(8)

Media Recovery

Media Recovery

ƒ What is Media recovery

– physical components of the database

ƒ What is Media recovery

(9)

Media Recovery, cont’d

Media Recovery, cont’d

ƒ Common causes of media loss or failure ƒ Lost or corrupted data file strategies

ƒ Lost or corrupt control file strategies

ƒ Complete or incomplete recovery strategies

ƒ Common causes of media loss or failure ƒ Lost or corrupted data file strategies

ƒ Lost or corrupt control file strategies

(10)

Lost or Corrupted Data File

Lost or Corrupted Data File

For non-system tablespace

ƒ Offline the object

– Alter tablespace xxxx offline;

– Alter database datafile ‘/u01/oradata/xxxxx’ offline;

ƒ Restore the file from backup ƒ Execute recover command

– Recover tablespace xxxx;

– Recover datafile ‘/u01/oradata/xxxxx’; ƒ Offline the object

– Alter tablespace xxxx offline;

– Alter database datafile ‘/u01/oradata/xxxxx’ offline;

ƒ Restore the file from backup ƒ Execute recover command

– Recover tablespace xxxx;

– Recover datafile ‘/u01/oradata/xxxxx’;

(11)

Lost or Corrupted Data File

Lost or Corrupted Data File

For non-system tablespace, cont’d ƒ Apply archive logs if prompted

ƒ Online the object

– Alter tablespace xxxx online;

– Alter database datafile ‘/u01/oradata/xxxxx’ online;

ƒ Verify recovery

– Select name,status from v$datafile;

• Status should be ONLINE

ƒ Apply archive logs if prompted ƒ Online the object

– Alter tablespace xxxx online;

– Alter database datafile ‘/u01/oradata/xxxxx’ online;

ƒ Verify recovery

– Select name,status from v$datafile;

• Status should be ONLINE

(12)

Lost or Corrupted Data File

Lost or Corrupted Data File

For system tablespace

ƒ Shutdown database

ƒ Restore the file from backup

ƒ Start the database in mounted state

– Startup mount;

ƒ Execute recover command

– Recover database;

ƒ Apply logs if prompted ƒ Open database

– Alter database open;

ƒ Shutdown database

ƒ Restore the file from backup

ƒ Start the database in mounted state

– Startup mount;

ƒ Execute recover command

– Recover database;

ƒ Apply logs if prompted ƒ Open database

– Alter database open;

(13)

Lost or Corrupted Data File

Lost or Corrupted Data File

No archivelog mode

ƒ Shutdown database, do a backup

ƒ Restore all files from previous offline backup

– Restore control file from the same backup

ƒ Startup database

ƒ If you don’t have a copy of your control file from the previous offline backup

– Startup mount;

– Alter database open resetlogs; – Immediately do a backup

ƒ Shutdown database, do a backup

ƒ Restore all files from previous offline backup

– Restore control file from the same backup

ƒ Startup database

ƒ If you don’t have a copy of your control file from the previous offline backup

– Startup mount;

– Alter database open resetlogs; – Immediately do a backup

(14)

Lost or Corrupted Control File

Lost or Corrupted Control File

ƒ Shutdown database

ƒ If control files multiplexed

– Copy a good control file over corrupted one – Restart database

ƒ If all copies of control file are gone

– Use backup controlfile script – Restart database

– Backup database ƒ Shutdown database

ƒ If control files multiplexed

– Copy a good control file over corrupted one – Restart database

ƒ If all copies of control file are gone

– Use backup controlfile script – Restart database

(15)

Lost or Corrupted Control File

Lost or Corrupted Control File

STARTUP NOMOUNT

CREATE CONTROLFILE REUSE DATABASE "LPROD" NORESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 2 MAXDATAFILES 800 MAXINSTANCES 1 MAXLOGHISTORY 2726 LOGFILE

GROUP 1 '/u06/oradata/LPROD/redoLPROD01.log' SIZE 80M, GROUP 2 '/u05/oradata/LPROD/redoLPROD2.log' SIZE 80M DATAFILE ‘/u06/oradata/LPROD/system01.dbf’, ‘/u06/oradata/LPROD/rbs101.dbf’, ‘/u01/oradata/LPROD/temp01.dbf’, ‘/u01/oradata/LPROD/tools01.dbf’, STARTUP NOMOUNT

CREATE CONTROLFILE REUSE DATABASE "LPROD" NORESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 2 MAXDATAFILES 800 MAXINSTANCES 1 MAXLOGHISTORY 2726 LOGFILE

GROUP 1 '/u06/oradata/LPROD/redoLPROD01.log' SIZE 80M, GROUP 2 '/u05/oradata/LPROD/redoLPROD2.log' SIZE 80M DATAFILE

‘/u06/oradata/LPROD/system01.dbf’, ‘/u06/oradata/LPROD/rbs101.dbf’, ‘/u01/oradata/LPROD/temp01.dbf’, ‘/u01/oradata/LPROD/tools01.dbf’,

Alter database backup controlfile to trace; Alter database backup controlfile to trace;

(16)

Lost or Corrupted Control File

Lost or Corrupted Control File

. .

# Recovery is required if any of the datafiles are restored backups, # or if the last shutdown was not normal or immediate.

RECOVER DATABASE

# All logs need archiving and a log switch is needed. ALTER SYSTEM ARCHIVE LOG ALL;

# Database can now be opened normally. ALTER DATABASE OPEN;

. .

# Recovery is required if any of the datafiles are restored backups, # or if the last shutdown was not normal or immediate.

RECOVER DATABASE

# All logs need archiving and a log switch is needed. ALTER SYSTEM ARCHIVE LOG ALL;

# Database can now be opened normally. ALTER DATABASE OPEN;

cont’d cont’d

Alter database backup controlfile to trace;, Alter database backup controlfile to trace;,

(17)

Incomplete Recovery

Incomplete Recovery

ƒ Common scenarios

ƒ Database point in time recovery ƒ Tablespace point in time recovery ƒ Recover until cancel

ƒ Recover until change (SCN)

ƒ Common scenarios

ƒ Database point in time recovery ƒ Tablespace point in time recovery ƒ Recover until cancel

(18)

Database Point In Time

Recovery

Database Point In Time

Recovery

ƒ Shutdown database

ƒ Restore all datafiles from previous backup

ƒ Verify archive logs are available

ƒ Startup database in mounted state

– Startup mount ;

ƒ Shutdown database

ƒ Restore all datafiles from previous backup

ƒ Verify archive logs are available

ƒ Startup database in mounted state

(19)

Database Point In Time

Recovery, cont’d

Database Point In Time

Recovery, cont’d

ƒ Execute recovery command

– Recover database until time ‘2002-12-28:10:38:00’;

Or,

Recover database until cancel;

ƒ Open database and resetlogs

– Alter database open resetlogs;

ƒ Backup database

ƒ Execute recovery command

– Recover database until time ‘2002-12-28:10:38:00’;

Or,

Recover database until cancel;

ƒ Open database and resetlogs

– Alter database open resetlogs;

(20)

Data Recovery

Data Recovery

ƒ Using export/import

ƒ Partial database recovery, then export ƒ Transportable tablespace

ƒ Logminer

ƒ Using export/import

ƒ Partial database recovery, then export ƒ Transportable tablespace

(21)

Disaster Recovery

Disaster Recovery

ƒ Loss of – Server – Data center – Building

ƒ If different OS on DR server, use import

– Verify Oracle version – Create shell database – Import full database

– Restore your initSID.ora ƒ Loss of

– Server

– Data center – Building

ƒ If different OS on DR server, use import

– Verify Oracle version – Create shell database – Import full database

(22)

Disaster Recovery, cont’d

Disaster Recovery, cont’d

ƒ If same OS on DR server, restore files

from hot/cold backup

– Restore files using original paths – Rename files in mounted state – Restore initSID.ora file

– Startup database, recover

ƒ Standby database

ƒ Have a plan and test it!

ƒ If same OS on DR server, restore files from hot/cold backup

– Restore files using original paths – Rename files in mounted state – Restore initSID.ora file

– Startup database, recover

ƒ Standby database

(23)

Server Managed Recovery

RMAN Overview

Server Managed Recovery

RMAN Overview

ƒ Uses Oracle’s server processes ƒ Scripts are found in

$ORACLE_HOME/bin ƒ Target database

ƒ Repository

ƒ Media Manager

ƒ Channels / Disk Devices

ƒ Uses Oracle’s server processes ƒ Scripts are found in

$ORACLE_HOME/bin ƒ Target database

ƒ Repository

ƒ Media Manager

(24)

RMAN Overview

Repository Setup

RMAN Overview

Repository Setup

ƒ Create repository owner ƒ Grant

RECOVERY_CATALOG_OWNER role ƒ Connect to the repository and ‘create

catalog’

ƒ Connect to target (needs SYSDBA role) and register the database

ƒ Create repository owner ƒ Grant

RECOVERY_CATALOG_OWNER role ƒ Connect to the repository and ‘create

catalog’

ƒ Connect to target (needs SYSDBA role) and register the database

(25)

RMAN DEMO

RMAN DEMO

Susan McClain, Alliance Data Systems

(26)

Final Notes

Final Notes

ƒ Keep users out of your database while recovering

– Startup restrict

ƒ Backup your database before starting a recovery

– If you think it can’t get any worse, trust me, it can

ƒ Analyze all alternatives before you begin ƒ Successful recoveries require successful

backups.

– Make sure you have data files, controlfiles,

initSID.ora, archive logs, redo logs (hot backups)

ƒ Keep users out of your database while recovering

– Startup restrict

ƒ Backup your database before starting a recovery

– If you think it can’t get any worse, trust me, it can

ƒ Analyze all alternatives before you begin ƒ Successful recoveries require successful

backups.

– Make sure you have data files, controlfiles,

(27)

Final Notes

Final Notes

ƒ The best recovery is no recovery

– Multiplex control files – Multiplex redo logs

– Have appropriate OS and database security

ƒ TEST YOUR RECOVERY PLAN REGULARLY !

ƒ If you can’t recover your database

– Select * from v$my_resume;

ƒ The best recovery is no recovery

– Multiplex control files – Multiplex redo logs

– Have appropriate OS and database security

ƒ TEST YOUR RECOVERY PLAN REGULARLY !

ƒ If you can’t recover your database

(28)

Q & A

Q & A

Paper #521

(29)

Database Recovery for Newbies

Database Recovery for Newbies

Paper #521

Bonnie J. Bizzaro

Lead Database Administrator Alliance Data Systems

[email protected] Susan McClain

Systems Manager, Distributed Database Support Alliance Data Systems

Special thanks to Joe Testa, Data Management Consulting

Paper #521

Bonnie J. Bizzaro

Lead Database Administrator Alliance Data Systems

[email protected]

Susan McClain

Systems Manager, Distributed Database Support Alliance Data Systems

References

Related documents

for the sojourn time analysis, since they correspond to the distribution of the queue length and the phase of the background process right after the individual arrivals.. However,

• Simple nuclear effects are important for quasi elastic neutrino processes. • Provides a good anchor point

The purpose of this grounded theory study was to explore the experiences of adolescents and teachers and perceptions of parents regarding school-based sexuality education in

Savings Applied to Reduce Financial Hardship Apportionment on Future Project. Unapplied Savings Amount + Interest Returned to State After

Back up and recover a database using RMAN and Enterprise Manager Configure Oracle Database for optimal recovery for any environment Identify burdensome database sessions and

Back up and recover a database using RMAN and Enterprise Manager Configure Oracle Database for optimal recovery for any environment Identify burdensome database sessions and

h number of hops remaining in the message header bk number of bits of destination ID in the destination address sd social benefit to the owner of forwarding a message cf

Recent innovations in Western Australia’s approach to infrastructure planning and allocation include the introduction of a new Strategic Asset Management Framework (2005) and