Professional Documents
Culture Documents
Recovery Manager
Backup & Recovery Utility Oracle Corporation
Many features of Recovery Manager are also available through the Oracle Enterprise Manager - Backup Wizard. Recovery Manager is a Command Line Interface.
Recovery Manager - 2
Features
Automation of Backup, Restore, and Recovery
e.g. addition of data file will be automatically detected, and included in the next backup
restore: reported in RMAN log, as well as target database alert and trace
Easily manages distributing database backups, restores, and recoveries across clustered nodes in an Oracle Parallel Server/RAC.
March 22, 2014 Recovery Manager - 3
Features
Easy backup of Archived redo logs. Performance
Automatic Parallelization of backup, restore, and recovery. Multiplexing prevents flooding any one file with reads and writes while still keeping a tape drive streaming. No generation of extra redo during open database backups (also no worries about the database crashing with files in backup mode).
Recovery Manager - 4
Terminology
Backup Set A logical object, containing backups of one or more datafiles or archived logs. A backup set consists of one or more physical files called backup pieces. Backup Piece A file that contains the data for a backup set. If a backup set requires more bytes than can be supported by one file in the underlying media, then the backup set will be written to as many backup pieces as necessary. Media Manager A non-Oracle software product that knows how to manage tape drives, tape libraries, and other types of tertiary storage.
Recovery Manager - 5
Recovery Manager - 6
CF
server (default)
SCF
SGA
server (polling) File 2
File 1
server
channel SBT_TAPE
File 3
MML
Target
File 4
If not using a catalog, multiple backups of the control file should be kept in distinct locations (on different disks, tapes and/or machines). These backups must be restorable without Recovery Manager.
Recovery Manager - 8
Decide whether to create a separate tablespace for the Recovery Catalog. e.g. To create a separate tablespace, start Server Manager, and:
SVRMGR> connect internal SVRMGR> create tablespace rcvcat 2> datafile /oracle/rcvcat/prod/rcvcat_1.dbf size 20m;
Recovery Manager - 9
Recovery Manager - 10
Recovery Manager - 11
To be able to write to sequential devices such as Tape, you must link the Oracle server software with software which is written by a Media Management vendor. This software (usually known as the Media Management Library, or Media Management Layer) is called by Oracle when Oracle needs to write to, or read from devices supported by the Media Manager. An example of linking Oracle on Solaris, with an MML (the MML is libobk.so, and is located in /usr/lib): Shutdown all databases using that executable set before linking, then:
$ $ $ $ $ cd $ORACLE_HOME/lib mv libobk.so libobk.so.orig #if libobk.so already exists, rename it ln -s /usr/lib/libobk.so . cd $ORACLE_HOME/rdbms/lib make -f ins_rdbms.mk ioracle
In 8.1.5, no link is needed to install a media manager. Just point the symbolic link $ORACLE_HOME/lib/libobk.so to your MML library, and re-start the Oracle instance.
Recovery Manager - 12
Recovery Manager - 13
Recovery Manager - 14
The register database command identifies the database to the Recovery Catalog.
All information about the target databases structure is propagated to the Recovery Catalog from the target databases control file. The database must be mounted or open to perform this action.
Recovery Manager - 15
Backup Overview
The database can be Open or Closed during backup
If you are performing a closed backup, the database must be mounted, but not open.
SVRMGR> shutdown immediate SVRMGR> startup mount
If you are performing a backup while the database is open, the tablespaces should not be put in hot backup mode (i.e. you should not issue an alter tablespace begin backup command). Recovery Manager allows you to backup the whole database, or any of the following subsets, whether the database is open or closed (of course, as in v7, the database must be in archivelog mode to take an open backup):
database tablespace(s) datafile(s) and datafile copies control file, spfile
Recovery Manager - 16
Backup Overview
Backup Tags
Backups can be given a 30 character name called a Tag:
weekly_full daily_incremental
Tags do not need to be unique. Restore can override automatic backup selection by specifying a tag.
Recovery Manager - 17
Types of Backups
There are two types of Recovery Manager backups:
File Copies Backup Sets
Recovery Manager automatically propagates changes in database structure information to the Recovery Catalog (from the control file) before executing certain commands (e.g. backup)
The information propagated includes new datafiles, resized datafiles, dropped tablespaces, new archivelogs
Recovery Manager - 18
File Copy
A File Copy is created by the copy command and
Is an exact image copy of the original file Contains only a single input file (datafile, archivelog or controlfile) Is most like an Operating System backup (contains all blocks) Can be a part of an incremental strategy; but a file copy always includes all blocks, and hence can only be a level 0
run { allocate channel d1 type disk; copy level 0 datafile 1 to /oracle/prod/backup/file1.dbf; }
Recovery Manager - 19
Recovery Manager - 20
Backup Set
A Backup Set is created by the backup command and
Usually contains multiple source files (multiplexed in the output) It is a logical entity, comprising one or more physical output files called backup pieces Can be written to disk or sbt_tape A restore operation is required to extract files from a backup set There are two types of Backup Sets
Datafile backup sets (can include control files) Archivelog backup sets (can only contain archivelogs)
Recovery Manager - 21
Backup Pieces
A Backup Set is a logical entity which is composed of one or more physical output files, called backup pieces A backup set usually has only one backup piece. When using sbt_tape the only time a backup set has more than one piece is when the maximum piece size is limited by the user: e.g. Tablespace backup to one tape drive, max. file size is 4Gb
run { allocate channel t1 type SBT_TAPE; set limit channel t1 kbytes 4194304; backup format df_%t_%s_%p tablespace user_data; }
If the output is < 4Gb, only one backup piece will be written. If the output size is > 4Gb, more than one backup piece will be written. Each backup piece will have blocks from all files belonging to the tablespace interspersed together.
In 8i, the media management layer can inform rman of its maximum backup piece size, which may cause multiple pieces to be created. March 22, 2014 Recovery Manager - 22
Are initially based on a Level 0 backup set, or a Level 0 File Copy Can be faster than performing full (or level 0) backups Write out fewer blocks than full (or level 0) backups Are by default non-cumulative Available only with Enterprise Edition
changed blocks all nonempty blocks
Level Day
March 22, 2014
0 Sun
2 Mon
2 Tue
1 Wed
2 Thu
2 Fri
2 Sat
0 Sun
Recovery Manager - 23
Level Day
March 22, 2014
0 Sun
2 Mon
2C Tue
1 Wed
2 Thu
2C Fri
2C Sat
0 Sun
Recovery Manager - 24
As with datafile backup sets, archivelog backups are automatically distributed across the number of channels specified.
March 22, 2014 Recovery Manager - 25
by SCN:
backup archivelog from scn 1 until scn 9999999;
by time:
backup archivelog from time 01-jan-98 until time 30-jun-98;
by name:
backup archivelog like /oracle/arc/dest/log%;
The delete input option can be used to delete logs from disk after they have been successfully backed up.
Recovery Manager - 26
Restore Concepts
To reconstruct, or bring back an original file from backup. Recovery Manager allows you to restore any logical unit of a database:
database tablespace datafile control file
restore database; restore tablespace <name>,..,<name>; restore datafile <name>,..,<name>; restore controlfile to <location>;
restore controlfile;
The controlfile will automatically be restored to all locations specified in the init.ora file (i.e. replicate controlfile will not be needed).
Archived logs may also be manually restored. Usually this is not needed, as Recovery Manager automatically restores all archivelogs which are needed during the Recovery phase. Use SET ARCHIVELOG DESTINATION to override the target database's LOG_ARCHIVE_DEST setting.
restore archivelog [all|like <filename>|<archivelog range>| etc);
Recovery Manager - 27
Restore Concepts
Recovery Manager:
Queries the Recovery Catalog to determine the configuration of the database, and to find out what backups are available for use. Decides which backups are the optimal ones to use to restore the specified files.
When compiling lists of files to restore, Recovery Manager takes into consideration:
Time Specifications (e.g. for a Point-In-Time Restore) Any tags specified by users The channel type (disk/sbt_tape) allocated. To ensure Recovery Manager will find the most recent backups, allocate the appropriate channel type. The from backupset/datafilecopy option, if specified. Note that Datafile Copies do not need to be restored, they can be used insitu by executing a switch command, which directs the database to use this file as the actual file in the database.
March 22, 2014 Recovery Manager - 28
Restore Example
Restore the whole database, including control file (to each files original location). As the whole database and control file are being restored, the database should be started, but not mounted. Start Server Manager, then:
SVRMGR> shutdown immediate SVRMGR> startup nomount
Recovery Manager - 29
Restore Example
Then start Recovery Manager:
rman target internal/secret@prod rcvcat rman/rman@rcat RMAN> run { 2> allocate channel t1 type sbt_tape; 3> restore controlfile to /tmp/cf; 4> replicate controlfile from /tmp/cf; 5> sql alter database mount; 6> restore database; 7> }
The database has been restored If the backup is consistent, and the DBA either does not want to, or cannot perform recovery, the database can be opened resetlogs, by adding the sql below to the script (a fake recovery is not required):
sql alter database open resetlogs;
Recovery Manager - 30
Recovery Concepts
Recovery is the process of using redo logs to re-play database changes to datafiles, to make the files current after they have been restored from a backup. If the database is in ARCHIVELOG mode, it is possible to either completely recover the database, or recover the database to any arbitrary point-in-time (incomplete recovery). For NOARCHIVELOG mode databases, recovery is not usually possible. The only option is to restore from a consistent whole database backup. If a database is closed during recovery, all files in that database must be consistent with each other before the database can be opened. If a database is open during a tablespace or datafile recovery, the tablespace or datafile must be consistent with the remaining datafiles before it can be brought online (implying that incomplete recovery is not possible in this scenario).
March 22, 2014 Recovery Manager - 31
Apply redo which is currently on disk. If all redo required for recovery is not on disk, restore archivelogs, then apply them and any redo in the online redo logs needed for recovery.
Recovery Manager - 32
Recovery Manager - 33
In 8i, the shutdown and startup commands can be done from RMAN.
Recovery Manager - 34
To delete a backup piece, file copy or archivelog which is no longer required from the controlfile, recovery catalog, and from the media it resides on:
RMAN> allocate channel t1 for delete type 'sbt_tape'; RMAN> change backuppiece <key> delete;
The keys are determined by using the list command. The 'allocate channel for delete' command is required when using the 'change delete' or 'crosscheck' commands.
To remove references to a backup piece, file copy or archivelog from the recovery catalog (e.g. if it was deleted by an O/S utility):
RMAN> change archivelog
2> /disk1/archivelog/al_prd1_123.rdo uncatalog;
Recovery Manager - 35
This verifies that the files the Recovery Catalog believes are on disk, are there. If they are not there, these files are identified as deleted in the catalog.
Recovery Manager - 36
Use the DELETE EXPIRED BACKUP command to change all EXPIRED backups to DELETED.
Recovery Manager - 37
Recovery Manager - 38
Recovery Manager - 39
Recovery Manager - 40
List Command
Displays the contents of the controlfile or recovery catalog:
All databases known to the recovery catalog or incarnations of a database
RMAN> list incarnation of database;
Backup Sets or File Copies containing a backup of any datafile which is a member of a list of tablespaces
RMAN> list copy of tablespace system;
Backup Sets or File Copies of the whole database, optionally restricted by time, datafile copy name, device name and tag Backup Sets containing Archivelogs restricted by name, or by range. For example, list which backup sets contain archivelogs between the sequence 123 and 145
RMAN> list backupset of archivelog 2> from logseq 123 until logseq 145 thread 1;
Recovery Manager - 41
Report Command
Analyzes the content of the recovery catalog in more detail than list Produces reports which can answer questions such as:
What files need a backup?
report need backup
Recovery Manager - 42
Report Command
unrecoverable
should be used on a
Recovery is possible
RMAN> report unrecoverable;
Recovery is possible within an acceptable time For Example, the following command reports all datafiles which would require the application of 3 or more incrementals to be recovered to their current state
RMAN> report need backup incremental 3 database;
The following command reports all datafiles belonging to the SYSTEM tablespace that havent had a backup (full or incremental) in 5 days or more.
RMAN> report need backup days 5 tablespace system;
Recovery Manager - 43
Duplicate Database
New command in 8i, DUPLICATE DATABASE, creates a duplicate copy of the target database:
restores backups to a second instance, on the same or a different machine recovers those backups to any desired point in time sets a new DBID in the duplicated database opens the database resetlogs
You must first create a second instance: net config files, init.ora. This is called the AUXILIARY instance. It should be started, but not mounted, before using the DUPLICATE command. The auxiliary instance does not have to be on the same machine as the target. If the duplicate database is on the same machine as the target, the filenames must be changed to avoid conflict with the target database files. Syntax: DUPLICATE TARGET DATABASE TO <newdbname>
March 22, 2014 Recovery Manager - 44
Recovery Manager - 45
Recovery Manager - 46
Questions
Recovery Manager - 47