通过RMAN有两种不同类型的备份方式:创建镜像复制和创建备份集。备份集(Backup Sets):为RMAN默认备份选项。备份集是RMAN创建的具有特定格式的逻辑备份对象,备份集在逻辑上由一个或多个备份片段(Backup Piece)组成,每个备份片段在物理上对应一个操作系统文件,一个备份片段中可能包含多个数据文件、控制文件或归档文件,括弧之一。通过RMAN创建备份集的优势在于,备份时只读取数据库中已经使用的数据块,因此不管是从备份效率,或是节省存储空间的角度,创建备份集的方式都更有优势。 镜像复制(Image Copies):镜像复制实际上就是创建数据文件、控制文件或归档文件的备份文件,与用户通过操作系统命令创建的备份一样(甚至连执行的命令都相同,RMAN镜像复制使用COPY命令,Windows下复制文件也用COPY命令,Linux/UNIX下则是用cp命令),只不过RMAN是利用目标数据库中的服务进程来完成文件复制,而用户则是用操作系统命令。这种方式本质仍是复制数据库中的物理文件,包括数据文件、控制文件等,复制出的文件与原始文件一模一样,所以镜像复制的方式体现不出RMAN的优势。如何查看当前的备份方式RMAN> show all;using target database control file instead of recovery catalogRMAN configuration parameters for database with db_unique_name PTIAN are:CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # defaultCONFIGURE BACKUP OPTIMIZATION OFF; # defaultCONFIGURE DEFAULT DEVICE TYPE TO DISK; # defaultCONFIGURE CONTROLFILE AUTOBACKUP OFF; # defaultCONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # defaultCONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # defaultCONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE MAXSETSIZE TO UNLIMITED; # defaultCONFIGURE ENCRYPTION FOR DATABASE OFF; # defaultCONFIGURE ENCRYPTION ALGORITHM 'AES128'; # defaultCONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # defaultCONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # defaultCONFIGURE SNAPSHOT CONTROLFILE NAME TO 'E:\APP\TIANPAN\PRODUCT\11.2.0\DBHOME_1\DATABASE\SNCFPTIAN.ORA'; # defaultRMAN>红色部分的配置说明当前的备份方式为备份集备份。CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default不改变RMAN的配置,也可以直接以镜像复制的方式备份,命令为:RMAN> backup as copy database;Starting backup at 08-JUL-15allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=72 device type=DISKchannel ORA_DISK_1: starting datafile copyinput datafile file number=00001 name=E:\APP\TIANPAN\ORADATA\PTIAN\SYSTEM01.DBFoutput file name=E:\APP\TIANPAN\FLASH_RECOVERY_AREA\PTIAN\DATAFILE\O1_MF_SYSTEM_BSTBH904_.DBF tag=TAG20150708T214720 RECID=2 STAMP=884555266channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35channel ORA_DISK_1: starting datafile copyinput datafile file number=00002 name=E:\APP\TIANPAN\ORADATA\PTIAN\SYSAUX01.DBFoutput file name=E:\APP\TIANPAN\FLASH_RECOVERY_AREA\PTIAN\DATAFILE\O1_MF_SYSAUX_BSTBJDFQ_.DBF tag=TAG20150708T214720 RECID=3 STAMP=884555292channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25channel ORA_DISK_1: starting datafile copyinput datafile file number=00003 name=E:\APP\TIANPAN\ORADATA\PTIAN\UNDOTBS01.DBFoutput file name=E:\APP\TIANPAN\FLASH_RECOVERY_AREA\PTIAN\DATAFILE\O1_MF_UNDOTBS1_BSTBK5V1_.DBF tag=TAG20150708T214720 RECID=4 STAMP=884555305channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07channel ORA_DISK_1: starting datafile copyinput datafile file number=00005 name=E:\APP\TIANPAN\ORADATA\PTIAN\EXAMPLE01.DBFoutput file name=E:\APP\TIANPAN\FLASH_RECOVERY_AREA\PTIAN\DATAFILE\O1_MF_EXAMPLE_BSTBKF80_.DBF tag=TAG20150708T214720 RECID=5 STAMP=884555312channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03channel ORA_DISK_1: starting datafile copycopying current control fileoutput file name=E:\APP\TIANPAN\FLASH_RECOVERY_AREA\PTIAN\CONTROLFILE\O1_MF_TAG20150708T214720_BSTBKJJC_.CTL tag=TAG20150708T214720 RECID=6 STAMP=884555313channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01channel ORA_DISK_1: starting datafile copyinput datafile file number=00004 name=E:\APP\TIANPAN\ORADATA\PTIAN\USERS01.DBFoutput file name=E:\APP\TIANPAN\FLASH_RECOVERY_AREA\PTIAN\DATAFILE\O1_MF_USERS_BSTBKKVB_.DBF tag=TAG20150708T214720 RECID=7 STAMP=884555314channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01channel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setincluding current SPFILE in backup setchannel ORA_DISK_1: starting piece 1 at 08-JUL-15channel ORA_DISK_1: finished piece 1 at 08-JUL-15piece handle=E:\APP\TIANPAN\FLASH_RECOVERY_AREA\PTIAN\BACKUPSET\2015_07_08\O1_MF_NNSNF_TAG20150708T214720_BSTBKM7K_.BKP tag=TAG20150708T214720 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 08-JUL-15RMAN>当然你也可以修改RMAN的配置:RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COPY;old RMAN configuration parameters:CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;new RMAN configuration parameters:CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COPY;new RMAN configuration parameters are successfully storedRMAN> 配置备份类型的命令:To configure the default type of backup:Start RMAN and connect to a target database and a recovery catalog (if used).Configure backup sets or image copies as the default backup type.The following examples configure the backup type for disk backups to copies and backup sets:CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY; # image copies
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET; # uncompressedThe following examples configure compression for backup sets:CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DEVICE TYPE sbt BACKUP TYPE TO COMPRESSED BACKUPSET;