oracle recovery manager - rman · october 29, 2008 | rman • incremental backups • recovery...
TRANSCRIPT
Oracle Recovery Manager - RMAN
October 29, 2008 | www.sungardhe.com
RMAN
• Incremental Backups
• Recovery Preview – allows you to test recovery process without actually recovering
• Backup can be stored in ASM
• Compress backups – save disk and network bandwidth
• Recover past “resetlogs”!
October 29, 2008 | www.sungardhe.com
Introduction
• Session Goal
—Discuss the merits of Recovery Manager and the importance of backups
• Session Objectives
—Discuss the basic anatomy of Recovery Manager
—Review backup options
—Learn basic RMAN syntax required for backup and recovery
—Answer your burning questions about RMAN
October 29, 2008 | www.sungardhe.com
Agenda Slide
• Backup Basics and Review
• Recovery Manager Anatomy
• Using Enterprise Manager for…
—RMAN Setup
—Backups with RMAN
—Backup Reports
• Questions and Answers
Backup Basics and Review
October 29, 2008 | www.sungardhe.com
Executive Decisions
What questions should be posed to your institution while formulating your backup and recovery plan?
—Can you afford any data loss?
—What is an acceptable recovery time?
—What kind of budget has been designated?
—Are you considering a High Availability (HA) solution?
• Real Application Clusters
• Data Guard
October 29, 2008 | www.sungardhe.com
Translation of Executive Decisions
• Allocate resources
—Hardware
—Software
—Manpower
—Time
• Configure database according to decisions
• Storage space for backups
October 29, 2008 | www.sungardhe.com
Oracle Architecture
Instance
SGA
Database Buffer
Cache
Redo Log Buffer
Java Pool
Large Pool
Shared Pool
Shared SQL &
PL/SQL
Data Dictionary
Cache
Parameter
File
Password
File
Server
Processes
PGA
User
Processes
Network Client
Database Files
Redo Log Files
Control Files
Database
SMON DBWn PMONCKPT LGWR ARCn
Archived Log Files
October 29, 2008 | www.sungardhe.com
Oracle Architecture- Files
• Control Files: record the status of data/physical structure
• Datafiles: physical storage of data
• Redo Logs: contain before and after copies of data
• Archived Redo Logs: copies of redo logs
• Alert Log: logs major database changes and errors
• Password File: stores information allowing sysdbaconnections
• Parameter File: stores parameters required for instance startup
October 29, 2008 | www.sungardhe.com
Oracle Architecture- Processes
• PMON: Performs rollback and releases the resources held by a failed process
• SMON: performs automatic instance recovery
• DBWn: writes dirty buffers form the data buffer cache to the data files
• LGWR: writes data from the redo log buffer to the redo log files
• CKPT: Synchronizes the headers of the data files and control files with the current redo log and checkpoint numbers
• ARCHn: copies redo logs that have been marked for archiving
October 29, 2008 | www.sungardhe.com
To Archive or Not to Archive?
• NOARCHIVELOG mode
—Default mode
—Database must be shutdown to perform backups
• ARCHIVELOG mode
—Uses ARCH process
—May use point-n-time recovery
—Database may be open while performing backups
October 29, 2008 | www.sungardhe.com
Turning on Archivelog Mode
• Set necessary init.ora parameters
—Log_archive_dest_n
—Log_archive_dest_state_n
—Log_archive_format
• Shutdown the database
• Mount the database
• ALTER DATABASE ARCHIVELOG;
• Open the database
October 29, 2008 | www.sungardhe.com
NOARCHIVELOG offline backup
—A database in NOARCHIVELOG mode can achieve full recovery only up to the point of the last complete backup taken with the following steps:
1.Shutdown the database cleanly
2.Make a copy of all datafiles, control files and online redo logs to another location
3.Startup the database
October 29, 2008 | www.sungardhe.com
ARCHIVELOG offline backup
—A database in ARCHIVELOG mode can be backed up while the database is open or shut down. In order to take an offline backup use the following steps:
1.Shutdown the database cleanly
2.Make a copy of all datafiles
3.Startup the database
4.Force a log switch for your online redo logs
5.Make a copy of all archived redo logs
6.Create a backup of the control file
October 29, 2008 | www.sungardhe.com
ARCHIVELOG online backup
— In order to take an online backup use the following steps:
1.ALTER DATABASE BEGIN BACKUP;
2.Make a copy of all datafiles
3.ALTER DATABASE END BACKUP;
4.Force a log switch for your online redo logs
5.Make a copy of all archived redo logs
6.Create a backup of the control file
October 29, 2008 | www.sungardhe.com
What happens during an online backup?
• Datafiles are written to continuously as backup is performed
• All redo generated during a backup must be available if recovery is needed, hence the log switch
• Entire blocks of data that are being changed are recorded in the redo, rather than just the change vectors
• More disk space and CPU resources are utilized during backup mode
October 29, 2008 | www.sungardhe.com
ARCHIVELOG Recovery
— In order perform a full database recovery use the following steps:
1.Copy all of the database files from your last backup
2.Copy all necessary archived redo logs
3.Mount the database
4.Recover the database
5.Apply archived redo entry as prompted
6.Open the database
October 29, 2008 | www.sungardhe.com
What else should I backup?
—While you could recreate the following, it’s a lot less work to restore from a backup:
• Oracle Home software
• Network files
—listener.ora
—tnsnames.ora
• Parameter files
• Password files
• Oratab file
Recovery Manager Anatomy
October 29, 2008 | www.sungardhe.com
What is RMAN?
• Short Answer…
—RMAN is an interface for backing up and recovering your database.
• Long Answer…
—RMAN is a method of server managed recovery, interpreting commands into remote procedure calls to be carried out in the database for the purpose of backup and recovery.
October 29, 2008 | www.sungardhe.com
Why use RMAN?
• It’s FREE (with your Oracle license)
• Backups can be checked for corruption before it become a problem
• Minimize downtime after failure
• Recover single blocks of data
• Backup directly to tape
• Creating duplicate instances, including standbys for failover
October 29, 2008 | www.sungardhe.com
Why use RMAN?...continued
• Backups can be taken online without the additional overhead of traditional online backups
• Automatically includes new datafiles and tablespaceswithout manual intervention
• Only backs up used data blocks
• Allows for compressed backups
• Works with third-party media management
• Allows for centralized management and reporting of backups
October 29, 2008 | www.sungardhe.com
Key RMAN Players
• $ORACLE_HOME/bin/rman
—Command interpreter, creating PL/SQL calls to the target
—Creates system calls to the OS requiring read/write privileges
• recover.bsq
—Library file
—Must be the same version as the executable
October 29, 2008 | www.sungardhe.com
Supporting Cast
• Target Database: database that is being backed up
• Recovery Catalog: additional repository for backup metadata
• Auxiliary Database: database to be cloned or standby instance to be created
October 29, 2008 | www.sungardhe.com
Additional plot lines…
• RMAN always connects to the target as sysdba, because it must access objects in the SYS schema
• Best practice is to run RMAN form the target $ORACLE_HOME
• If you are not running RMAN from the target $ORACLE_HOME, you will need a password file, sysdbaprivileges, a tnsnames.ora entry for the target instance
• RMAN is backward compatible
• The recommendation for 10g is to run RMAN through the control file, rather than a separate repository
• It is easy to connect to the wrong database when using the same $ORACLE_HOME
October 29, 2008 | www.sungardhe.com
Benefits of Using the Control File
• Already has physical database structure included
• No need to update when new datafiles/tablespaces are added
• Possible to use the RMAN utility delivered in the $ORACLE_HOME of the target database
• May not need password file or sysdba privileges
October 29, 2008 | www.sungardhe.com
How the Control File Works
• Control file regularly ages out information as necessary
• Noncircular Reuse Records include datafile and log file inventory
• Circular Reuse Records include archived log history and RMAN backups
October 29, 2008 | www.sungardhe.com
Additional Control File Notes
• CONTROL_FILE_RECORD_KEEP_TIME=7 (default) is found in the init.ora file
• RMAN creates a read consistent view of the control file during backups called the snapshot control file
• Database must be at least in NOMOUNT for RMAN usage
October 29, 2008 | www.sungardhe.com
Benefits of using a Recovery Catalog
• You may store scripts for future use or reuse
• Helpful for a Data Guard HA solution
• Do not need to use CONTROL_FILE_RECORD_KEEP_TIME in init.ora
• You will not lose RMAN metadata when rebuilding the control file
• Creates one spot for maintenance and reporting of backups
October 29, 2008 | www.sungardhe.com
How a Recovery Catalog Works
• RMAN connects to designated schema in a database other than the target database
• RMAN connects to the target database
• Metadata is extracted from the control file of the target
• Data is loaded into tables of the schema specified while connecting to the additional instance
October 29, 2008 | www.sungardhe.com
How to Create a Recovery Catalog
• Designate another database
— SYSTEM 90MB
— TEMP 5MB
— UNDO 5MB
— RMAN User 15MB per backed up instance
— Online Redo 1MB per file
• Create a user specifically for RMAN backups
• Grant connect, resource, recovery_catalog_owner to the user created above
• Issue the CREATE CATALOG command
Figures are
based on
one year of
metadata
collection
Using Enterprise Manager for Backups
October 29, 2008 | www.sungardhe.com
EM Maintenance Tab
October 29, 2008 | www.sungardhe.com
Recovery Catalog Settings
October 29, 2008 | www.sungardhe.com
Register Database with Recovery Catalog
October 29, 2008 | www.sungardhe.com
Backup Settings
October 29, 2008 | www.sungardhe.com
Configuration SettingsRMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u03/backup/PPRD/rman/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u03/backup/PPRD/rman/%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0.2/dbs/snapcf_PPRD.f'; # default
October 29, 2008 | www.sungardhe.com
Backup Settings
October 29, 2008 | www.sungardhe.com
Default Device Type
—Determines whether you will be backing up to disk or tape
—Options are mutually exclusive
—Default may be overridden with the backup device type parameter
—Syntax:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE DEFAULT DEVICE TYPE TO SBT;
October 29, 2008 | www.sungardhe.com
Format
—Multiple channels may be allocated
—Various format options available
• %U: System generated unique filename (default)
• %F: DBID, day, month, year, sequence
• %s: backup set
• %p: backup piece
—Syntax:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘/u01/backup/PPRD/rman/PPRD_%U’;
October 29, 2008 | www.sungardhe.com
Backup Type
—Used to further define how backups will be carried out by default device type
—If compressed backup sets are chosen, backup files will be smaller, but it will take longer to restore from them
—Syntax:CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO
BACKUPSET;
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DEVICE TYPE DISK BACKUP TYPE COPY;
October 29, 2008 | www.sungardhe.com
Backup Settings
October 29, 2008 | www.sungardhe.com
Backup Settings
October 29, 2008 | www.sungardhe.com
Retention Policy
—Dictates when a backup will be marked as obsolete
—Backups that do not meet the configured retention policy will NOT be automatically deleted
—Syntax:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE RETENTION POLICY TO NONE;
CONFIGURE RETENTION POLICY TO CLEAR;
October 29, 2008 | www.sungardhe.com
Retention Policy Notes
• Retention policies remain until changed or control file is rebuilt
• You can identify backups that fall outside of your retention policy by issuing the REPORT OBSOLETE command
• The CHANGE BACKUPSET n KEEP command maybe used to bypass retention policies
• Restrictions for KEEP FOREVER
— Must be using a recovery catalog
— May not be using Flash Recovery Area
October 29, 2008 | www.sungardhe.com
Control File Autobackup
—This option will backup the control file and the spfile, if one exists
—When enable, backups will happen under the following conditions:
—BACKUP or COPY command is issued, not in a RUN block
—If a RUN block is used, then at the end as long as the last statement is not BACKUP or COPY
—Syntax:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
October 29, 2008 | www.sungardhe.com
Schedule a Backup
October 29, 2008 | www.sungardhe.com
Schedule a Backup
October 29, 2008 | www.sungardhe.com
Schedule a Backup
October 29, 2008 | www.sungardhe.com
Schedule a Backup
October 29, 2008 | www.sungardhe.com
Schedule a Backup
SHGE
October 29, 2008 | www.sungardhe.com
Schedule a Backup
October 29, 2008 | www.sungardhe.com
Schedule a Backup
October 29, 2008 | www.sungardhe.com
Backup Reports
October 29, 2008 | www.sungardhe.com
11g New Features for RMAN
• You don’t have to physically copy backup files to the auxiliary server, thanks to network aware duplication
• Backups can skip transactions in the undo tablespace that have already been committed
• Backup control files can now be converted to standby control files for Data Guard usage
• Large files can be backed up in parallel with multiple channels using multi-section backups
• Access to portions of a recovery catalog can be restricted with virtual private catalogs
• RMAN scripts now take variables at run time
October 29, 2008 | www.sungardhe.com
Summary
• Backups are one of the most important aspects the DBA role, if for no other reason than this is the database from which your paycheck comes ☺☺☺☺
• Recovery Manager usage can be as simple or as complex as you need it to be
• Recovery with RMAN is just as easy as the backup
• RMAN can be used for more than backups
—Failovers
—Duplicate Instances
• TEST your backups!!
October 29, 2008 | www.sungardhe.com
Questions & Answers
It’s your turn ($5 per question)!!