本文出自 “大臉貓” 部落格,請務必保留此出處http://bfc99.blog.51cto.com/265386/1354771
感謝大臉貓的實驗分析結果。
下面以實驗的方式,展示在RUN塊中手工指定多信道(CHANNEL,也有稱之為“通道”) 與設定并行度PARALLELISM參數 的異同,以及FILESPERSET參數的作用。
RMAN備份時,為了加快備份的速度,提供了并行處理的方式。一種是設定多個信道,另一種是設定PARALLELISM參數。那麼這兩種方式有什麼不同呢?今天在實驗的方式來加深了解。
首先,我們來實驗第一種方式,即設定多個信道的方式。為了比較增加信道後的效果,我們先做一次單信道的備份操作。 [[email protected] ~]$ rman target / Recovery Manager: Release 10.2.0.5.0 - Production on Sat Jan 25 15:22:13 2014 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: ORCL (DBID=1347935162) RMAN> run { allocate channel c1 device type disk format '/oradata/orcl/databak1/%U'; backup database; release channel c1; }2> 3> 4> 5> using target database control file instead of recovery catalog allocated channel: c1 channel c1: sid=158 devtype=DISK Starting backup at 20140125 15:27:37 channel c1: starting full datafile backupset channel c1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf input datafile fno=00004 name=/oradata/orcl/users01.dbf input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf input datafile fno=00007 name=/oradata/orcl/system02.dbf channel c1: starting piece 1 at 20140125 15:27:38 channel c1: finished piece 1 at 20140125 15:28:23 piece handle=/oradata/orcl/databak1/8iouvaba_1_1 tag=TAG20140125T152737 comment=NONE channel c1: backup set complete, elapsed time: 00:00:45 Finished backup at 20140125 15:28:23 Starting Control File and SPFILE Autobackup at 20140125 15:28:23 piece handle=/oradata/orcl/databak/c-1347935162-20140125-08 comment=NONE Finished Control File and SPFILE Autobackup at 20140125 15:28:26 released channel: c1 可見,資料庫的備份時間約為49秒(15:27:37至15:28:26)。
下面我們設定2個信道,來執行備份。 RMAN> run { allocate channel c1 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c2 device type disk format '/oradata/orcl/databak1/%U'; backup database; release channel c1; release channel c2; }2> 3> 4> 5> 6> 7> allocated channel: c1 channel c1: sid=158 devtype=DISK allocated channel: c2 channel c2: sid=147 devtype=DISK Starting backup at 20140125 15:31:45 channel c1: starting full datafile backupset channel c1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf input datafile fno=00007 name=/oradata/orcl/system02.dbf input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf channel c1: starting piece 1 at 20140125 15:31:45 channel c2: starting full datafile backupset channel c2: specifying datafile(s) in backupset input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf input datafile fno=00004 name=/oradata/orcl/users01.dbf input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf channel c2: starting piece 1 at 20140125 15:31:45 channel c2: finished piece 1 at 20140125 15:32:00 piece handle=/oradata/orcl/databak1/8louvaj1_1_1 tag=TAG20140125T153145 comment=NONE channel c2: backup set complete, elapsed time: 00:00:15 channel c1: finished piece 1 at 20140125 15:32:35 piece handle=/oradata/orcl/databak1/8kouvaj1_1_1 tag=TAG20140125T153145 comment=NONE channel c1: backup set complete, elapsed time: 00:00:50 Finished backup at 20140125 15:32:35 Starting Control File and SPFILE Autobackup at 20140125 15:32:35 piece handle=/oradata/orcl/databak/c-1347935162-20140125-09 comment=NONE Finished Control File and SPFILE Autobackup at 20140125 15:32:38 released channel: c1 released channel: c2 2個信道的情況下,備份時間約為53秒(15:31:45至15:32:38)。時間上還要慢了一些。 而且,我們發現,組成資料庫的資料檔案一共有6個,當用2個信道備份時,其自動分成了兩組,每組3個檔案。 備份結束後,每個信道生成一個備份檔案,共兩個備份檔案。 我們再試試3個信道時的情況 RMAN> run { allocate channel c1 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c2 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c3 device type disk format '/oradata/orcl/databak1/%U'; backup database; release channel c1; release channel c2; release channel c3; }2> 3> 4> 5> 6> 7> 8> 9> allocated channel: c1 channel c1: sid=158 devtype=DISK allocated channel: c2 channel c2: sid=147 devtype=DISK allocated channel: c3 channel c3: sid=138 devtype=DISK Starting backup at 20140125 15:39:06 channel c1: starting full datafile backupset channel c1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf input datafile fno=00007 name=/oradata/orcl/system02.dbf channel c1: starting piece 1 at 20140125 15:39:07 channel c2: starting full datafile backupset channel c2: specifying datafile(s) in backupset input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf channel c2: starting piece 1 at 20140125 15:39:07 channel c3: starting full datafile backupset channel c3: specifying datafile(s) in backupset input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf input datafile fno=00004 name=/oradata/orcl/users01.dbf channel c3: starting piece 1 at 20140125 15:39:07 channel c2: finished piece 1 at 20140125 15:39:14 piece handle=/oradata/orcl/databak1/8oouvb0r_1_1 tag=TAG20140125T153906 comment=NONE channel c2: backup set complete, elapsed time: 00:00:07 channel c1: finished piece 1 at 20140125 15:39:59 piece handle=/oradata/orcl/databak1/8nouvb0r_1_1 tag=TAG20140125T153906 comment=NONE channel c1: backup set complete, elapsed time: 00:00:52 channel c3: finished piece 1 at 20140125 15:39:59 piece handle=/oradata/orcl/databak1/8pouvb0r_1_1 tag=TAG20140125T153906 comment=NONE channel c3: backup set complete, elapsed time: 00:00:52 Finished backup at 20140125 15:39:59 Starting Control File and SPFILE Autobackup at 20140125 15:39:59 piece handle=/oradata/orcl/databak/c-1347935162-20140125-0a comment=NONE Finished Control File and SPFILE Autobackup at 20140125 15:40:02 released channel: c1 released channel: c2 released channel: c3 3個信道的情況下,備份時間約為56秒(15:39:06至15:40:02) 而且,6個資料檔案也被分成了三組,每組2個檔案。那麼如果我設成4個信道,6個檔案會如何分組呢? RMAN> run { allocate channel c1 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c2 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c3 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c4 device type disk format '/oradata/orcl/databak1/%U'; backup database; release channel c1; release channel c2; release channel c3; release channel c4; } 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> allocated channel: c1 channel c1: sid=158 devtype=DISK allocated channel: c2 channel c2: sid=147 devtype=DISK allocated channel: c3 channel c3: sid=138 devtype=DISK allocated channel: c4 channel c4: sid=137 devtype=DISK Starting backup at 20140125 15:42:49 channel c1: starting full datafile backupset channel c1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf input datafile fno=00007 name=/oradata/orcl/system02.dbf channel c1: starting piece 1 at 20140125 15:42:49 channel c2: starting full datafile backupset channel c2: specifying datafile(s) in backupset input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf channel c2: starting piece 1 at 20140125 15:42:49 channel c3: starting full datafile backupset channel c3: specifying datafile(s) in backupset input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf input datafile fno=00004 name=/oradata/orcl/users01.dbf channel c3: starting piece 1 at 20140125 15:42:49 channel c2: finished piece 1 at 20140125 15:43:04 piece handle=/oradata/orcl/databak1/8souvb7p_1_1 tag=TAG20140125T154249 comment=NONE channel c2: backup set complete, elapsed time: 00:00:15 channel c3: finished piece 1 at 20140125 15:43:39 piece handle=/oradata/orcl/databak1/8touvb7p_1_1 tag=TAG20140125T154249 comment=NONE channel c3: backup set complete, elapsed time: 00:00:50 channel c1: finished piece 1 at 20140125 15:43:46 piece handle=/oradata/orcl/databak1/8rouvb7p_1_1 tag=TAG20140125T154249 comment=NONE channel c1: backup set complete, elapsed time: 00:00:57 Finished backup at 20140125 15:43:46 Starting Control File and SPFILE Autobackup at 20140125 15:43:46 piece handle=/oradata/orcl/databak/c-1347935162-20140125-0b comment=NONE Finished Control File and SPFILE Autobackup at 20140125 15:43:47 released channel: c1 released channel: c2 released channel: c3 released channel: c4 配置設定了4個信道,但備份過程中,隻實際使用了3個。備份的時間為58秒(15:42:49至15:43:47 )。
到了這裡,看來RMAN是在各個信道間平均配置設定檔案數量的。推測一下,如果設成6個信道,應該就是一個檔案一個信道了。 RMAN> run { allocate channel c1 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c2 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c3 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c4 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c5 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c6 device type disk format '/oradata/orcl/databak1/%U'; backup database; release channel c1; release channel c2; release channel c3; release channel c4; release channel c5; release channel c6; }2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> allocated channel: c1 channel c1: sid=158 devtype=DISK allocated channel: c2 channel c2: sid=147 devtype=DISK allocated channel: c3 channel c3: sid=138 devtype=DISK allocated channel: c4 channel c4: sid=137 devtype=DISK allocated channel: c5 channel c5: sid=156 devtype=DISK allocated channel: c6 channel c6: sid=155 devtype=DISK Starting backup at 20140125 15:57:58 channel c1: starting full datafile backupset channel c1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf channel c1: starting piece 1 at 20140125 15:57:58 channel c2: starting full datafile backupset channel c2: specifying datafile(s) in backupset input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf channel c2: starting piece 1 at 20140125 15:57:58 channel c3: starting full datafile backupset channel c3: specifying datafile(s) in backupset input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf channel c3: starting piece 1 at 20140125 15:57:58 channel c4: starting full datafile backupset channel c4: specifying datafile(s) in backupset input datafile fno=00004 name=/oradata/orcl/users01.dbf channel c4: starting piece 1 at 20140125 15:57:58 channel c5: starting full datafile backupset channel c5: specifying datafile(s) in backupset input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf channel c5: starting piece 1 at 20140125 15:57:58 channel c6: starting full datafile backupset channel c6: specifying datafile(s) in backupset input datafile fno=00007 name=/oradata/orcl/system02.dbf channel c6: starting piece 1 at 20140125 15:57:58 channel c5: finished piece 1 at 20140125 15:58:01 piece handle=/oradata/orcl/databak1/93ouvc46_1_1 tag=TAG20140125T155758 comment=NONE channel c5: backup set complete, elapsed time: 00:00:03 channel c2: finished piece 1 at 20140125 15:58:08 piece handle=/oradata/orcl/databak1/90ouvc46_1_1 tag=TAG20140125T155758 comment=NONE channel c2: backup set complete, elapsed time: 00:00:10 channel c6: finished piece 1 at 20140125 15:58:08 piece handle=/oradata/orcl/databak1/94ouvc46_1_1 tag=TAG20140125T155758 comment=NONE channel c6: backup set complete, elapsed time: 00:00:10 channel c4: finished piece 1 at 20140125 15:58:11 piece handle=/oradata/orcl/databak1/92ouvc46_1_1 tag=TAG20140125T155758 comment=NONE channel c4: backup set complete, elapsed time: 00:00:13 channel c3: finished piece 1 at 20140125 15:58:36 piece handle=/oradata/orcl/databak1/91ouvc46_1_1 tag=TAG20140125T155758 comment=NONE channel c3: backup set complete, elapsed time: 00:00:39 channel c1: finished piece 1 at 20140125 15:58:52 piece handle=/oradata/orcl/databak1/8vouvc46_1_1 tag=TAG20140125T155758 comment=NONE channel c1: backup set complete, elapsed time: 00:00:54 Finished backup at 20140125 15:58:52 Starting Control File and SPFILE Autobackup at 20140125 15:58:52 piece handle=/oradata/orcl/databak/c-1347935162-20140125-0c comment=NONE Finished Control File and SPFILE Autobackup at 20140125 15:58:55 released channel: c1 released channel: c2 released channel: c3 released channel: c4 released channel: c5 released channel: c6 果然,如推測中的一樣。是一個信道一個檔案,最終生成了6個備份檔案。總用時約57秒(15:57:58至 15:58:55) 經過以上實驗,得出以下結論: 1、增加信道,RMAN會并行處理備份任務,但根據硬體環境的不同,并不是越多越快。以本次實驗來說,備份時間最省的,卻是隻有一個信道的時候。這可能是因為實驗環境為一跑在普通桌上型電腦上的虛拟機所緻,其本身的并行處理能力就低。 2、當設有多個信道時,資料檔案會平均配置設定至各個信道上。若檔案不能全部均分至所有信道上,則會放棄部分信道的使用。例如上面實驗中的6個資料檔案在4個信道上備份時,則實際上隻使用了3個信道。可是,假如組成資料庫的資料檔案的個數是質數(隻能被它自己和1整除的數),比如7個檔案。當設定為4個信道時,會如何配置設定呢?由于無論是用4個,還是3個或2個信道,我們都不能把資料檔案均分到信道上。這裡先賣個關子,為了保證我們下面的實驗可以在相同的環境下完成,這個實驗,我們放到最後。 3、自動備份的控制檔案和參數檔案并沒有備份到信道指定的位置(/oradata/orcl/databak1),而放存放到了RMAN中配置的“控制檔案自動備份”所指定的位置(見下面紅字部分)。 RMAN> show all; RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oradata/orcl/databak/%F'; CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/oradata/orcl/databak/%U'; CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE ENCRYPTION FOR DATABASE OFF; # default CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/app/oracle/product/10.2/db_1/dbs/snapcf_orcl.f'; # default 現在再來看并行度PARALLELISM這個參數。這個參數要通過輸入以下指令來設定(這裡設定的并行度為3): RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters are successfully stored 我們再執行一個信道的備份,看看是什麼效果。 RMAN> run { allocate channel c1 device type disk format '/oradata/orcl/databak1/%U'; backup database; release channel c1; }2> 3> 4> 5> allocated channel: c1 channel c1: sid=158 devtype=DISK Starting backup at 20140125 16:20:32 channel c1: starting full datafile backupset channel c1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf input datafile fno=00004 name=/oradata/orcl/users01.dbf input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf input datafile fno=00007 name=/oradata/orcl/system02.dbf channel c1: starting piece 1 at 20140125 16:20:32 channel c1: finished piece 1 at 20140125 16:21:17 piece handle=/oradata/orcl/databak1/9bouvdeg_1_1 tag=TAG20140125T162032 comment=NONE channel c1: backup set complete, elapsed time: 00:00:45 Finished backup at 20140125 16:21:17 Starting Control File and SPFILE Autobackup at 20140125 16:21:17 piece handle=/oradata/orcl/databak/c-1347935162-20140125-0f comment=NONE Finished Control File and SPFILE Autobackup at 20140125 16:21:18 released channel: c1 嘿嘿,在RUN塊中指定信道時,這個參數是不管用的。也就是說,你在RUN塊内指定了幾個信道,就用幾個信道去備份,與這個PARALLELISM這個參數無關。 那我們直接在RMAN中輸入BACKUP DATABASE;會是什麼效果呢? RMAN> backup database; Starting backup at 20140125 16:24:41 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=158 devtype=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: sid=147 devtype=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: sid=138 devtype=DISK channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf input datafile fno=00007 name=/oradata/orcl/system02.dbf channel ORA_DISK_1: starting piece 1 at 20140125 16:24:42 channel ORA_DISK_2: starting full datafile backupset channel ORA_DISK_2: specifying datafile(s) in backupset input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf channel ORA_DISK_2: starting piece 1 at 20140125 16:24:42 channel ORA_DISK_3: starting full datafile backupset channel ORA_DISK_3: specifying datafile(s) in backupset input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf input datafile fno=00004 name=/oradata/orcl/users01.dbf channel ORA_DISK_3: starting piece 1 at 20140125 16:24:42 channel ORA_DISK_2: finished piece 1 at 20140125 16:24:49 piece handle=/oradata/orcl/databak/9eouvdma_1_1 tag=TAG20140125T162441 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:07 channel ORA_DISK_1: finished piece 1 at 20140125 16:25:24 piece handle=/oradata/orcl/databak/9douvdma_1_1 tag=TAG20140125T162441 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:42 channel ORA_DISK_3: finished piece 1 at 20140125 16:25:24 piece handle=/oradata/orcl/databak/9fouvdma_1_1 tag=TAG20140125T162441 comment=NONE channel ORA_DISK_3: backup set complete, elapsed time: 00:00:42 Finished backup at 20140125 16:25:24 Starting Control File and SPFILE Autobackup at 20140125 16:25:24 piece handle=/oradata/orcl/databak/c-1347935162-20140125-10 comment=NONE Finished Control File and SPFILE Autobackup at 20140125 16:25:27 RMAN自動建立了三個信道,ORA_DISK_1至3。備份時間為46秒(16:24:41至16:25:27)。這個時間要比我們手工指定三個信道(56秒)時快。 再設定并行度為4看看效果。 RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET; old RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters are successfully stored released channel: ORA_DISK_1 released channel: ORA_DISK_2 released channel: ORA_DISK_3 RMAN> backup database; Starting backup at 20140125 16:26:38 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=158 devtype=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: sid=147 devtype=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: sid=138 devtype=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: sid=137 devtype=DISK channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf input datafile fno=00007 name=/oradata/orcl/system02.dbf channel ORA_DISK_1: starting piece 1 at 20140125 16:26:38 channel ORA_DISK_2: starting full datafile backupset channel ORA_DISK_2: specifying datafile(s) in backupset input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf channel ORA_DISK_2: starting piece 1 at 20140125 16:26:38 channel ORA_DISK_3: starting full datafile backupset channel ORA_DISK_3: specifying datafile(s) in backupset input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf input datafile fno=00004 name=/oradata/orcl/users01.dbf channel ORA_DISK_3: starting piece 1 at 20140125 16:26:39 channel ORA_DISK_2: finished piece 1 at 20140125 16:26:54 piece handle=/oradata/orcl/databak/9iouvdpu_1_1 tag=TAG20140125T162638 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:16 channel ORA_DISK_1: finished piece 1 at 20140125 16:27:29 piece handle=/oradata/orcl/databak/9houvdpu_1_1 tag=TAG20140125T162638 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:51 channel ORA_DISK_3: finished piece 1 at 20140125 16:27:29 piece handle=/oradata/orcl/databak/9jouvdpu_1_1 tag=TAG20140125T162638 comment=NONE channel ORA_DISK_3: backup set complete, elapsed time: 00:00:51 Finished backup at 20140125 16:27:29 Starting Control File and SPFILE Autobackup at 20140125 16:27:29 piece handle=/oradata/orcl/databak/c-1347935162-20140125-11 comment=NONE Finished Control File and SPFILE Autobackup at 20140125 16:27:32 和我們手工指定4個信道時類似,備份時隻實際使用了3個信道。備份的時間為54秒(16:26:38至16:27:32),和上面手工指定4個信道所用時間來比,稍快一點兒。但比剛才自動3信道的要慢。 再設定并行度為7看看效果。 RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 7 BACKUP TYPE TO BACKUPSET; old RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 7 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters are successfully stored released channel: ORA_DISK_1 released channel: ORA_DISK_2 released channel: ORA_DISK_3 released channel: ORA_DISK_4 RMAN> backup database; Starting backup at 20140125 16:29:00 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=158 devtype=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: sid=147 devtype=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: sid=138 devtype=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: sid=137 devtype=DISK allocated channel: ORA_DISK_5 channel ORA_DISK_5: sid=156 devtype=DISK allocated channel: ORA_DISK_6 channel ORA_DISK_6: sid=155 devtype=DISK allocated channel: ORA_DISK_7 channel ORA_DISK_7: sid=134 devtype=DISK channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf channel ORA_DISK_1: starting piece 1 at 20140125 16:29:02 channel ORA_DISK_2: starting full datafile backupset channel ORA_DISK_2: specifying datafile(s) in backupset input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf channel ORA_DISK_2: starting piece 1 at 20140125 16:29:02 channel ORA_DISK_3: starting full datafile backupset channel ORA_DISK_3: specifying datafile(s) in backupset input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf channel ORA_DISK_3: starting piece 1 at 20140125 16:29:02 channel ORA_DISK_4: starting full datafile backupset channel ORA_DISK_4: specifying datafile(s) in backupset input datafile fno=00004 name=/oradata/orcl/users01.dbf channel ORA_DISK_4: starting piece 1 at 20140125 16:29:02 channel ORA_DISK_5: starting full datafile backupset channel ORA_DISK_5: specifying datafile(s) in backupset input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf channel ORA_DISK_5: starting piece 1 at 20140125 16:29:02 channel ORA_DISK_6: starting full datafile backupset channel ORA_DISK_6: specifying datafile(s) in backupset input datafile fno=00007 name=/oradata/orcl/system02.dbf channel ORA_DISK_6: starting piece 1 at 20140125 16:29:02 channel ORA_DISK_6: finished piece 1 at 20140125 16:29:09 piece handle=/oradata/orcl/databak/9qouvdue_1_1 tag=TAG20140125T162902 comment=NONE channel ORA_DISK_6: backup set complete, elapsed time: 00:00:07 channel ORA_DISK_5: finished piece 1 at 20140125 16:29:16 piece handle=/oradata/orcl/databak/9pouvdue_1_1 tag=TAG20140125T162902 comment=NONE channel ORA_DISK_5: backup set complete, elapsed time: 00:00:14 channel ORA_DISK_2: finished piece 1 at 20140125 16:29:19 piece handle=/oradata/orcl/databak/9mouvdue_1_1 tag=TAG20140125T162902 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:17 channel ORA_DISK_4: finished piece 1 at 20140125 16:29:22 piece handle=/oradata/orcl/databak/9oouvdue_1_1 tag=TAG20140125T162902 comment=NONE channel ORA_DISK_4: backup set complete, elapsed time: 00:00:20 channel ORA_DISK_3: finished piece 1 at 20140125 16:29:47 piece handle=/oradata/orcl/databak/9nouvdue_1_1 tag=TAG20140125T162902 comment=NONE channel ORA_DISK_3: backup set complete, elapsed time: 00:00:45 channel ORA_DISK_1: finished piece 1 at 20140125 16:29:54 piece handle=/oradata/orcl/databak/9louvdue_1_1 tag=TAG20140125T162902 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:52 Finished backup at 20140125 16:29:54 Starting Control File and SPFILE Autobackup at 20140125 16:29:54 piece handle=/oradata/orcl/databak/c-1347935162-20140125-12 comment=NONE Finished Control File and SPFILE Autobackup at 20140125 16:29:57 因為隻有6個檔案,是以,隻實際使用了6個信道。備份時間為57秒(16:29:00至16:29:57),和手工指定6信道時的用時完全一樣。 綜上,我們可以看出,這個并行度的參數與手工指定信道的作用是類似的。隻不過一個是由RMAN自動配置設定,一個由人工指定。 FILESPERSET這個參數又是做什麼用的呢?還是來做實驗。 我們把并行度改回2 RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET; old RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 7 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters: CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET; new RMAN configuration parameters are successfully stored 根據我們前邊做實驗的經驗,如果這時執行backup database;指令,會自動通過兩個信道來備份。 如果我們執行 backup database filesperset 2; 又會是什麼結果呢? RMAN> backup database filesperset 2; Starting backup at 20140125 16:58:48 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=158 devtype=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: sid=147 devtype=DISK channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf input datafile fno=00007 name=/oradata/orcl/system02.dbf channel ORA_DISK_1: starting piece 1 at 20140125 16:58:48 channel ORA_DISK_2: starting full datafile backupset channel ORA_DISK_2: specifying datafile(s) in backupset input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf channel ORA_DISK_2: starting piece 1 at 20140125 16:58:48 channel ORA_DISK_2: finished piece 1 at 20140125 16:58:55 piece handle=/oradata/orcl/databak/9vouvfm8_1_1 tag=TAG20140125T165848 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:07 channel ORA_DISK_2: starting full datafile backupset channel ORA_DISK_2: specifying datafile(s) in backupset input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf input datafile fno=00004 name=/oradata/orcl/users01.dbf channel ORA_DISK_2: starting piece 1 at 20140125 16:58:55 channel ORA_DISK_1: finished piece 1 at 20140125 16:59:40 piece handle=/oradata/orcl/databak/9uouvfm8_1_1 tag=TAG20140125T165848 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:52 channel ORA_DISK_2: finished piece 1 at 20140125 16:59:40 piece handle=/oradata/orcl/databak/a0ouvfmf_1_1 tag=TAG20140125T165848 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:45 Finished backup at 20140125 16:59:40 Starting Control File and SPFILE Autobackup at 20140125 16:59:40 piece handle=/oradata/orcl/databak/c-1347935162-20140125-14 comment=NONE Finished Control File and SPFILE Autobackup at 20140125 16:59:43 看到了嗎,加了filesperset 2 這個參數後,每次每信道隻讀取2個資料檔案了。最終6個資料檔案,生成了3個備份檔案。 換句話說,每個備份集裡,最多隻能包含兩個源檔案。如果我們設為 filesperset 1的話,由于一個備份集中隻能有1個源檔案,是以,實驗環境下的這6個資料檔案就要生成6個備份集了。 驗證一下: RMAN> backup database filesperset 1; Starting backup at 20140125 17:01:01 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf channel ORA_DISK_1: starting piece 1 at 20140125 17:01:01 channel ORA_DISK_2: starting full datafile backupset channel ORA_DISK_2: specifying datafile(s) in backupset input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf channel ORA_DISK_2: starting piece 1 at 20140125 17:01:01 channel ORA_DISK_2: finished piece 1 at 20140125 17:01:08 piece handle=/oradata/orcl/databak/a3ouvfqd_1_1 tag=TAG20140125T170101 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:07 channel ORA_DISK_2: starting full datafile backupset channel ORA_DISK_2: specifying datafile(s) in backupset input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf channel ORA_DISK_2: starting piece 1 at 20140125 17:01:08 channel ORA_DISK_1: finished piece 1 at 20140125 17:01:43 piece handle=/oradata/orcl/databak/a2ouvfqd_1_1 tag=TAG20140125T170101 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:42 channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00004 name=/oradata/orcl/users01.dbf channel ORA_DISK_1: starting piece 1 at 20140125 17:01:43 channel ORA_DISK_2: finished piece 1 at 20140125 17:01:43 piece handle=/oradata/orcl/databak/a4ouvfqk_1_1 tag=TAG20140125T170101 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:35 channel ORA_DISK_2: starting full datafile backupset channel ORA_DISK_2: specifying datafile(s) in backupset input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf channel ORA_DISK_2: starting piece 1 at 20140125 17:01:43 channel ORA_DISK_1: finished piece 1 at 20140125 17:01:44 piece handle=/oradata/orcl/databak/a5ouvfrn_1_1 tag=TAG20140125T170101 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00007 name=/oradata/orcl/system02.dbf channel ORA_DISK_1: starting piece 1 at 20140125 17:01:44 channel ORA_DISK_2: finished piece 1 at 20140125 17:01:44 piece handle=/oradata/orcl/databak/a6ouvfrn_1_1 tag=TAG20140125T170101 comment=NONE channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01 channel ORA_DISK_1: finished piece 1 at 20140125 17:01:45 piece handle=/oradata/orcl/databak/a7ouvfro_1_1 tag=TAG20140125T170101 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 20140125 17:01:45 Starting Control File and SPFILE Autobackup at 20140125 17:01:46 piece handle=/oradata/orcl/databak/c-1347935162-20140125-15 comment=NONE Finished Control File and SPFILE Autobackup at 20140125 17:01:47 果然。 現在,我們回過頭來,把當需要備份的檔案個數為質數時,如何在多個信道中配置設定的實驗做了。 為了滿足這個條件,我們在資料庫中再添加一個表空間,并在該表空間中添加一個資料檔案,進而形成7個資料檔案。 SQL> create tablespace demo datafile '/oradata/orcl/demo01.dbf' size 10M; Tablespace created. SQL> create table demo (id int) tablespace demo; Table created. SQL> insert into demo values(1); 1 row created. SQL> commit; Commit complete. SQL> select file_name,file_id,bytes/1024/1024 "size(M)" from dba_data_files; FILE_NAME FILE_ID size(M) ---------------------------------------- ---------- ---------- /oradata/orcl/system01.dbf 1 400 /oradata/orcl/undotbs01.dbf 2 320 /oradata/orcl/sysaux01.dbf 3 190 /oradata/orcl/users01.dbf 4 21.25 /oradata/orcl/hrtbs01.dbf 5 10 /oradata/orcl/demo01.dbf 6 10 /oradata/orcl/system02.dbf 7 10 7 rows selected. 再回到RMAN中,以手工指定4個通道的方式來進行資料庫備份。 MAN> run { allocate channel c1 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c2 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c3 device type disk format '/oradata/orcl/databak1/%U'; allocate channel c4 device type disk format '/oradata/orcl/databak1/%U'; backup database; release channel c1; release channel c2; release channel c3; release channel c4; }2> 3> 4> 5> 6> 7> 8> 9> 10> 11> released channel: ORA_DISK_1 released channel: ORA_DISK_2 allocated channel: c1 channel c1: sid=158 devtype=DISK allocated channel: c2 channel c2: sid=147 devtype=DISK allocated channel: c3 channel c3: sid=138 devtype=DISK allocated channel: c4 channel c4: sid=137 devtype=DISK Starting backup at 20140125 17:41:56 channel c1: starting full datafile backupset channel c1: specifying datafile(s) in backupset input datafile fno=00001 name=/oradata/orcl/system01.dbf channel c1: starting piece 1 at 20140125 17:41:56 channel c2: starting full datafile backupset channel c2: specifying datafile(s) in backupset input datafile fno=00002 name=/oradata/orcl/undotbs01.dbf input datafile fno=00007 name=/oradata/orcl/system02.dbf channel c2: starting piece 1 at 20140125 17:41:56 channel c3: starting full datafile backupset channel c3: specifying datafile(s) in backupset input datafile fno=00003 name=/oradata/orcl/sysaux01.dbf input datafile fno=00006 name=/oradata/orcl/demo01.dbf channel c3: starting piece 1 at 20140125 17:41:56 channel c4: starting full datafile backupset channel c4: specifying datafile(s) in backupset input datafile fno=00004 name=/oradata/orcl/users01.dbf input datafile fno=00005 name=/oradata/orcl/hrtbs01.dbf channel c4: starting piece 1 at 20140125 17:41:56 channel c4: finished piece 1 at 20140125 17:41:57 piece handle=/oradata/orcl/databak1/agouvi74_1_1 tag=TAG20140125T174156 comment=NONE channel c4: backup set complete, elapsed time: 00:00:01 channel c2: finished piece 1 at 20140125 17:42:12 piece handle=/oradata/orcl/databak1/aeouvi74_1_1 tag=TAG20140125T174156 comment=NONE channel c2: backup set complete, elapsed time: 00:00:16 channel c3: finished piece 1 at 20140125 17:42:27 piece handle=/oradata/orcl/databak1/afouvi74_1_1 tag=TAG20140125T174156 comment=NONE channel c3: backup set complete, elapsed time: 00:00:31 channel c1: finished piece 1 at 20140125 17:42:34 piece handle=/oradata/orcl/databak1/adouvi74_1_1 tag=TAG20140125T174156 comment=NONE channel c1: backup set complete, elapsed time: 00:00:38 Finished backup at 20140125 17:42:34 Starting Control File and SPFILE Autobackup at 20140125 17:42:34 piece handle=/oradata/orcl/databak/c-1347935162-20140125-18 comment=NONE Finished Control File and SPFILE Autobackup at 20140125 17:42:37 released channel: c1 released channel: c2 released channel: c3 released channel: c4 實驗證明,當需備份的檔案數不能均分至多個信道時,RMAN會以一種近似平均的方法來處理。那麼為什麼6個檔案4個通道時,RMAN沒有采用1-1-2-2的方式來使用4個通道呢?個人推測是由于當按這種方式配置設定時,最多的一個信道上還是要有2個檔案,那麼這時,就不如把6個檔案配置設定在3個通道上(即2-2-2的配置設定方式)即節省了通道數,又能保證總體的備份時間不會延長。同時,在進行檔案配置設定時,檔案的大小,也是其進行配置設定的一個考慮因素,RMAN會在首先保證各信道處理的檔案個數接近的前提下,使每個信道上配置設定到的總的檔案大小也盡量均衡。