RMAN的backup命令是可以产生两种类型的备份:备份集和镜像复制。
具体产生哪种类型的备份,取决于backup命令,如果是backup as backupset,则生成备份集;如果是backup as copy,则生成镜像复制。
RMAN> show device type; //查看默认设备设置
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name STEST are:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default 默认设置是备份生成备份集。
RMAN> configure device type disk backup type to copy; //设置备份生成镜像复制
=====================================================================================
备份集(backup set):
备份集就是输入文件的备份,它是一个逻辑概念,物理上由备份片(backup piece)组成。一个备份集可以包含多个输入文件,一个输入文件可以分散在多个备份片上。例子如下:
RMAN> list backupset;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 1005.80M DISK 00:00:04 23-OCT-14
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20141023T111812
Piece Name: /oracle/app/oracle/fast_recovery_area/ZLB/backupset/2014_10_23/o1_mf_nnndf_TAG20141023T111812_b4jwvo17_.bkp
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1094205 23-OCT-14 /oracle/app/oracle/oradata/zlb/system01.dbf
2 Full 1094205 23-OCT-14 /oracle/app/oracle/oradata/zlb/sysaux01.dbf
3 Full 1094205 23-OCT-14 /oracle/app/oracle/oradata/zlb/undotbs01.dbf
4 Full 1094205 23-OCT-14 /oracle/app/oracle/oradata/zlb/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 9.36M DISK 00:00:01 23-OCT-14
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20141023T111812
Piece Name: /oracle/app/oracle/fast_recovery_area/ZLB/backupset/2014_10_23/o1_mf_ncsnf_TAG20141023T111812_b4jwvx3s_.bkp
SPFILE Included: Modification time: 22-OCT-14
SPFILE db_unique_name: ZLB
Control File Included: Ckp SCN: 1094209 Ckp time: 23-OCT-14
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 1.01G DISK 00:00:10 23-OCT-14
List of Datafiles in backup set 3
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1122962 23-OCT-14 /oracle/app/oracle/oradata/zlb/system01.dbf
2 Full 1122962 23-OCT-14 /oracle/app/oracle/oradata/zlb/sysaux01.dbf
3 Full 1122962 23-OCT-14 /oracle/app/oracle/oradata/zlb/undotbs01.dbf
4 Full 1122962 23-OCT-14 /oracle/app/oracle/oradata/zlb/users01.dbf
Backup Set Copy #1 of backup set 3
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:10 23-OCT-14 NO TAG20141023T225841
List of Backup Pieces for backup set 3 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
3 1 AVAILABLE /oracle/app/oracle/fast_recovery_area/ZLB/backupset/2014_10_23/o1_mf_nnndf_TAG20141023T225841_b4l5x1ph_.bkp
4 2 AVAILABLE /oracle/app/oracle/fast_recovery_area/ZLB/backupset/2014_10_23/o1_mf_nnndf_TAG20141023T225841_b4l5x8pw_.bkp
5 3 AVAILABLE /oracle/app/oracle/fast_recovery_area/ZLB/backupset/2014_10_23/o1_mf_nnndf_TAG20141023T225841_b4l5xcq0_.bkp
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Full 9.36M DISK 00:00:01 23-OCT-14
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20141023T225841
Piece Name: /oracle/app/oracle/fast_recovery_area/ZLB/backupset/2014_10_23/o1_mf_ncsnf_TAG20141023T225841_b4l5xftm_.bkp
SPFILE Included: Modification time: 23-OCT-14
SPFILE db_unique_name: ZLB
Control File Included: Ckp SCN: 1122966 Ckp time: 23-OCT-14
=================================================================================================================
backup命令生成的备份集的数量由以下几个因素决定:
1、输入文件的数量:
一个备份集默认情况下最多可以容纳64个输入文件。这个默认值可以由filesperset子句来修改:
backup as backupset tablespace users filesperset 1; //定义一个备份集只能有一个输入文件
2、并行度:
备份集的数量不会低于backuo并行度的数量。
(并行度:和通道数有关,一般情况下,有几个通道就可以认为并行度是几。但是,也有例外情况,如:
RMAN> configure device type disk parallelism 2; //设置默认并行度为2,备份的时候,rman会自动分配两个通道。但是这两个通道只有在输入文件有两个或者两个以上时,才有意义。否则,只有一个通道会工作,此时,并行度可以认为是1。
可以为每一个通道设置备份路径,如:
RMAN> configure channel 1 device type disk to destination '/home/oracle/disk1/';
RMAN> configure channel 2 device type disk to destination '/home/oracle/disk2/';
如果配置的通道数目少于parallelism定义的并行度,则少的通道的备份路径会由快速恢复区或者$ORACLE_HOME/dbs目录代替。
)
3、输入文件的种类:
有些文件是不能再同一个备份集中的。数据文件、归档日志是单独占用备份集,控制文件和参数文件可以共用备份集。
这是因为组成这些文件的最小单位block_size不一致:
SQL> select distinct BLOCK_SIZE from v$datafile;
BLOCK_SIZE
-----------------
8192
SQL> select distinct BLOCK_SIZE from v$controlfile;
BLOCK_SIZE
----------------
16384
SQL> select distinct BLOCK_SIZE from v$archived_log;
BLOCK_SIZE
-----------------
512
另外:只要备份1号数据文件(即system表空间),rman就会自发备份控制文件和参数文件,如:
RMAN> backup as backupset datafile 1;
Starting backup at 05-NOV-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA1/stest/datafile/system.256.926893851
channel ORA_DISK_1: starting piece 1 at 05-NOV-16
channel ORA_DISK_1: finished piece 1 at 05-NOV-16
piece handle=/opt/test/channel_0qrk3vo1_1_1 tag=TAG20161105T000001 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:58
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 05-NOV-16
channel ORA_DISK_1: finished piece 1 at 05-NOV-16
piece handle=/opt/test/channel_0rrk3vps_1_1 tag=TAG20161105T000001 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-NOV-16
4、小括号的使用
小括号起到隔离的作用,不在同一个小括号内的输入文件一定不会再同一个备份集中,但是在一个小括号内的输入文件不一定会在一个备份集中。
例子:
RMAN> run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
backup (datafile 4) (datafile 5);
} //生成两个备份集
RMAN> run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
backup (datafile 4,5) (datafile 6);
} //生产三个备份集,因为通道有三个,并行度为3
RMAN> run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
backup (datafile 4,5 channel c1) (datafile 6 channel c2);
} //生成两个备份集,因为指定了通道
5、“plus archivelog”子句
最后:
在备份时,一个通道中,RMAN同时读取多个输入文件的数据并将其写入到同一个备份片中的操作被称为多路传输。同时被读取的输入文件的数量称之为多路传输等级。该等级等于以下三个数中的最小值:
(1)通道的maxopenfiles,如 RMAN> allocate channel c1 device type disk maxopenfiles 2;
(2)通道的输入文件数量
(3)backup命令中的filesperset的值,如果没有定义filesperset,则取默认值64
总结:一个通道时:备份集产生个数的多少,可以用输入文件的个数除以多路传输等级来计算。多路传输等级的确定上面已经介绍了。
一个以上的通道时,考虑上文中的第二点并行度。
然后,无论一个通道还是一个以上通道,需要考虑上文中的第三点、第四点、第五点,基本上就可以知道会生成多少个备份集了。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28497416/viewspace-2127829/,如需转载,请注明出处,否则将追究法律责任。
只作为学习记录