Harvard University Oracle Database Administration Session 11 Database Recovery.

Slides:



Advertisements
Similar presentations
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Backup and Recovery Copyright System Managers LLC 2008 all rights reserved.
Advertisements

Oracle Architecture. Instances and Databases (1/2)
ITEC474 Control File Maintenance
Backup and recovery Basics of Backup and restoration Types of recovery Defining strategy Starting up and shutting down 80/20 rule SLA’s.
Harvard University Oracle Database Administration Session 10 Database Backups.
5 Copyright © 2006, Oracle. All rights reserved. Database Recovery.
Advanced Databases DBA: Backups 1. Advanced Databases Agenda Define backup Discuss Backup Terminology Explain various backup and restore options in Oracle.
Database Backup and Recovery
INTRODUCTION TO ORACLE Lynnwood Brown President System Managers LLC Data Loading & Backup And Recovery Lecture 5 Copyright System Managers LLC 2003 all.
RMAN Restore and Recovery
Backup and Recovery (2) Oracle 10g CAP364 1 Hebah ElGibreen.
Backup and Recovery Part 1.
Chapter 12 Performing Incomplete Recovery. Background Viewed as one of the more difficult chapters to write Thought it was important to put in material.
ITEC474 Redo Log Files.
Chapter 5Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 5 User-Managed Incomplete Recovery.
Database Backup & Recovery David Konopnicki. Introduction A major responsibility of the database administrator is to prepare for the possibility of hardware,
CHAPTER 16 User-Managed Backup and Recovery. Introduction to User Managed Backup and Recovery Backup and recover is one of the most critical skills a.
CHAPTER 5 Managing Control Files, Online Redo Logs, and Archiving.
Oracle9i Database Administrator: Implementation and Administration
The Oracle Recovery Manager (RMAN)
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
Agenda  Overview  Configuring the database for basic Backup and Recovery  Backing up your database  Restore and Recovery Operations  Managing your.
Oracle backup and recovery strategy
Introduction to Oracle Backup and Recovery
Using RMAN to Perform Recovery
CHAPTER 16 User-Managed Backup and Recovery. Introduction to User Managed Backup and Recovery Backup and recover is one of the most critical skills a.
IS 4510 – Database Administration Module – 2 Database Backup 10/24/20141Compiled by: Zafar Iqbal Khan.
Backup & Recovery Concepts for Oracle Database
Oracle Database Administration
20 Copyright © 2004, Oracle. All rights reserved. Database Recovery.
13 Copyright © Oracle Corporation, All rights reserved. RMAN Complete Recovery.
5 Copyright © 2004, Oracle. All rights reserved. Using Recovery Manager.
Chapter 7 Making Backups with RMAN. Objectives Explain backup sets and image copies RMAN Backup modes’ Types of files backed up Backup destinations Specifying.
11 Copyright © Oracle Corporation, All rights reserved. RMAN Backups.
11 Copyright © Oracle Corporation, All rights reserved. RMAN Backups.
Backup & Recovery Backup and Recovery Strategies on Windows Server 2003.
16 Copyright © 2007, Oracle. All rights reserved. Performing Database Recovery.
7202ICT – Database Administration
Week 3 Lecture 1 The Redo Log Files and Diagnostic Files.
IT Database Administration Section 09. Backup and Recovery Backup: The available options Full Consistent (cold) Backup Database shutdown, all files.
8 Copyright © Oracle Corporation, All rights reserved. Configuring the Database Archiving Mode.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
Backup Concepts. Introduction Backup and recovery procedures protect your database against data loss and reconstruct the data, should loss occur. The.
3 Copyright © 2006, Oracle. All rights reserved. Using Recovery Manager.
10 Copyright © Oracle Corporation, All rights reserved. User-Managed Backups.
Configuring the Database Archiving Mode
Backup and Recovery Part 2. Online backup Online backup requirements: Backup all data files (file system copy) Backup all redo information produced during.
Overview of Oracle Backup and Recovery Darl Kuhn, Regis University.
12 Copyright © Oracle Corporation, All rights reserved. User-Managed Complete Recovery.
18 Copyright © 2004, Oracle. All rights reserved. Backup and Recovery Concepts.
6 Copyright © 2007, Oracle. All rights reserved. Performing User-Managed Backup and Recovery.
2 Copyright © 2007, Oracle. All rights reserved. Configuring for Recoverability.
16 Copyright © 2005, Oracle. All rights reserved. Performing Database Recovery.
8 Copyright © 2007, Oracle. All rights reserved. Using RMAN to Duplicate a Database.
18 Copyright © 2004, Oracle. All rights reserved. Recovery Concepts.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
9 Copyright © 2004, Oracle. All rights reserved. Incomplete Recovery.
14 Copyright © 2007, Oracle. All rights reserved. Backup and Recovery Concepts.
Copyright  Oracle Corporation, All rights reserved. 3 Oracle Backup and Recovery Configuration.
Control File Information The database name The timestamp of database creation The names and locations of associated datafiles and redo log files Tablespace.
Backup and Recovery.
Configuring the Database Archiving Mode
Maintaining Online Redo Log Files
Backup and Recovery (1) Oracle 10g Hebah ElGibreen CAP364.
Oracle9i Database Administrator: Implementation and Administration
Database Recovery.
Duplicating a Database
Performing User-Managed Backup and Recovery
Performing Database Recovery
Chapter 5 The Redo Log Files.
Presentation transcript:

Harvard University Oracle Database Administration Session 11 Database Recovery

Harvard University ArchiveLog Mode  Log_archive_dest = filename – Filename is /disk1/archive/arch  Log_archive_dest should not be on a raw device  Log_archive_format = extension – Extension includes %s, so that the log sequence number is part of the filename  Log_archive_format = %s.arc

Harvard University ArchiveLog Mode  The file will be named arch%s.arc  Example /disk1/archive/arch23005.arc  We can duplex the archive log files  Log_archive_duplex_dest = filename

Harvard University ArchiveLog Mode  After changing a database from noarchivelog mode to archivelog mode, take a backup of the database files and the control file  The previous backups are now unusable

Harvard University The Change Sequence  Shutdown immediate  Startup mount  Alter database archivelog;  Alter database open;  Shutdown immediate  Take a full backup

Harvard University The Change Sequence  In the init.ora set the log_archive_start = true, so that the database will startup in archivelog mode, automatically  You can set log_archive_max_processes = N if you want multiple archive processes, ARCn

Harvard University Recovery Process  Oracle performs recovery based on scn#  Two step Process – Roll Forward Redo files – Roll back Transaction recovery

Harvard University Failure Recovery  Media failure  User failure  Instance failure  Network failure  Process failure

Harvard University Failure Recovery  Each redo file has a low and high SCN  select * from v$log_history  Log switches – Alter system switch logfile  Checkpoints – Flushes modified data from cache to disk

Harvard University Database Startup Status  Nomount init.ora  Mount recover, alter database  Open database

Harvard University Noarchivelog Mode Recovery  When media failure occurs, a valid closed database backup must exist in order to recover  All Oracle files must be restored, even if only one data file is damaged or lost  Restore all data files, control files and redo logs

Harvard University Noarchivelog Mode Recovery  To recover a database that is in noarchivelog mode  Shutdown abort  Delete existing files  Recover all the files  Restart the instance  Inform users they need to re-enter data from the time of the last backup

Harvard University Recovery to a Different Location  To restore file(s) to a different location, if the original disk is unusable – Copy the file(s) to the new location  Mount the instance, use ‘startup mount’  alter database rename file ‘/u04/oradata/user_01.dbf’ to ‘/u05/oradata/user_01.dbf’;  This command updates the control file with the new file location

Harvard University Recovery to a Different Location  Make sure that there is a copy of the file in the new location before issuing the command  Open the database

Harvard University Archivelog Mode Recovery  To recover a database that is in archivelog mode, we need – A valid backup containing the lost or damaged data files, after the database was set in archivelog mode – All archived logs from the backup you are restoring from, to the present – The redo logs that contain the transactions that are not yet archived

Harvard University Archivelog Mode Recovery  If we meet all the above requirements  Make sure that the file(s) that are to be restored are not open  Check v$datafiles and v$tablespace to get the status  Restore only the lost or damaged file(s)  Do not restore online redo logs

Harvard University Archivelog Mode Recovery  Place the database in either mount or open mode  Recover the data files by using the recover command

Harvard University Archivelog Mode Recovery  The advantages of the archivelog mode – Only need to restore the lost or damaged file(s) – No committed data is lost – Restoring the files and then applying the archived and redo logs, takes the database up to the current point-in-time – The restore time is reduced

Harvard University Archivelog Mode Recovery  The disadvantages of the archivelog mode – We need all the archived logs from the time of the last backup to the current time – If one is missing or damaged, we cannot complete recovery, because the archives are applied in sequence

Harvard University Recover Syntax  Recover [automatic] database, can only be used for a closed database recovery  Recover [automatic] tablespace | | Can be used for open database recovery  Recover [automatic ] datafile | Can be used for both opened and closed database recovery

Harvard University Recover Syntax  Automatic means that the archives and redo logs are applied automatically  Alter database can be placed in front of the recover command but will suppress some of the error messages. Do not use!!

Harvard University Recover Syntax  Recover database;  Recover datafile ‘/u04/oradata/data_01.dbf’;  Alter database recover database;  Recover tablespace user_data;  Recover datafile 2;  Alter database recover datafile 2;

Harvard University Recover Syntax  If we restore the archived logs from a different location than log_archive_dest, we must tell the database where they are  Alter system archive log start to  Recover from ‘ ’ database;

Harvard University Recovery Process  When we issue recover datafile 4;, oracle will suggest(request) a specific log to apply.  If it exists in the log_archive_dest, enter auto and it will be applied  If you issue recover automatic datafile 4; It will apply the log, if it exists

Harvard University Recovery Process  To find the files needing recovery – select * from v$recover_file;  The change# column returns the SCN (system change number) from where recovery must start  To get a list of all the archived log files needed for recovery, look in v$recovery_log

Harvard University Recovery Process  V$archived_log gives a list of all archived log files

Harvard University Scenario 1  Corrupt data blocks on /u02, in a data file belonging to the SYSTEM tablespace  Shutdown the database  Restore the damaged file from the most recent valid backup  Startup mount  Recover datafile ‘/u02/oradata/system01.dbf’

Harvard University Scenario 1  Apply all needed archived and redo logs  Alter database open

Harvard University Scenario 2  A datafile is accidentally removed using unix commands  See what tablespace it belongs to  Select file_id f#, file_name, tablespace_name tablespace, status from dba_data_files;

Harvard University File Offline  Do we need to take the file offline  Select d.file# f#, d.name, d.status, h.status from v$datafile d, v$datafile_header h where d.file# = h.file#;  If the file is offline, restore it  Recover datafile ‘/u04/oradata/data02.dbf’;  Or use recover tablespace user_data;

Harvard University File Not Offline  If the file is not offline  Alter database datafile ‘/u04/oradata/data02.dbf’ offline  After all recovery is complete, alter the datafile online  If a tablespace is taken offline, then all the datafiles related to that tablespace are offline

Harvard University Incomplete Recovery  Reasons – User error, like table dropped or bad data committed  Recovery fails because an archive log is lost  Loss of all control files  Loss of all unarchived redo log files and a data file

Harvard University Incomplete Recovery  Types of incomplete recovery – Cancel-based recovery – Time-based recovery – Recovery using a backup control file  recover database until cancel;  Used when redo log file or group is damaged or when needed archive log file is lost

Harvard University Incomplete Recovery  Recover [automatic] database until time ‘ :14:22:03’;  Recover database until time ‘ :14:22:03’ using backup controlfile;  Time is ‘YYYY-MM-DD:HH:MI:SS’;  The application of the archived redo logs can be automatic  Recover database until scn ;

Harvard University Incomplete Recovery  Incomplete recovery can only occur if the database is in archivelog mode  We need a valid offline or online backup of all data files  All archived logs, from the restored backup to a time before the failure

Harvard University Incomplete Recovery  Perform a full offline backup of the existing database, including control files and redo logs  Restore all data files to take the database back in time  Place the database in mount mode and recover the database

Harvard University Incomplete Recovery  Open the database using the resetlogs option – Alter database open resetlogs; – This prevents the application of redo logs that were skipped  Most recovery errors are due to the DBA.

Harvard University Import  The import utility reads the export dump file and runs the commands that are stored there  It can be used to selectively bring back objects or users from the export dump file  If the export is incremental, then import from the incremental dump file first, then from the most recent complete export

Harvard University Import  Some of the import parameters conflict with one another, eg FULL=Y and OWNER=GL  DESTROY=N is useful if we have two databases on a server and wish to export from one to another. The tablespace definitions are in the file and it will overwrite the existing files

Harvard University Import  Another way is to recreate tablespaces first, on the second database. This will avoid the overwrite

Harvard University Import  To import into another account use the following example  Exp system/passwd file=user1.dmp owner=joe grants=N indexes=Y compress=Y rows=Y  Imp system/passwd file=user1.dmp fromuser=joe touser=jane rows=Y indexes=Y

Harvard University Import  Create a parameter file that hold all the parameters for an export or an import  List each one on a new line of a file  Use exp parfile=exp_parm_file  Userid=system/passwd Tables=(emp,dept) File=export.dmp

Harvard University Data Pump Utility  Transfers data objects and data between Oracle databases  expdp help=y  Impdp help=y

Harvard University Data Pump Utility  Import options (modes) – Full – Schema (user) – Tablespace – Table  No mode, defaults to full

Harvard University Data Pump Utility  To import the directory must be already setup for that database  The dump file must be in that directory  Example – Impdp user/pw parfile=name.par – A parameter file hold the various parameters to complete the import ( or export)

Harvard University Data Pump Utility  Parameter file example – Directory= – Dumpfile=name.dmp – Content=metedata_only – Remap=joe:jane  The export and import function are desupported in 11g

Harvard University Failure analysis  Mean time between failures  Mean time to recover when a failure occurs  Downtime – Scheduled outage for regular preventative maintenance – Unscheduled outage due to physical failure  Record why failure occurred  Service level agreements

Harvard University Reading  Chapter 11 DBA Handbook  Oracle Metalink  Backup and Recovery Handbook, Oracle Press  Backup and Recovery Concepts, Oracle Guide.