3.88k likes | 3.89k Views
Introduction. Objectives. After completing this lesson, you should be able to: Describe course objectives Describe backup methods Describe the forms of data recovery Describe Oracle Recovery Manager architecture Plan a recovery strategy
E N D
Objectives • After completing this lesson, you should be able to: • Describe course objectives • Describe backup methods • Describe the forms of data recovery • Describe Oracle Recovery Manager architecture • Plan a recovery strategy • Plan a backup strategy based on your recovery strategy
Course Objectives • After completing this course, you should be able to: • Use Oracle Recovery Manager (RMAN) to perform backup and recovery operations • Create a duplicate database • Perform tablespace point-in-time recovery • Create and manage an RMAN recovery catalog • Use Oracle Secure Backup to back up and restore Oracle databases and file-system data to and from tape
What Is Backup and Recovery? • Backup and recovery constitutes the strategies and procedures you employ to: • Protect your database against data loss • Reconstruct your database following data loss
Performing Backup and Recovery Operations for an Oracle Database • For performing backup and recovery based on physical backups, the following solutions are available: • Recovery Manager: A utility with a command-line client and an Enterprise Manager GUI interface • User-managed backup and recovery: A technique that involves using operating system commands to create backups and using SQL*Plus commands for additional backup and recovery operations
Using Oracle Recovery Manager • RMAN: • Is a command-line client for advanced functions • Has powerful control and scripting language • Has a published API that enables interface with most popular backup software • Backs up data, control, archived log, and server parameter files • Backs up files to disk or tape • Enterprise Manager uses Recovery Manager (RMAN) to perform backup and recovery operations.
Recovery Manager Components Serversession RecoveryManager(RMAN) Enterprise Manager Target database (control file repository) Options Serversession Channel Channel Channel Auxiliarydatabase MML Recoverycatalog database Disk Flash RecoveryArea
Using Oracle Secure Backup • One tool to backup and restore Oracle databases and file-system data to and from tape • Integrated with RMAN and Enterprise Manager • Supports Oracle9i and Oracle Database 10g
Overview of Oracle Backup Methods • Backup strategies: • Whole: A backup of the control file and all datafiles that belong to a database • Partial: A portion of the database • Backup types: • Full: A non-incremental RMAN backup • Incremental: Only information that has changed since some previous backup • Backups modes: • Offline: Consistent, also referred to as cold backup • Online: Inconsistent, also referred to as hot backup
When Do You Need to Use a Backup for Recovery? • The use of a backup to perform recovery is often required for the following types of errors: • Media failure: The failure of a read or write of a database file due to a physical problem with the file • User errors: Data in your database is changed or deleted incorrectly
Responding to User Error • Possible responses to user error include: • Reentering the lost data manually, if a record of the changes exists • Importing the dropped object, if a suitable export file exists or the object is still available on a standby database • Performing tablespace point-in-time recovery (TSPITR) of one or more tablespaces • Returning the database to a past state using database point-in-time recovery • Using one of the Oracle Flashback features to recover from logical corruption by returning affected objects to a past state
Overview of Data Recovery • Crash recovery: Automatic recovery after instance failure • Media recovery: Recovery of current datafiles, control files • Complete recovery: Recovery of the database to the most recent point in time • Incomplete recovery (point-in-time recovery): Recovery of the database to its state at a specific time or system change number (SCN)
Oracle Database Architecture: Crash Recovery • The online redo log files are used to roll the database forward. • Uncommitted changes are rolled back. Online redo log files Undo blocks Database with committed and uncommitted transactions Database at time of instance failure Database with committed transactions only
Oracle Database Architecture: Recovery After Media Failure • Datafiles are restored from a backup. • Archived and online redo log files are used to roll the database forward. Online and archived redo log files Undo blocks Recovered database Database with committed and uncommitted transactions Database with restored datafiles
Developing a Backup and Recovery Strategy for Your Oracle Database • Assess service-level criteria, including: • Data availability requirements • Data criticality • Recovery point and time objectives • Anticipate the errors that will arise in your environment and put in place the backup procedures needed to recover from those errors.
Oracle Solutions for High Availability • In addition to backup and recovery strategies and procedures, consider the following Oracle solutions: • Oracle Data Guard: Provides a comprehensive set of services that create, maintain, manage, and monitor one or more standby databases • Oracle Real Application Clusters (RAC): Enables access to a single database from multiples instances • Oracle Streams: Enables the propagation and management of data, transactions, and events in a data stream • LogMiner: Enables you to query redo log files through a SQL interface to provide data recovery
Oracle High Availability Solutions for Unplanned Downtime • Computer failure: Fast-start fault recovery, Real Application Clusters (RAC), Data Guard, Oracle Streams • Storage failure: Automatic Storage Management (ASM), RMAN with Flash Recovery Area, Data Guard, Oracle Streams • Human errors: Oracle security features, Oracle Flashback technology, LogMiner • Data corruption: Hardware Assisted Resilient Data (HARD) initiative, RMAN with Flash Recovery Area, Data Guard, Oracle Streams • Site failure: RMAN, Data Guard, Oracle Streams
Summary • In this lesson, you should have learned how to: • Describe backup methods • Describe the forms of data recovery • Describe Oracle Recovery Manager architecture • Plan a recovery strategy • Plan a backup strategy based on your recovery strategy
Objectives • After completing this lesson, you should be able to: • Configure your database in ARCHIVELOG mode • Specify a retention policy • Configure the Flash Recovery Area
Configuring Your Database for Backup and Recovery Operations • Operate the database in ARCHIVELOG mode. • Configure the Flash Recovery Area. Archiver (ARCn) Online redo log files Archived redo log files Archived redo log files Control file backups Datafile backups
Configuring ARCHIVELOG Mode • Perform the following steps to place the database in ARCHIVELOG mode: • Using Enterprise Manager: • Select the “ARCHIVELOG Mode” check box. • Click Apply. The database can be set to ARCHIVELOG mode only from the MOUNT state. • Click Yes when asked whether you want to restart the database. • Using SQL commands: • Place the database in MOUNT mode. • Issue the ALTERDATABASEARCHIVELOGMODE command • Open the database.
Specifying a Backup Destination • Backups can be written to: • Disk directory • Tape using Oracle Secure Backup • Media Management Library (tape device) • Flash recovery area: Disk area set aside for backup and recovery and flashback database purposes
Specifying a Retention Policy • Retention policy: Describes which backups will be kept and for how long • Two types of retention policies: • Recovery window: Establishes a period of time within which point-in-time recovery must be possible • Redundancy: Establishes a fixed number of backups that must be kept • Retention policies are mutually exclusive. File2 File1 Now File2 needsto be backed up: Seven-day retention
Using a Flash Recovery Area • The Flash Recovery Area provides a centralized location for control file backups, archived redo logs, flashback logs, and database backups. • The Flash Recovery Area can be defined as a directory, file system, or ASM disk group. • A single Flash Recovery Area can be shared by more than one database. Database area Flash Recovery Area
Defining a Flash Recovery Area • The Flash Recovery Area is defined by setting the following initialization parameters: • DB_RECOVERY_FILE_DEST_SIZE: Sets the disk limit, expressed in bytes • DB_RECOVERY_FILE_DEST: Sets the location for the Flash Recovery Area • These parameters are dynamic and can be altered or disabled.
1 2 3 4 1 2 Backup files to be deleted Flash Recovery Area Space Management Disk limit is reached and a new file needs to be written into the Flash Recovery Area Files that are no longer required on disk are deleted Flash Recovery Area Database file backup Space pressure occurs Warning issued to user RMAN updates list of files that may be deleted
Flash Recovery Area Space Usage • Configure the retention policy to the minimum value appropriate for your database. • Back up the archive log files regularly and delete the files upon completion of the backup. • Use the RMAN REPORTOBSOLETE and DELETEOBSOLETE commands to remove backups and file copies that are not required.
Benefits of Using a Flash Recovery Area • Using the Flash Recovery Area for recovery-related files: • Simplifies the location of database backups • Automatically manages the disk space allocated for recovery files
Summary • In this lesson, you should have learned how to: • Configure your database in ARCHIVELOG mode • Specify a retention policy • Configure the Flash Recovery Area
Practice Overview • This practice covers the following topics: • Placing the database in ARCHIVELOG mode • Verifying that the Flash Recovery Area is configured • Using RMAN to connect to the target database
Objectives • After completing this lesson, you should be able to: • Configure persistent settings • Configure backup destinations • Configure backup optimization • Create duplexed backup sets
Using RMAN to Create Backups • When creating a backup using RMAN, you can specify: • Type: Full or incremental • Files to back up: Entire database, datafiles, control file, server parameter file, archived redo log files • Backup type: Image copy or backup set
Backup Destinations • Backups can be written to: • Disk directory • Media Management Library (tape device) • Typically used for disaster recovery, when disk backups are lost. • Flash Recovery Area • This is the disk area set aside for backup and recovery and flashback database purposes. • Define the location and the size. • Files are automatically named by using Oracle Managed Files. • Files are automatically retained and deleted as necessary.
Configuring Persistent Settings for RMAN • RMAN is preset with default configuration settings. • Use the CONFIGURE command to: • Configure automatic channels • Specify the backup retention policy • Specify the number of backup copies to be created • Set the default backup type to BACKUPSET or COPY • Limit the size of backup pieces • Exempt a tablespace from backup • Enable and disable backup optimization • Configure automatic backups of control files
Managing Persistent Settings • Use the SHOW command to list current settings: • Use the CLEAR command to reset any persistent setting to its default value: RMAN> SHOW CONTROLFILE AUTOBACKUP FORMAT; RMAN> SHOW EXCLUDE; RMAN> SHOW ALL; RMAN> CONFIGURE BACKUP OPTIMIZATION CLEAR; RMAN> CONFIGURE MAXSETSIZE CLEAR; RMAN> CONFIGURE DEFAULT DEVICE TYPE CLEAR;
Configuring and Allocating Channels forUse in Backups • Configure automatic channels with the CONFIGURE command: • Allocate channels manually with the ALLOCATECHANNEL command within a RUN block: RMAN> CONFIGURE DEVICE TYPE sbt PARALLELISM 1; RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt; RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt … RMAN> BACKUP DATABASE; RMAN> RUN { ALLOCATE CHANNEL ch1 DEVICE TYPE DISK; … BACKUP DATABASE PLUS ARCHIVELOG; }
Configuring Backup Optimization • The BACKUP command skips backing up files when the identical files have already been backed up. • It is used when the following conditions are true: • Backup optimization is enabled. • BACKUPDATABASE, BACKUPARCHIVELOG with ALL or LIKE options, or BACKUPBACKUPSETALL commands are executed. • Only one type of channel is allocated. • It can be overriden with the FORCE option. • It is always used for RECOVERYAREA, DB_RECOVERY_FILE_DEST, and RECOVERYFILESBACKUP options.
Datafile 1 Datafile 3 Datafile 2 Datafile 3 Creating Backup Sets RMAN> BACKUP AS BACKUPSET 2> FORMAT '/BACKUP/df_%d_%s_%p.bus' 3> TABLESPACE hr_data; Backupset Datafile 1 Datafile 2 Tablespace HR_DATA
Creating Image Copies RMAN> BACKUP AS COPY 2> DATAFILE '/ORADATA/users_01_db01.dbf' 3> FORMAT '/BACKUP/users01.dbf';RMAN> BACKUP AS COPY 4> ARCHIVELOG LIKE '/arch%' 5> FORMAT 'arch_%U.bak'; Copy of datafile 3 Datafile 3 Datafile 3 Copy of archived log Archivedlog file Archivedlog file
BACKUP Command Options • Scan for logical corruptions and physical corruptions. • Set a threshold on the number of detected corruptions allowed before aborting. • Validate the target input files before performing a backup operation. • Duplex the backup set. • Overwrite an existing backup set or image copy. • Pass control of the data transfer between storage devices and the datafiles on disk to the media management layer. • Encrypt the backup files.
Creating a Whole Database Backup RMAN>BACKUP DATABASE PLUS ARCHIVELOG; Controlfile Archived log file copies Datafile copies SPFILE
RMAN Backup Types Full, or "level 0incremental backup" • A full backup contains all used datafile blocks. • A level 0 incremental backup is equivalent to a full backup that has been marked as level 0. • A cumulative level 1 incremental backup contains only blocks modified since thelast level 0 incremental backup. • A differential level 1 incremental backup contains only blocks modified since the last incremental backup. Cumulative incremental backup Differential incremental backup
CTWR Fast Incremental Backup • Optimizes incremental backups • Tracks which blocks have changed since the last backup • Oracle Database 10g has integrated change tracking: • A change tracking file is introduced. • Changed blocks are tracked as redo is generated. • Database backup automatically uses the changed block list. List of changed blocks 1011001010110 0001110100101 1010101110011 Change trackingfile Redogeneration SGA Redo log
Enabling Fast Incremental Backup ALTER DATABASE{ENABLE|DISABLE} BLOCK CHANGE TRACKING [USING FILE '...']
Monitoring Block Change Tracking SQL> SELECT filename, status, bytes 2 FROM v$block_change_tracking; SQL> SELECT file#, avg(datafile_blocks), 2 avg(blocks_read), 3 avg(blocks_read/datafile_blocks) 4 * 100 AS PCT_READ_FOR_BACKUP, 5 avg(blocks) 5 FROM v$backup_datafile 6 WHERE used_change_tracking = 'YES' 7 AND incremental_level > 0 8 GROUP BY file#;