Академический Документы
Профессиональный Документы
Культура Документы
http://www.datadisk.co.uk/html_docs/oracle/rman.htm
Media Management Layer If you backup to tapes you require additional software called MML (media management layer) or media manager. MML is a API that interfaces with different vendors tape libraries. RMAN terminology
1 of 5
5/7/2012 4:12 PM
Oracle RMAN
http://www.datadisk.co.uk/html_docs/oracle/rman.htm
backup piece - operating system file containing the backup of a data file, controlfile, etc backup set - logical structure that contains one or more backup pieces, all relevant backup pieces are contained in a backup set image copy - similar to operating system copies like cp or dd, they will contain all block if if not used (disk only) proxy copy - media manger is given control of the copying process channel - Channel allocation is a method of connecting rman and the target database while also specifying the type of backup i.e. disk or tape, they can created manually or automatically. Connecting to RMAN There are a number of ways to connect to RMAN and it depends on where the recovery catalog is
c:\> set ORACLE_SID=D01
connect to the target server use oracle_sid and local controlfile connect the recovery manager catalog connect target & recovery manager catalog
rman> connect catalog rman_user/password@d01 rman> connect target orcl catalog rman_user/password@d01
Configuring RMAN persistent settings RMANs persistent settings which are stored in the controlfile (reason why must be in mount mode) of the target database (#default means that parameter is at default setting) or a recovery catalog if used
You can use format options with backup commands to specify a location and name for backup pieces %F %U %u %d %s %t %p combines database identifier (DBID), day, month, year and sequence number Specifies a system generated unique filename (default) specifies an 8 character name name of database backup set number backup set timestamp piece number within the backup set
Format options
rman> show all CONFIGURE CONFIGURE CONFIGURE CONFIGURE CONFIGURE CONFIGURE CONFIGURE CONFIGURE CONFIGURE CONFIGURE CONFIGURE CONFIGURE CONFIGURE CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default BACKUP OPTIMIZATION OFF; # default DEFAULT DEVICE TYPE TO DISK; # default CONTROLFILE AUTOBACKUP OFF; CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1; DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CHANNEL DEVICE TYPE DISK FORMAT 'z:/orabackup/%U'; MAXSETSIZE TO UNLIMITED; # default ENCRYPTION FOR DATABASE OFF; # default ENCRYPTION ALGORITHM 'AES128'; # default ARCHIVELOG DELETION POLICY TO NONE; # default SNAPSHOT CONTROLFILE NAME TO 'C:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\SNCFD01.ORA';#default
Displaying
set default device to be a tape drive set default device to be a disk drive set default backup to be a image copy default disk backup to a compressed backupset (upto 20% ratio) default tape backup to a compressed backupset (upto 20% ratio) Set degree of parallelism
configure default device type to sbt; configure default device type to disk; configure device type disk backup type to copy;
configure device type sbt backup type to compressed backupset; configure device type disk parallelism 4; configure device type sbt parallelism 4; configure backup optimization on;
Backup optimization
Note: this will ensure that RMAN doesn't perform a backup if it has already backed up identical versions.
2 of 5
5/7/2012 4:12 PM
Oracle RMAN
http://www.datadisk.co.uk/html_docs/oracle/rman.htm
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS CONFIGURE CONTROLFILE AUTOBACKUP ON CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET PARALLELISM 1
Channel Parameters/Options The parameters/options are use to control the resources used by RMAN, there are many options probably best to consult the oracle documentation. channel device type - set default location of backups can be disk or sbt channel rate - limits i/o bandwith KB, MB or GB channel maxpiecesize - limits the size of the backup pieces channel maxsetsize - limits the size of the backup sets channel connect - instructs a specific instance to perform an operation duration - controls time for backup job (hours/mins) parms - send specific instructions to tape library
rman> rman> rman> rman> configure configure configure configure channel channel channel channel device device device device type type type type disk disk disk disk format s:\ora_backup\ora_dev_f%t_s%s_s%p; rate = 5m; maxpiecesize = 2g; maxsetsize = 10g;
examples
Backup Retention Default is redundancy 1 which means always attempt to have one backup image or backupset of every data file, archive log and controlfile
keep backups for 30 days keep aleast 2 copies reset back to 1 (default) extend the retention period
rman> configure retention policy to recover window of 30 days; rman> configure retention policy to redundancy 2; rman> configure retention policy clear; rman> change backupset tag monthly_backup keep until time 01-dec-07 logs;
Backup Tagging
rman> backup database tag monthly_backup; rman> backup database as copy tag monthly_backup;
examples
Controlfile Backup
rman> backup current controlfile; rman> configure controlfile autobackup on; (default location flash recovery area)
examples
rman> configure controlfile autobackup format for device type disk to \controlfile_%F; z:\orabackup
Tablespace Excludes
rman> configure exclude from tablespace test; (exclude test tablespace from backup) rman> configure exclude from tablespace test clear; (remove the exclude test tablespace from backup) rman> backup database noexeclude (ignore any exclude settings)
examples
Creating Backups
rman> run { allocate channel c1 type disk; backup database format db_%u_%d_%s; (the backup set name for the data file) backup format log_t%t_s%s_p%p; (the backup set name from the archive logs) (archivelog all); } rman> run { allocate channel c1 type disk; allocate channel c2 type disk;
Backup Sets
3 of 5
5/7/2012 4:12 PM
Oracle RMAN
http://www.datadisk.co.uk/html_docs/oracle/rman.htm
backup (datafile 1,2,3 channel c1) (archivelog all channel c2); } rman> rman> rman> rman> backup backup backup backup as compressed backupset database; incremental level 0 database; - baseline incremental backup (a full backup ) incremental level 1 database; - incremental backup must have baseline backup incremental level 1 cumulative database; - backs up from last level 0 backup (NOT FULL)
rman> backup as backupset copy of tablespace sysaux; (create a backupset from a image copy) ## make that all redo logs are archived - see redo rman> backup database (archivelog all);
rman> run { allocate channel c1 type disk; copy datafile 1 to z:\orabackup\system01.dbf, current controlfile to z:\orabackup\control01.ctl; }
Backup Images
rman> rman> rman> rman> backup backup backup backup as copy as copy copy as as copy database; copy of database; copy tablespace sysaux; datafile 2;
Parallel Streams
Note : You only configure the number of streams to the number of channels, if you configure more they will not start. Remember that you need multiple channels configured to use the streams. # need to clear the 'controlfile autoback format' then the flash recovery area will be used.
Backup controlfile and rman> configure controlfile autobackup format for device type disk clear spfile to flash recovery area rman> backup current controlfile;
rman> rman> rman> rman> rman> backup backup backup backup backup
device type disk copies 2 datafile 1 format ''disk1/df1_%U', '/disk2/df1_%U'; as copy copy of database from tag 'test' check logical tag 'duptest'; database plus archivelog; as copy duration 04:00 minimize time database; as compressed backupset database plus archivelog;
Other examples
Note: logical - perform logical check of the backup files duration - time limit to perform the backup minimize - perform the backup as fast as it can compressed - compress the backup set, remember it will take longer to recovery as it needs to uncompress
Validating/Cross Checking Backups You can validate a backup set before you restore which ensures that backup files exist in the proper locations and that they are readable and free from any logical and physical corruptions, you can also crosscheck backup sets to make sure they are available and have not been deleted (backup sets can be deleted from the operating system level).
Validate a backup crosscheck
rman> validate backupset 1; rman> crosscheck backupset 1;
Viewing backups The v$ views information regarding backups is always located in the target databases or target databases controlfile. The list commands are used to determine files impacted by the change, crosscheck and delete commands. The report command is accurate when the control and RMAN repository are synchronized which can be performed by the change, crosscheck and delete commands
list all image copies list all backups list backed up files list backed up databases; list all datafile number 1 backups list backed up controlfiles list backup scripts list all backups no longer required according to retention policy
rman> list copy; rman> list archivelog all; rman> list backup; rman> list backupset by backup [summary|verbose]; rman> list backupset by file; rman> list backup of database; rman> list backup of datafile 1; rman> list backup of controlfile; rman> list script names; rman> list global script names; rman> report obsolete;
4 of 5
5/7/2012 4:12 PM
Oracle RMAN
http://www.datadisk.co.uk/html_docs/oracle/rman.htm
list all the physical datafiles list files that require backing up
Useful Views v$controlfile_record_Section displays information about the control file record sections v$backup_files v$backup_set v$backup_piece v$backup_redolog v$backup_spfile v$backup_device v$rman_configuration v$rman_status v$backup_corruption v$copy_corruption lists each file backed up, also has compressed option lists backup sets lists backup pieces lists archived backup logs lists spfiles names of SBT devices that have been linked to rman lists all changed configurations settings (good point to check config) Status of all completed rman jobs provides important corruption information provides important corruption information
Deleting Backups To removed old archive logs use "delete all" option, if all is missed only the archive logs in the primary destination will be deleted.
rman> rman> rman> rman> rman> delete delete delete delete delete backupset 12; backupset tag=monthly_backup; copy of datafile 6; copy of archivelog all; obsolete;
Examples
Note: obsolete - delete all backups no longer needed due to retention levels
Catalog commands The catalog command helps you identify and catalog any files that aren't recorded in RMAN's repository and thus are known to RMAN
catalog all data files copies rman> catalog datafilecopy 'c:\oracle\backup\users01.dbf'; catalog all backup pieces copies
rman> catalog backuppiece ':c\oracle\backup\backup_20.bkp';
Search for uncatalog files in rman> catalog start with ':c\oracle\backup'; a directory Delete discrepancy in catalog
rman> delete force noprompt archivelog sequence 40;
Block change tracking Block change tracking is used to backup very large databases,when you enable change block tracking a new process CTWR is then started:
Enabling Viewing Disabling
alter database enable block change tracking using file c:\oracle\tracking\block_tracking.log select filename, status, bytes from v$block_change_tracking; alter database disable block change tracking;
5 of 5
5/7/2012 4:12 PM