一個RMAN備份集所包含的資料檔案個數是由哪些因素來決定的?

oliseh發表於2015-08-05

前不久在處理一個RMAN備份問題時,想到過這樣一個問題:一個RMAN backupset裡會包含多少個資料檔案?經過之後的一系列測試得到的結論是:
一個Backupset裡包含多少個datafile,與備份使用的通道數量、filesperset的設定,所備份的資料檔案總數都有關係,與maxopenfiles的值是無關的以下是我對這個問題的詳細測試驗證過程,劃分了多個不同場景,每一個測試步驟後都附有量化的測試結論(綠色字型的部分)

(1)使用一根通道進行備份的情況


******************** one channel、maxopenfiles 1、filesperset 4
RMAN> run
2> {
3> allocate channel d1 device type disk format '/oradata06/vlib/%U' maxopenfiles 1;
4> backup filesperset 4 database;
5> }


allocated channel: d1
channel d1: SID=992 device type=DISK


Starting backup at 20150605 13:15:56
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata06/testaaaaa/system01.dbf
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
input datafile file number=00007 name=/oradata06/testaaaaa/ts0212.dbf
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
channel d1: starting piece 1 at 20150605 13:15:57
channel d1: finished piece 1 at 20150605 13:16:32
piece handle=/oradata06/vlib/0mq8nsod_1_1 tag=TAG20150605T131556 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:35
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00009 name=/oradata06/testaaaaa/ts0422_1.dbf
input datafile file number=00006 name=/oradata06/testaaaaa/xdbts1.dbf
channel d1: starting piece 1 at 20150605 13:16:32
channel d1: finished piece 1 at 20150605 13:16:47
piece handle=/oradata06/vlib/0nq8nspg_1_1 tag=TAG20150605T131556 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:15
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
input datafile file number=00005 name=/oradata06/testaaaaa/ts0329_1.dbf
input datafile file number=00008 name=/oradata06/testaaaaa/ts0212_1.dbf
channel d1: starting piece 1 at 20150605 13:16:47
channel d1: finished piece 1 at 20150605 13:16:54
piece handle=/oradata06/vlib/0oq8nspv_1_1 tag=TAG20150605T131556 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:07
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel d1: starting piece 1 at 20150605 13:16:55
channel d1: finished piece 1 at 20150605 13:16:56
piece handle=/oradata06/vlib/0pq8nsq6_1_1 tag=TAG20150605T131556 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:01
Finished backup at 20150605 13:16:56
released channel: d1


******************** one channel、maxopenfiles 2、filesperset 4
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U' maxopenfiles 2;
backup filesperset 4 database;
}
allocated channel: d1
channel d1: SID=992 device type=DISK


Starting backup at 20150605 13:23:19
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata06/testaaaaa/system01.dbf
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
input datafile file number=00007 name=/oradata06/testaaaaa/ts0212.dbf
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
channel d1: starting piece 1 at 20150605 13:23:19
channel d1: finished piece 1 at 20150605 13:23:44
piece handle=/oradata06/vlib/0rq8nt67_1_1 tag=TAG20150605T132319 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:25
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00009 name=/oradata06/testaaaaa/ts0422_1.dbf
input datafile file number=00006 name=/oradata06/testaaaaa/xdbts1.dbf
channel d1: starting piece 1 at 20150605 13:23:45
channel d1: finished piece 1 at 20150605 13:24:00
piece handle=/oradata06/vlib/0sq8nt71_1_1 tag=TAG20150605T132319 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:15
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
input datafile file number=00005 name=/oradata06/testaaaaa/ts0329_1.dbf
input datafile file number=00008 name=/oradata06/testaaaaa/ts0212_1.dbf
channel d1: starting piece 1 at 20150605 13:24:00
channel d1: finished piece 1 at 20150605 13:24:07
piece handle=/oradata06/vlib/0tq8nt7g_1_1 tag=TAG20150605T132319 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:07
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel d1: starting piece 1 at 20150605 13:24:08
channel d1: finished piece 1 at 20150605 13:24:09
piece handle=/oradata06/vlib/0uq8nt7n_1_1 tag=TAG20150605T132319 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:01
Finished backup at 20150605 13:24:09
released channel: d1


******************** one channel、maxopenfiles 8、filesperset 4
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U' maxopenfiles 8;
backup filesperset 4 database;
}


allocated channel: d1
channel d1: SID=992 device type=DISK


Starting backup at 20150605 13:25:41
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata06/testaaaaa/system01.dbf
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
input datafile file number=00007 name=/oradata06/testaaaaa/ts0212.dbf
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
channel d1: starting piece 1 at 20150605 13:25:41
channel d1: finished piece 1 at 20150605 13:26:06
piece handle=/oradata06/vlib/0vq8ntal_1_1 tag=TAG20150605T132541 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:25
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00009 name=/oradata06/testaaaaa/ts0422_1.dbf
input datafile file number=00006 name=/oradata06/testaaaaa/xdbts1.dbf
channel d1: starting piece 1 at 20150605 13:26:06
channel d1: finished piece 1 at 20150605 13:26:21
piece handle=/oradata06/vlib/10q8ntbe_1_1 tag=TAG20150605T132541 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:15
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
input datafile file number=00005 name=/oradata06/testaaaaa/ts0329_1.dbf
input datafile file number=00008 name=/oradata06/testaaaaa/ts0212_1.dbf
channel d1: starting piece 1 at 20150605 13:26:22
channel d1: finished piece 1 at 20150605 13:26:29
piece handle=/oradata06/vlib/11q8ntbu_1_1 tag=TAG20150605T132541 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:07
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel d1: starting piece 1 at 20150605 13:26:30
channel d1: finished piece 1 at 20150605 13:26:31
piece handle=/oradata06/vlib/12q8ntc5_1_1 tag=TAG20150605T132541 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:01
Finished backup at 20150605 13:26:31
released channel: d1


******************** one channel、maxopenfiles 8、filesperset 12
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U' maxopenfiles 8;
backup filesperset 12 database;
}


allocated channel: d1
channel d1: SID=992 device type=DISK


Starting backup at 20150605 13:28:16
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
input datafile file number=00009 name=/oradata06/testaaaaa/ts0422_1.dbf
input datafile file number=00001 name=/oradata06/testaaaaa/system01.dbf
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
input datafile file number=00006 name=/oradata06/testaaaaa/xdbts1.dbf
input datafile file number=00005 name=/oradata06/testaaaaa/ts0329_1.dbf
input datafile file number=00007 name=/oradata06/testaaaaa/ts0212.dbf
input datafile file number=00008 name=/oradata06/testaaaaa/ts0212_1.dbf
channel d1: starting piece 1 at 20150605 13:28:16
channel d1: finished piece 1 at 20150605 13:29:01
piece handle=/oradata06/vlib/13q8ntfg_1_1 tag=TAG20150605T132816 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:45
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel d1: starting piece 1 at 20150605 13:29:02
channel d1: finished piece 1 at 20150605 13:29:03
piece handle=/oradata06/vlib/14q8ntgt_1_1 tag=TAG20150605T132816 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:01
Finished backup at 20150605 13:29:03
released channel: d1


******************** one channel、maxopenfiles 4、filesperset 12
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U' maxopenfiles 4;
backup filesperset 12 database;
}


allocated channel: d1
channel d1: SID=992 device type=DISK


Starting backup at 20150605 13:30:25
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
input datafile file number=00009 name=/oradata06/testaaaaa/ts0422_1.dbf
input datafile file number=00001 name=/oradata06/testaaaaa/system01.dbf
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
input datafile file number=00006 name=/oradata06/testaaaaa/xdbts1.dbf
input datafile file number=00005 name=/oradata06/testaaaaa/ts0329_1.dbf
input datafile file number=00007 name=/oradata06/testaaaaa/ts0212.dbf
input datafile file number=00008 name=/oradata06/testaaaaa/ts0212_1.dbf
channel d1: starting piece 1 at 20150605 13:30:26
channel d1: finished piece 1 at 20150605 13:31:01
piece handle=/oradata06/vlib/15q8ntji_1_1 tag=TAG20150605T133026 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:35
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel d1: starting piece 1 at 20150605 13:31:02
channel d1: finished piece 1 at 20150605 13:31:03
piece handle=/oradata06/vlib/16q8ntkl_1_1 tag=TAG20150605T133026 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:01
Finished backup at 20150605 13:31:03
released channel: d1


以上所有one channel情況下生成的backupset,backupset裡的datafile數量由min[filesperset,這根通道讀取的Datafile數量]決定,因為只有一根通道所以這根通道讀取的datafile數量等價於backup命令裡所包含的datafile數量

 (2)使用兩根通道進行備份
******************** two channel、maxopenfiles 1、filesperset 4
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U' maxopenfiles 1;
allocate channel d2 device type disk format '/oradata06/vlib/%U' maxopenfiles 1;
backup filesperset 4 database;
}


allocated channel: d1
channel d1: SID=992 device type=DISK


allocated channel: d2
channel d2: SID=3 device type=DISK


Starting backup at 20150605 13:35:45
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata06/testaaaaa/system01.dbf
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
input datafile file number=00007 name=/oradata06/testaaaaa/ts0212.dbf
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
channel d1: starting piece 1 at 20150605 13:35:46
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
input datafile file number=00009 name=/oradata06/testaaaaa/ts0422_1.dbf
input datafile file number=00006 name=/oradata06/testaaaaa/xdbts1.dbf
channel d2: starting piece 1 at 20150605 13:35:46
channel d2: finished piece 1 at 20150605 13:36:11
piece handle=/oradata06/vlib/18q8ntti_1_1 tag=TAG20150605T133546 comment=NONE
channel d2: backup set complete, elapsed time: 00:00:25
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
input datafile file number=00005 name=/oradata06/testaaaaa/ts0329_1.dbf
input datafile file number=00008 name=/oradata06/testaaaaa/ts0212_1.dbf
channel d2: starting piece 1 at 20150605 13:36:11
channel d1: finished piece 1 at 20150605 13:36:26
piece handle=/oradata06/vlib/17q8ntti_1_1 tag=TAG20150605T133546 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:40
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
channel d2: finished piece 1 at 20150605 13:36:26
piece handle=/oradata06/vlib/19q8ntub_1_1 tag=TAG20150605T133546 comment=NONE
channel d2: backup set complete, elapsed time: 00:00:15
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
including current SPFILE in backup set
channel d2: starting piece 1 at 20150605 13:36:27
including current control file in backup set
channel d1: starting piece 1 at 20150605 13:36:28
channel d2: finished piece 1 at 20150605 13:36:28
piece handle=/oradata06/vlib/1bq8ntur_1_1 tag=TAG20150605T133546 comment=NONE
channel d2: backup set complete, elapsed time: 00:00:01
channel d1: finished piece 1 at 20150605 13:36:29
piece handle=/oradata06/vlib/1aq8ntuq_1_1 tag=TAG20150605T133546 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:01
Finished backup at 20150605 13:36:29
released channel: d1
released channel: d2


RMAN> list backup summary tag TAG20150605T133546;


List of Backups
===============
Key     TY LV S Device Type Completion Time   #Pieces #Copies Compressed Tag
------- -- -- - ----------- ----------------- ------- ------- ---------- ---
38      B  F  A DISK        20150605 13:36:03 1       1       NO         TAG20150605T133546
39      B  F  A DISK        20150605 13:36:20 1       1       NO         TAG20150605T133546
40      B  F  A DISK        20150605 13:36:21 1       1       NO         TAG20150605T133546
41      B  F  A DISK        20150605 13:36:27 1       1       NO         TAG20150605T133546
42      B  F  A DISK        20150605 13:36:28 1       1       NO         TAG20150605T133546


2個channel的情況下,其中前三個是datafile的backupset,共9個datafile,生成了3個backupset(BS_key=38、39、40),每個backupset包含1個backup piece,得到這樣的結果是因為:9個datafile,兩根channel,按照平均分佈的規則,一根channel讀取4個datafile,一根channel讀取5個datafile,但因為filesperset=4,每根channel生成的backupset所包含的檔案數量由min[filesperset,這條通道讀取的Datafile數量]決定,此例中filesperset決定了這個最小值是4,所以每個backupset裡的檔案數<=4,9個datafile最終就生成了3個backupset,分別包含4個、2個、3個datafile


******************** two channel、maxopenfiles 2、filesperset 4
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U' maxopenfiles 2;
allocate channel d2 device type disk format '/oradata06/vlib/%U' maxopenfiles 2;
backup filesperset 4 database;
}


結果同上
******************** two channel、maxopenfiles 8、filesperset 4
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U' maxopenfiles 8;
allocate channel d2 device type disk format '/oradata06/vlib/%U' maxopenfiles 8;
backup filesperset 4 database;
}


結果同上
******************** two channel、maxopenfiles 8、filesperset 12
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U' maxopenfiles 8;
allocate channel d2 device type disk format '/oradata06/vlib/%U' maxopenfiles 8;
backup filesperset 12 database;
}


allocated channel: d1
channel d1: SID=992 device type=DISK


allocated channel: d2
channel d2: SID=3 device type=DISK


Starting backup at 20150605 14:03:41
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00009 name=/oradata06/testaaaaa/ts0422_1.dbf
input datafile file number=00001 name=/oradata06/testaaaaa/system01.dbf
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
input datafile file number=00007 name=/oradata06/testaaaaa/ts0212.dbf
channel d1: starting piece 1 at 20150605 14:03:42
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
input datafile file number=00006 name=/oradata06/testaaaaa/xdbts1.dbf
input datafile file number=00005 name=/oradata06/testaaaaa/ts0329_1.dbf
input datafile file number=00008 name=/oradata06/testaaaaa/ts0212_1.dbf
channel d2: starting piece 1 at 20150605 14:03:42
channel d2: finished piece 1 at 20150605 14:04:07
piece handle=/oradata06/vlib/1nq8nvhu_1_1 tag=TAG20150605T140341 comment=NONE
channel d2: backup set complete, elapsed time: 00:00:25
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
including current control file in backup set
channel d2: starting piece 1 at 20150605 14:04:08
channel d2: finished piece 1 at 20150605 14:04:09
piece handle=/oradata06/vlib/1oq8nvin_1_1 tag=TAG20150605T140341 comment=NONE
channel d2: backup set complete, elapsed time: 00:00:01
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
including current SPFILE in backup set
channel d2: starting piece 1 at 20150605 14:04:09
channel d2: finished piece 1 at 20150605 14:04:10
piece handle=/oradata06/vlib/1pq8nvip_1_1 tag=TAG20150605T140341 comment=NONE
channel d2: backup set complete, elapsed time: 00:00:01
channel d1: finished piece 1 at 20150605 14:04:24
piece handle=/oradata06/vlib/1mq8nvhu_1_1 tag=TAG20150605T140341 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:42
Finished backup at 20150605 14:04:24
released channel: d1
released channel: d2


list backup summary tag TAG20150605T140341;
List of Backups
===============
Key     TY LV S Device Type Completion Time   #Pieces #Copies Compressed Tag
------- -- -- - ----------- ----------------- ------- ------- ---------- ---
53      B  F  A DISK        20150605 14:04:06 1       1       NO         TAG20150605T140341
54      B  F  A DISK        20150605 14:04:08 1       1       NO         TAG20150605T140341
55      B  F  A DISK        20150605 14:04:09 1       1       NO         TAG20150605T140341
56      B  F  A DISK        20150605 14:04:17 1       1       NO         TAG20150605T140341


兩根channel,filesperset=12,9個datafile,channel d1讀取4個datafile,channel d2讀取了5個datafile,根據min[filesperset,這條通道讀取的Datafile數量]公式,channel d1生成的backupset裡包含有4個datafile,channel d2生成的backupset裡包含有5個datafile,9個Datafile備份後最終生成了2個Backupset

******************** two channel、maxopenfiles 4、filesperset 12
結果同上,因為maxopenfiles=4,區別在於channel d2所生成的backuppiece裡,5個datafile呈如下分佈狀態
df3 df4 df6 df5
df3 df4 df6 df5
.....
df3 df4 df6 df5
df8 df8 df8 df8
....
df8 df8 df8 df8


而maxopenfiles=4得例子裡,channel d2所生成的backuppiece裡,5個datafile呈如下分佈狀態
df3 df4 df6 df5
df8 df3 df4 df6
df5 df8  ..... ..... 
.....  ......  ..... df3
df4 df6 df5 df8


%%%%%%%%%%結論
歸納一下RMAN備份集裡的幾個重要概念
1、Number of files in each backupset,一個backupset裡包含的datafile個數由哪些因素決定?
我們把需要備份的datafile個數記為number of datafiles
一根channel:
如果number of datafiles<filesperset,Number of files in each backup=Number of datafiles
如果number of datafiles>=filesperset,Number of files in each backup<=filesperset


多根channel:
如果Number of channels=<number of datafiles <filesperset,Number of files in each backupset<=ceil(Number of datafiles/Number of channels)

驗證過程:
***Number of channels=3,number of datafiles=7,filesperset=8,Number of files in each backupset<=ceil(7/3)=3
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U';
allocate channel d2 device type disk format '/oradata06/vlib/%U';
allocate channel d3 device type disk format '/oradata06/vlib/%U';
backup filesperset 8 datafile 2,3,4,5,6,7,8;
}


allocated channel: d1
channel d1: SID=134 device type=DISK


allocated channel: d2
channel d2: SID=928 device type=DISK


allocated channel: d3
channel d3: SID=729 device type=DISK


Starting backup at 20150605 16:40:47
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
channel d1: starting piece 1 at 20150605 16:40:48
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
input datafile file number=00006 name=/oradata06/testaaaaa/xdbts1.dbf
input datafile file number=00008 name=/oradata06/testaaaaa/ts0212_1.dbf
channel d2: starting piece 1 at 20150605 16:40:48
channel d3: starting full datafile backup set
channel d3: specifying datafile(s) in backup set
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
input datafile file number=00005 name=/oradata06/testaaaaa/ts0329_1.dbf
input datafile file number=00007 name=/oradata06/testaaaaa/ts0212.dbf
channel d3: starting piece 1 at 20150605 16:40:48
channel d1: finished piece 1 at 20150605 16:41:03
piece handle=/oradata06/vlib/3eq8o8og_1_1 tag=TAG20150605T164047 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:15
channel d2: finished piece 1 at 20150605 16:41:13
piece handle=/oradata06/vlib/3fq8o8og_1_1 tag=TAG20150605T164047 comment=NONE
channel d2: backup set complete, elapsed time: 00:00:25
channel d3: finished piece 1 at 20150605 16:41:13
piece handle=/oradata06/vlib/3gq8o8og_1_1 tag=TAG20150605T164047 comment=NONE
channel d3: backup set complete, elapsed time: 00:00:25
Finished backup at 20150605 16:41:13
released channel: d1
released channel: d2
released channel: d3


如果number of datafiles <Number of channels<filesperset,那麼僅有和number of datafiles相等數量的channel被使用,Number of files in each backupset=1;

驗證過程:

***Number of channels=4,number of datafiles=3,filesperset=8,Number of files in each backupset=1
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U';
allocate channel d2 device type disk format '/oradata06/vlib/%U';
allocate channel d3 device type disk format '/oradata06/vlib/%U';
allocate channel d4 device type disk format '/oradata06/vlib/%U';
backup filesperset 8 datafile 2,3,4;
}


allocated channel: d1
channel d1: SID=134 device type=DISK


allocated channel: d2
channel d2: SID=928 device type=DISK


allocated channel: d3
channel d3: SID=729 device type=DISK


allocated channel: d4
channel d4: SID=467 device type=DISK


Starting backup at 20150605 16:43:21
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
channel d1: starting piece 1 at 20150605 16:43:22
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
channel d2: starting piece 1 at 20150605 16:43:22
channel d3: starting full datafile backup set
channel d3: specifying datafile(s) in backup set
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
channel d3: starting piece 1 at 20150605 16:43:22
channel d1: finished piece 1 at 20150605 16:43:37
piece handle=/oradata06/vlib/3hq8o8t9_1_1 tag=TAG20150605T164321 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:15
channel d2: finished piece 1 at 20150605 16:43:47
piece handle=/oradata06/vlib/3iq8o8ta_1_1 tag=TAG20150605T164321 comment=NONE
channel d2: backup set complete, elapsed time: 00:00:25
channel d3: finished piece 1 at 20150605 16:43:47
piece handle=/oradata06/vlib/3jq8o8ta_1_1 tag=TAG20150605T164321 comment=NONE
channel d3: backup set complete, elapsed time: 00:00:25
Finished backup at 20150605 16:43:47
released channel: d1
released channel: d2
released channel: d3
released channel: d4


如果Number of datafiles>=filesperset,Number of files in each backupset<=min[ceil(Number of datafiles/Number of channels),filesperset]

驗證過程:

***Number of channels=4,number of datafiles=7,filesperset=2,Number of files in each backupset<=min[ceil(7/4),3]=2
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U';
allocate channel d2 device type disk format '/oradata06/vlib/%U';
allocate channel d3 device type disk format '/oradata06/vlib/%U';
allocate channel d4 device type disk format '/oradata06/vlib/%U';
backup filesperset 2 datafile 2,3,4,5,6,7,8;
}


allocated channel: d1
channel d1: SID=134 device type=DISK


allocated channel: d2
channel d2: SID=928 device type=DISK


allocated channel: d3
channel d3: SID=729 device type=DISK


allocated channel: d4
channel d4: SID=467 device type=DISK


Starting backup at 20150605 17:01:54
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
channel d1: starting piece 1 at 20150605 17:01:55
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
input datafile file number=00008 name=/oradata06/testaaaaa/ts0212_1.dbf
channel d2: starting piece 1 at 20150605 17:01:55
channel d3: starting full datafile backup set
channel d3: specifying datafile(s) in backup set
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
input datafile file number=00007 name=/oradata06/testaaaaa/ts0212.dbf
channel d3: starting piece 1 at 20150605 17:01:55
channel d4: starting full datafile backup set
channel d4: specifying datafile(s) in backup set
input datafile file number=00006 name=/oradata06/testaaaaa/xdbts1.dbf
input datafile file number=00005 name=/oradata06/testaaaaa/ts0329_1.dbf
channel d4: starting piece 1 at 20150605 17:01:55
channel d1: finished piece 1 at 20150605 17:02:10
piece handle=/oradata06/vlib/40q8oa03_1_1 tag=TAG20150605T170154 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:15
channel d4: finished piece 1 at 20150605 17:02:10
piece handle=/oradata06/vlib/43q8oa03_1_1 tag=TAG20150605T170154 comment=NONE
channel d4: backup set complete, elapsed time: 00:00:15
channel d2: finished piece 1 at 20150605 17:02:20
piece handle=/oradata06/vlib/41q8oa03_1_1 tag=TAG20150605T170154 comment=NONE
channel d2: backup set complete, elapsed time: 00:00:25
channel d3: finished piece 1 at 20150605 17:02:20
piece handle=/oradata06/vlib/42q8oa03_1_1 tag=TAG20150605T170154 comment=NONE
channel d3: backup set complete, elapsed time: 00:00:25
Finished backup at 20150605 17:02:20
released channel: d1
released channel: d2
released channel: d3
released channel: d4


如果Number of datafiles>=filesperset且Number of channels<filesperset,Number of files in each backupset<=min[ceil(Number of datafiles/Number of channels),filesperset]
驗證過程:
***Number of channels=3,number of datafiles=7,filesperset=5,Number of files in each backupset<=min[ceil(7/3),3]=3
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U';
allocate channel d2 device type disk format '/oradata06/vlib/%U';
allocate channel d3 device type disk format '/oradata06/vlib/%U';
backup filesperset 5 datafile 2,3,4,5,6,7,8;
}


allocated channel: d1
channel d1: SID=134 device type=DISK


allocated channel: d2
channel d2: SID=928 device type=DISK


allocated channel: d3
channel d3: SID=729 device type=DISK


Starting backup at 20150605 17:07:28
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
channel d1: starting piece 1 at 20150605 17:07:29
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
input datafile file number=00006 name=/oradata06/testaaaaa/xdbts1.dbf
input datafile file number=00008 name=/oradata06/testaaaaa/ts0212_1.dbf
channel d2: starting piece 1 at 20150605 17:07:29
channel d3: starting full datafile backup set
channel d3: specifying datafile(s) in backup set
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
input datafile file number=00005 name=/oradata06/testaaaaa/ts0329_1.dbf
input datafile file number=00007 name=/oradata06/testaaaaa/ts0212.dbf
channel d3: starting piece 1 at 20150605 17:07:29
channel d1: finished piece 1 at 20150605 17:07:44
piece handle=/oradata06/vlib/44q8oaah_1_1 tag=TAG20150605T170728 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:15
channel d2: finished piece 1 at 20150605 17:07:54
piece handle=/oradata06/vlib/45q8oaah_1_1 tag=TAG20150605T170728 comment=NONE
channel d2: backup set complete, elapsed time: 00:00:25
channel d3: finished piece 1 at 20150605 17:07:54
piece handle=/oradata06/vlib/46q8oaah_1_1 tag=TAG20150605T170728 comment=NONE
channel d3: backup set complete, elapsed time: 00:00:25
Finished backup at 20150605 17:07:54
released channel: d1
released channel: d2
released channel: d3


測試過程中還發現一個細節,把number of datafiles平均分佈到number of channels的時候如果有兩根channel上的datafile數量都要比其它channel少的時候,RMAN會棄用一根channel,比如下面的備份中分配了4根channel,6個datafiles,如果4根channel上都有Datafile的話,其分佈情況為
d1:1個datafile
d2:1個datafile
d3:2個datafile
d4:2個datafile
這時d1、d2兩根通道上的datafile就要比d3、d4少,RMAN只允許有一根channel上的Datafile數量少於其它channel,這樣做的目的是儘量保持每根Channel上的負載均衡,下面的輸出中可以看到d4雖被分配但未被使用,d1~d3每根channel上均分到了兩個datafile

驗證過程:

***Number of channels=4,number of datafiles=6,filesperset=3,Number of files in each backupset<=min[ceil(6/4),3]=2
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U';
allocate channel d2 device type disk format '/oradata06/vlib/%U';
allocate channel d3 device type disk format '/oradata06/vlib/%U';
allocate channel d4 device type disk format '/oradata06/vlib/%U';
backup filesperset 3 datafile 2,3,4,5,6,7;
}


allocated channel: d1
channel d1: SID=134 device type=DISK


allocated channel: d2
channel d2: SID=928 device type=DISK


allocated channel: d3
channel d3: SID=729 device type=DISK


allocated channel: d4
channel d4: SID=467 device type=DISK


Starting backup at 20150605 17:11:17
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00003 name=/oradata06/testaaaaa/undotbs01.dbf
input datafile file number=00007 name=/oradata06/testaaaaa/ts0212.dbf
channel d1: starting piece 1 at 20150605 17:11:18
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
input datafile file number=00002 name=/oradata06/testaaaaa/sysaux01.dbf
input datafile file number=00006 name=/oradata06/testaaaaa/xdbts1.dbf
channel d2: starting piece 1 at 20150605 17:11:18
channel d3: starting full datafile backup set
channel d3: specifying datafile(s) in backup set
input datafile file number=00004 name=/oradata06/testaaaaa/users01.dbf
input datafile file number=00005 name=/oradata06/testaaaaa/ts0329_1.dbf
channel d3: starting piece 1 at 20150605 17:11:18
channel d1: finished piece 1 at 20150605 17:11:33
piece handle=/oradata06/vlib/47q8oahm_1_1 tag=TAG20150605T171117 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:15
channel d2: finished piece 1 at 20150605 17:11:43
piece handle=/oradata06/vlib/48q8oahm_1_1 tag=TAG20150605T171117 comment=NONE
channel d2: backup set complete, elapsed time: 00:00:25
channel d3: finished piece 1 at 20150605 17:11:43
piece handle=/oradata06/vlib/49q8oahm_1_1 tag=TAG20150605T171117 comment=NONE
channel d3: backup set complete, elapsed time: 00:00:25
Finished backup at 20150605 17:11:43
released channel: d1
released channel: d2
released channel: d3
released channel: d4

附帶解釋一下什麼是RMAN Multiplexing
所謂RMAN multiplexing就是同一時刻有多少個datafile被同時寫入同一個backuppiece,RMAN multiplexing level由maxopenfiles和filesperset中的最小值決定,其中maxopenfiles代表一根channel可以同時讀取多少個datafile,RMAN multiplexing的效果體現為backuppiece各個資料檔案呈現間隔存放的狀態
run
{
allocate channel d1 device type disk format '/oradata06/vlib/%U' maxopenfiles 4;
backup datafile 1,2,3,4;
}


以上命令生成的backuppiece裡df1~df4大致按照如下方式存放
 -----------------
| df1 df2 df3 df4 |
 -----------------
| df1 df2 df3 df4 |
 -----------------
 
如果把上面的maxopenfiles 4改為maxopenfiles 3;
那麼生成backuppiece裡將會呈現如下分佈:
 -----------------
| df1 df2 df3 df1 |
 -----------------
| df2 df3 df4 df4 |
 -----------------

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/53956/viewspace-1763013/,如需轉載,請註明出處,否則將追究法律責任。

相關文章