[Oracle工程师手记] 提高 RMAN 备份性能的技巧之 Section Size
返回 Oracle 索引页
在某些情况下,section size 的使用,在 RMAN 备份中,会大幅度地提高备份速度。这是因为,如果不使用 section size ,那么无论我在备份时设置了多少个channel,在任何一个时刻,对每一个文件而言,只能有一个channel 连接到这个文件上执行读取和备份。
例如,下面的试验中,我开了 8 个 channel 进行备份。
-bash-4.1$ rman target /
Recovery Manager: Release 12.2.0.1.0 - Production on Sat Apr 10 09:35:01 2021
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL1220 (DBID=1362151495)
RMAN> run{
ALLOCATE CHANNEL CH1 TYPE DISK;
ALLOCATE CHANNEL CH2 TYPE DISK;
ALLOCATE CHANNEL CH3 TYPE DISK;
ALLOCATE CHANNEL CH4 TYPE DISK;
ALLOCATE CHANNEL CH5 TYPE DISK;
ALLOCATE CHANNEL CH6 TYPE DISK;
ALLOCATE CHANNEL CH7 TYPE DISK;
ALLOCATE CHANNEL CH8 TYPE DISK;
backup database;
}
using target database control file instead of recovery catalog
allocated channel: CH1
channel CH1: SID=66 device type=DISK
allocated channel: CH2
channel CH2: SID=59 device type=DISK
allocated channel: CH3
channel CH3: SID=57 device type=DISK
allocated channel: CH4
channel CH4: SID=61 device type=DISK
allocated channel: CH5
channel CH5: SID=62 device type=DISK
allocated channel: CH6
channel CH6: SID=69 device type=DISK
allocated channel: CH7
channel CH7: SID=70 device type=DISK
allocated channel: CH8
channel CH8: SID=63 device type=DISK
Starting backup at 20210410_09:35:31
channel CH1: starting full datafile backup set
channel CH1: specifying datafile(s) in backup set
input datafile file number=00001 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/system01.dbf
channel CH1: starting piece 1 at 20210410_09:35:32
channel CH2: starting full datafile backup set
channel CH2: specifying datafile(s) in backup set
input datafile file number=00003 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/sysaux01.dbf
channel CH2: starting piece 1 at 20210410_09:35:32 ***
channel CH3: starting full datafile backup set
channel CH3: specifying datafile(s) in backup set
input datafile file number=00005 name=/refresh/home/datafile/df001.dbf
channel CH3: starting piece 1 at 20210410_09:35:32
channel CH4: starting full datafile backup set
channel CH4: specifying datafile(s) in backup set
input datafile file number=00004 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/undotbs01.dbf
channel CH4: starting piece 1 at 20210410_09:35:32
channel CH5: starting full datafile backup set
channel CH5: specifying datafile(s) in backup set
input datafile file number=00007 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/users01.dbf
channel CH5: starting piece 1 at 20210410_09:35:32
channel CH3: finished piece 1 at 20210410_09:35:39
piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0ivrubf4_1_1 tag=TAG20210410T093531 comment=NONE
channel CH3: backup set complete, elapsed time: 00:00:07
channel CH5: finished piece 1 at 20210410_09:35:39
piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0kvrubf4_1_1 tag=TAG20210410T093531 comment=NONE
channel CH5: backup set complete, elapsed time: 00:00:07
channel CH4: finished piece 1 at 20210410_09:35:47
piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0jvrubf4_1_1 tag=TAG20210410T093531 comment=NONE
channel CH4: backup set complete, elapsed time: 00:00:15
channel CH1: finished piece 1 at 20210410_09:36:07
piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0gvrubf4_1_1 tag=TAG20210410T093531 comment=NONE
channel CH1: backup set complete, elapsed time: 00:00:35 ***
channel CH2: finished piece 1 at 20210410_09:36:07
piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0hvrubf4_1_1 tag=TAG20210410T093531 comment=NONE
channel CH2: backup set complete, elapsed time: 00:00:35
Finished backup at 20210410_09:36:07 ***
Starting Control File and SPFILE Autobackup at 20210410_09:36:07
piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/c-1362151495-20210410-01 comment=NONE
Finished Control File and SPFILE Autobackup at 20210410_09:36:09
released channel: CH1
released channel: CH2
released channel: CH3
released channel: CH4
released channel: CH5
released channel: CH6
released channel: CH7
released channel: CH8
RMAN>
我的数据文件只有 5 个,所以 CH6、CH7、CH8 并没有被使用。我的 CH2 对 sysaux01.dbf 进行备份,它从 9:35:32 开始,到 9:36:07 结束。 而我的 CH4 比它早结束,它在 9:35:47 就结束了对 undotbs01.dbf 的备份,CH4 完成对 undotbs01.dbf 已经空闲,它并没有过来帮助CH2 来备份 sysaux01.dbf 。
所以,在不指定 section size 的情况下,一个文件只能被一个 Channel 访问。如果客户的环境中有一些文件十分的巨大,那么只有一个 channel 对其处理(只有一个CPU参与备份),那么效率就会是相当低下的。
所以,我们需要使用 section size。举例来说, 将 section size 设置为 200M。
run{
ALLOCATE CHANNEL CH1 TYPE DISK;
ALLOCATE CHANNEL CH2 TYPE DISK;
ALLOCATE CHANNEL CH3 TYPE DISK;
ALLOCATE CHANNEL CH4 TYPE DISK;
ALLOCATE CHANNEL CH5 TYPE DISK;
ALLOCATE CHANNEL CH6 TYPE DISK;
ALLOCATE CHANNEL CH7 TYPE DISK;
ALLOCATE CHANNEL CH8 TYPE DISK;
backup database section size 200M;
}
这时,备份的过程是这样的:
released channel: ORA_DISK_1 allocated channel: CH1 channel CH1: SID=66 device type=DISK allocated channel: CH2 channel CH2: SID=59 device type=DISK allocated channel: CH3 channel CH3: SID=57 device type=DISK allocated channel: CH4 channel CH4: SID=61 device type=DISK allocated channel: CH5 channel CH5: SID=62 device type=DISK allocated channel: CH6 channel CH6: SID=69 device type=DISK allocated channel: CH7 channel CH7: SID=70 device type=DISK allocated channel: CH8 channel CH8: SID=63 device type=DISK Starting backup at 20210410_09:52:44 channel CH1: starting full datafile backup set channel CH1: specifying datafile(s) in backup set input datafile file number=00001 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/system01.dbf backing up blocks 1 through 25600 channel CH1: starting piece 1 at 20210410_09:52:44 channel CH2: starting full datafile backup set channel CH2: specifying datafile(s) in backup set input datafile file number=00003 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/sysaux01.dbf backing up blocks 1 through 25600 channel CH2: starting piece 1 at 20210410_09:52:44 channel CH3: starting full datafile backup set channel CH3: specifying datafile(s) in backup set input datafile file number=00005 name=/refresh/home/datafile/df001.dbf channel CH3: starting piece 1 at 20210410_09:52:44 channel CH4: starting full datafile backup set channel CH4: specifying datafile(s) in backup set input datafile file number=00004 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/undotbs01.dbf channel CH4: starting piece 1 at 20210410_09:52:45 channel CH5: starting full datafile backup set channel CH5: specifying datafile(s) in backup set input datafile file number=00007 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/users01.dbf channel CH5: starting piece 1 at 20210410_09:52:45 channel CH6: starting full datafile backup set channel CH6: specifying datafile(s) in backup set input datafile file number=00001 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/system01.dbf backing up blocks 25601 through 51200 channel CH6: starting piece 2 at 20210410_09:52:47 channel CH7: starting full datafile backup set channel CH7: specifying datafile(s) in backup set input datafile file number=00001 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/system01.dbf backing up blocks 51201 through 76800 channel CH7: starting piece 3 at 20210410_09:52:47 channel CH8: starting full datafile backup set channel CH8: specifying datafile(s) in backup set input datafile file number=00001 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/system01.dbf backing up blocks 76801 through 102400 channel CH8: starting piece 4 at 20210410_09:52:47 channel CH1: finished piece 1 at 20210410_09:52:47 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_1_1 tag=TAG20210410T095244 comment=NONE channel CH1: backup set complete, elapsed time: 00:00:03 channel CH1: starting full datafile backup set channel CH1: specifying datafile(s) in backup set input datafile file number=00001 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/system01.dbf backing up blocks 102401 through 106240 channel CH1: starting piece 5 at 20210410_09:52:48 channel CH2: finished piece 1 at 20210410_09:52:48 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0nvrucfc_1_1 tag=TAG20210410T095244 comment=NONE channel CH2: backup set complete, elapsed time: 00:00:04 channel CH2: starting full datafile backup set channel CH2: specifying datafile(s) in backup set input datafile file number=00003 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/sysaux01.dbf backing up blocks 25601 through 51200 channel CH2: starting piece 2 at 20210410_09:52:49 channel CH3: finished piece 1 at 20210410_09:52:49 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0ovrucfc_1_1 tag=TAG20210410T095244 comment=NONE channel CH3: backup set complete, elapsed time: 00:00:05 channel CH3: starting full datafile backup set channel CH3: specifying datafile(s) in backup set input datafile file number=00003 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/sysaux01.dbf backing up blocks 51201 through 76800 channel CH3: starting piece 3 at 20210410_09:52:51 channel CH4: finished piece 1 at 20210410_09:52:51 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0pvrucfd_1_1 tag=TAG20210410T095244 comment=NONE channel CH4: backup set complete, elapsed time: 00:00:06 channel CH4: starting full datafile backup set channel CH4: specifying datafile(s) in backup set input datafile file number=00003 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/sysaux01.dbf backing up blocks 76801 through 93440 channel CH4: starting piece 4 at 20210410_09:52:52 channel CH5: finished piece 1 at 20210410_09:52:52 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0qvrucfd_1_1 tag=TAG20210410T095244 comment=NONE channel CH5: backup set complete, elapsed time: 00:00:07 channel CH1: finished piece 5 at 20210410_09:52:52 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_5_1 tag=TAG20210410T095244 comment=NONE channel CH1: backup set complete, elapsed time: 00:00:04 channel CH6: finished piece 2 at 20210410_09:52:53 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_2_1 tag=TAG20210410T095244 comment=NONE channel CH6: backup set complete, elapsed time: 00:00:06 channel CH7: finished piece 3 at 20210410_09:52:53 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_3_1 tag=TAG20210410T095244 comment=NONE channel CH7: backup set complete, elapsed time: 00:00:06 channel CH8: finished piece 4 at 20210410_09:52:53 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_4_1 tag=TAG20210410T095244 comment=NONE channel CH8: backup set complete, elapsed time: 00:00:06 channel CH2: finished piece 2 at 20210410_09:53:00 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0nvrucfc_2_1 tag=TAG20210410T095244 comment=NONE channel CH2: backup set complete, elapsed time: 00:00:11 channel CH3: finished piece 3 at 20210410_09:53:00 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0nvrucfc_3_1 tag=TAG20210410T095244 comment=NONE channel CH3: backup set complete, elapsed time: 00:00:09 channel CH4: finished piece 4 at 20210410_09:53:00 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0nvrucfc_4_1 tag=TAG20210410T095244 comment=NONE channel CH4: backup set complete, elapsed time: 00:00:08 Finished backup at 20210410_09:53:00 Starting Control File and SPFILE Autobackup at 20210410_09:53:00 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/c-1362151495-20210410-02 comment=NONE Finished Control File and SPFILE Autobackup at 20210410_09:53:01 released channel: CH1 released channel: CH2 released channel: CH3 released channel: CH4 released channel: CH5 released channel: CH6 released channel: CH7 released channel: CH8 RMAN>
可以看到,这次,CH1、CH2 一直到 CH8,都参与了备份过程。 为了看清它的过程,可以把 CH1 关联部分摘要出来:
allocated channel: CH1 channel CH1: SID=66 device type=DISK ...... Starting backup at 20210410_09:52:44 channel CH1: starting full datafile backup set channel CH1: specifying datafile(s) in backup set input datafile file number=00001 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/system01.dbf backing up blocks 1 through 25600 channel CH1: starting piece 1 at 20210410_09:52:44 ...... channel CH1: finished piece 1 at 20210410_09:52:47 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_1_1 tag=TAG20210410T095244 comment=NONE channel CH1: backup set complete, elapsed time: 00:00:03 ...... channel CH1: starting full datafile backup set channel CH1: specifying datafile(s) in backup set input datafile file number=00001 name=/refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/system01.dbf backing up blocks 102401 through 106240 channel CH1: starting piece 5 at 20210410_09:52:48 ...... channel CH1: finished piece 5 at 20210410_09:52:52 piece handle=/refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_5_1 tag=TAG20210410T095244 comment=NONE channel CH1: backup set complete, elapsed time: 00:00:04 ...... released channel: CH1 released channel: CH2 released channel: CH3 released channel: CH4 released channel: CH5 released channel: CH6 released channel: CH7 released channel: CH8 RMAN>
可以看到,从 9:52:47 ,CH1 完成了第一次的备份之后,又马不停蹄地开始了第二次的备份,9:52:48 CH1 再次开始备份,直到 9:52:52 结束。,使用了 section size ,就可以把一个文件理解成许多个小文件,各个channel 会不断地读取这些个小文件,直到所有的小文件都被读取过。
而备份后结果是这样的:
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -----------------
20 Full 8.42M DISK 00:00:00 20210410_09:52:45
BP Key: 20 Status: AVAILABLE Compressed: NO Tag: TAG20210410T095244
Piece Name: /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0pvrucfd_1_1
List of Datafiles in backup set 20
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- ----------------- ----------- ------ ----
4 Full 1944008 20210410_09:52:45 NO /refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/undotbs01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -----------------
21 Full 26.44M DISK 00:00:00 20210410_09:52:45
BP Key: 21 Status: AVAILABLE Compressed: NO Tag: TAG20210410T095244
Piece Name: /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0qvrucfd_1_1
List of Datafiles in backup set 21
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- ----------------- ----------- ------ ----
7 Full 1944009 20210410_09:52:45 NO /refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -----------------
22 Full 23.92M DISK 00:00:01 20210410_09:52:45
BP Key: 22 Status: AVAILABLE Compressed: NO Tag: TAG20210410T095244
Piece Name: /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0ovrucfc_1_1
List of Datafiles in backup set 22
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- ----------------- ----------- ------ ----
5 Full 1944007 20210410_09:52:45 NO /refresh/home/datafile/df001.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -----------------
23 Full 695.90M DISK 00:00:04 20210410_09:52:48
List of Datafiles in backup set 23
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- ----------------- ----------- ------ ----
1 Full 1944005 20210410_09:52:44 NO /refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/system01.dbf
Backup Set Copy #1 of backup set 23
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ ----------------- ---------- ---
DISK 00:00:04 20210410_09:52:48 NO TAG20210410T095244
List of Backup Pieces for backup set 23 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
23 1 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_1_1
26 2 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_2_1
28 3 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_3_1
27 4 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_4_1
25 5 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_5_1
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -----------------
24 Full 570.30M DISK 00:00:09 20210410_09:52:53
List of Datafiles in backup set 24
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- ----------------- ----------- ------ ----
3 Full 1944006 20210410_09:52:44 NO /refresh/home/app/12.2.0.1/oracle/oradata/orcl12201/sysaux01.dbf
Backup Set Copy #1 of backup set 24
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ ----------------- ---------- ---
DISK 00:00:09 20210410_09:52:57 NO TAG20210410T095244
List of Backup Pieces for backup set 24 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
24 1 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0nvrucfc_1_1
31 2 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0nvrucfc_2_1
30 3 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0nvrucfc_3_1
29 4 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0nvrucfc_4_1
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -----------------
25 Full 10.19M DISK 00:00:00 20210410_09:53:00
BP Key: 32 Status: AVAILABLE Compressed: NO Tag: TAG20210410T095300
Piece Name: /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/c-1362151495-20210410-02
SPFILE Included: Modification time: 20210410_09:33:06
SPFILE db_unique_name: ORCL12201
Control File Included: Ckp SCN: 1944061 Ckp time: 20210410_09:53:00
RMAN>
可以看到,对一些个数据文件,产生了多个备份文件。比如,对 system01.dbf 的备份产生的备份集 23,它包含的备份片(文件)有下面这些:
List of Backup Pieces for backup set 23 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
23 1 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_1_1
26 2 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_2_1
28 3 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_3_1
27 4 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_4_1
25 5 AVAILABLE /refresh/home/app/12.2.0.1/oracle/product/12.2.0.1/dbhome3/dbs/0mvrucfc_5_1
一般而言,和产生的备份文件数量比起来,因为备份速度有可能大幅度提高,使用 section size 很多时候是可以接受的。我这里给出的仅仅是一个例子,整体备份的时间本来就很短。如果真正的生产环境中,数据文件很大时,section size 就值得考虑了。
返回 Oracle 索引页

浙公网安备 33010602011771号