Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Oracle Backup and Recovery

Similar presentations


Presentation on theme: "Introduction to Oracle Backup and Recovery"— Presentation transcript:

1 Introduction to Oracle Backup and Recovery
Darl Kuhn, Regis University

2 Backup and Recovery Planning
How valuable is your data? How much data can you lose? Is the data easily recreated? Mean time to recovery requirements (MTTR) Availability requirements Disaster recovery requirements (DR) Test Plan How much money can you spend?

3 Backup and Recovery DBAs must be knowledgeable of backup and recovery
Arguably the most critical skill for a DBA to possess Must know how to architect backups Must know how to recover in the event of a failure

4 Oracle Architecture When dealing with backup and recovery, you must know the differences between an Oracle instance and database. When backing up files in an Oracle database, you will mainly be concerned with: control files, datafiles, and archive redo log files. Other file types to backup might be initialization files and network files. Keep in mind for online backups, you never backup the online redo log files, why?

5 Noarchivelog Mode Noarchivelog mode databases can only be backed up when the database is shutdown.

6 Archivelog Mode Archivelog mode is required for Hot Backups and RMAN Online backups. Archivelog mode allows you to take online backups, in other words, the database is up and running while the backup is taking place.

7 Archivelog Mode Continued
Advantages Enables mechanism for recovery of every committed transaction Enables online backups (Hot or RMAN) Disadvantages Requires additional storage Additional administrative overhead (you need to backup and periodically remove archive redo log files) Additional process (ARCn) and I/O

8 Enabling Archivelog Mode
SQL> shutdown immediate; SQL> startup mount; SQL> alter database archivelog; SQL> alter database open; It’s easy to enable archive log mode. However, now you need to consider where the archive redo logs are being written, and how long to keep them on disk before removing them, and how to remove them from disk (let RMAN do it or manually remove them).

9 Location and Management of Archive Redo Logs
If the location for the archive redo logs becomes full and Oracle cannot write archive redo logs to disk, your database will hang. In a production environment, you must give some detailed thought to the location of the archive redo log files. You need to ensure there is enough space and that the archive redo logs are backed up and removed on a regular basis. Do you want to use the Fast Recovery Area (or not). How long do you keep archive redo logs on disk? How do you remove the archive redo logs?

10 Types of Backups User Managed Physical Backups
Cold (offline) Hot (online) User Managed Logical Backups Old Export and Import utilities Data Pump export and import (10g and higher) Recovery Manager (RMAN) Offline physical Online physical 3rd Party Tools

11 User Managed Cold Backup (offline)
Database shutdown during backup Uses operating system copy command Cold Backup Steps: 1. Determine location of datafiles, controlfiles, and online redo logs 2. Shutdown immediate, transactional, or normal 3. Copy files to backup location 4. Startup database

12 User Managed Hot Backup (online)
Database must be in archivelog mode Tablespaces must be altered in and out of backup mode Database remains online during backup While tablespace in backup mode: When a block first changes Full block written to redo stream Not just the atomic change vector Can be significant performance hit Very common misperception that DBWn stops writing to datafiles during Hot Backup, not true!

13 User Managed Hot Backup Procedure
Hot Backup has more moving parts than a Cold: 1. Ensure database in archivelog mode 2. Determine which files to backup 3. Switch on-line redo logs 4. Alter tablespaces into backup mode (serial or parallel) 5. Use an OS utility to copy datafiles to backup location 6. Alter tablespaces out of backup mode 7. Switch on-line redo logs 8. Copy any archive redo logs generated during backup 9. Backup the controlfile via "alter database backup controlfile to <location/name>";

14 User Managed Logical Backups
Export utility Data Pump export: 10g and higher Greatly enhanced performance Schedule data pump jobs within the server Control and monitor data pump jobs from a different session Enhanced ETL operations The old export utility and the newer Data Guard export utility are referred to as “logical” because the backup file is not a physical copy of the data blocks, rather it’s a backup of the SQL that is required to recreate the objects and then the data to repopulate those objects.

15 Recovery Manager (RMAN)
RMAN is a tool that can be used for backup, restore, and recovery of Oracle databases First shipped with Oracle version 8.0 Oracle's recommended tool for B&R No extra license required Enterprise Edition contains all RMAN features, other editions contain subset of RMAN features. First stable release of RMAN was around Many DBAs who tried to use RMAN before that release have bad memories of RMAN. But since 8.1.6, RMAN has been very reliable and stable. Some features of RMAN are only available in the Enterprise Edition of Oracle. RMAN does ship with other editions, but does not contain the full feature set.

16 RMAN Advantages Easy to use command line mode to issue backup, restore, and recover commands Accessible through Enterprise Manager Tablespaces not put in backup mode (this is a huge advantage over Hot Backups) Incremental backups Block corruption detection Configurable I/O features (parallelism) Logging of backup operations Integrates with Media Management Layer (MML) software Compression and encryption Cross-platform data conversion Advanced reporting capabilities Data Recovery Advisor Automatic backup of the control file and server parameter file (spfile) RMAN has many, many advantages over user managed Hot/Cold backups. You really should be using RMAN (and not user managed Hot/Cold) backups for backing up your Oracle databases.

17 RMAN 9i New Features Backup optimization Restore optimization
Block level recovery New features for archive redo log backups Configurable persistent settings, automatic backup of controlfile, spfile Simplified syntax Retention policy RMAN was greatly enhanced in Oracle Database 9i. Many DBAs began to use RMAN with the release of 9i.

18 RMAN 10g New Features Make use of Flash Recovery Area (renamed to Fast Recovery Area in 11g) Change tracking Incremental merge Backup duration Compressed backups Automatic channel failover Restore failover Restore preview Automatic creation of missing datafiles Recovery through resetlogs With each release of Oracle, there are many significant improvements to RMAN functionality.

19 RMAN 11g New Features Data Recovery Advisor.
Enhancements to compression. Ability to backup large datafiles in parallel. Enhancements to cloning/duplicating. Oracle Secure Backup enhancements. More integration with Data Guard.

20 RMAN 12c New Features Not yet released, Oracle Database 12c.
Currently in Beta. Should be available ???

21 RMAN Backups Should you use a recovery catalog? Should you use a MML?
What should be the retention policy? Online or Offline Database must be in archivelog mode for online RMAN backups Can be as simple as: RMAN> backup database;

22 Failures Happen Non-Media Failure Media Failure Process failure
Statement failure User error Instance failure Media Failure Oracle unable to perform I/O on database file Requires DBA intervention

23 Crash vs. Media Recovery
On startup, Oracle determines whether crash or media failure situation exists: IF (cf SCN = df SCN) THEN Startup normally; ELSE IF (cf stop SCN = infinity) THEN SMON performs crash recovery; ELSE IF (cf SCN > df SCN) THEN Throw media failure error; ELSE IF (cf SCN < df SCN) THEN Throw controlfile too old error; END IF; Media failure means there is a critical file that Oracle needs that it cannot read when trying to open the database. This could be a control file, an online redo log file, or a datafile.

24 Restore and Recovery Restore is copying datafiles back from the backup set Recovery is apply redo to the datafiles via a “recover” command Many, many different B&R scenarios Restore and recovery procedure varies widely depending on: Type of backup Type of failure (datafile, controlfile, redo) Archivelog or noarchivelog mode

25 Noarchivelog Mode Restore
Restore from Cold Backup or an RMAN offline backup Restores to the point in time the backup was taken No redo available to restore transactions Most likely will result in loss of data

26 Archivelog Mode Restore and Recovery
Restore datafiles from: Cold backup Hot backup RMAN online or offline backup Issue “recover” command to apply redo SQL> recover database .... Recovery can be either complete or incomplete

27 Complete Recovery Complete recovery means that you can recover all transactions ever committed in the database You're restoring the database to the point in time right before the failure occurred Complete recovery only available for archivelog mode databases Complete does not mean that you have to restore and recover all datafiles Only have to restore and recover datafiles that have experienced media failure

28 Incomplete Recovery All transactions are not restored
Types of incomplete recovery: Change (SCN) Time Log Basic procedure: Copy all datafiles back from the backup set Rollforward to desired point SQL> alter database open resetlogs;

29 Summary Develop B&R plan that meets business requirements
Wide variety of methods to backup and recover your database Use RMAN “Your backup is only as good as the last time you tested it...”


Download ppt "Introduction to Oracle Backup and Recovery"

Similar presentations


Ads by Google