DBA运维工作中,可能会遇到数据库中个别的数据文件非常大,这样就会造成rman备份的速度缓慢(即便是多个并行的配置,但依然会是单通道的去备份该大数据文件的情况)11gr2后,Oracle 对此,在备份恢复特性中,推出了增强参数 SECTION SIZE。
官方的原文:
Specifies the size of each backup section produced during a data file backup.
By setting this parameter, RMAN can create a multisection backup. In a multisection backup, RMAN creates a backup piece that contains one file section, which is a contiguous range of blocks in a file. All sections of a multisection backup are the same size. You can create a multisection backup for a data file, but not a data file copy.
如果设置了section size参数,Rman就会创建一个连续范围内(大小为section 决定)的block 组成的备分片。每个备份片大小相同。且它只能在你备份数据文件(或者数据库,亲测),不能用在数据文件copy的备份方式上。
File sections enable RMAN to create multiple steps for the backup of a single large data file. RMAN channels can process each step independently and in parallel, with each channel producing one section of a multisection backup set.
file section 能让rman备份单个大数据文件是分成多个步骤(多个通道按照sectionsize创建备份片),实现并行处理。
If you specify a section size that is larger than the size of the file, then RMAN does not use multisection backup for the file. If you specify a small section size that would produce more than 256 sections, then RMAN increases the section size to a value that results in exactly 256 sections.
如果指定的section size比这个大数据文件还大,rman将无法提供并行备份(即该参数失效)。如果指定的大小非常小,rman会已256份为界限,将大数据文件的size/section size >256 ,调整为 section size为合理的大小,使备份片的量等于256份;
Depending on where you specify this parameter in the RMAN syntax, you can specify different section sizes for different files in the same backup job.备份不同数据文件可以指定不同section size.
Note: You cannot use SECTION SIZE with MAXPIECESIZE or withINCREMENTAL LEVEL 1.
注意,当指定了maxpiecesize 或者做1集备份时该参数失效
例1-1:
run {
allocate channel c1 type sbt;
allocate channel c2 type sbt;
allocate channel c3 type sbt;
allocate channel c4 type sbt;
backup as compressed backupset datafile 6 section size 10g;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
脚本中将启动4个通道,每个通道读取6号数据库文件的一段10GB的连续的block段。
每个通道将生成包含段的备份的片(单独的物理文件)。如果文件为200GB, 将有20个这样的片,一次生成4个,会连续创建5次。
如果没有section size 关键字,并行读将为1(也就是序列化),只会用一个通道执行整个操作。
注意:在用Format定义备份集名字时要记得加上%U,否则会出现rman-3009 ora-19504 ora-27038的错。
例1-2 (基于linux 平台 11.2.0.4 单实例)
source /home/oracle/.profile
export ORACLE_SID=wengtf
rman target / <<EOF
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup incremental level 0 cumulative section size 100M database format '/home/oracle/backup_%T_%n_%U';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
run{
allocate channel c00 type disk;
backup archivelog all format '/home/oracle/arch_backup_%T_%n_%U' delete all input;
release channel c00;
}
run{
allocate channel c01 type disk;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete device type disk;
release channel c01;
}
exit
EOF
mutt -s "test01_DailyBackup " -a /home/oracle/DailyBackup.log -- 邮件地址
例1-2 输出(live800 数据文件被分为10份):
Recovery Manager: Release 11.2.0.4.0 - Production on Sun Mar 6 14:59:01 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST1 (DBID=1279889488)
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11>
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=171 device type=DISK
allocated channel: c2
channel c2: SID=193 device type=DISK
allocated channel: c3
channel c3: SID=4 device type=DISK
allocated channel: c4
channel c4: SID=25 device type=DISK
Starting backup at 06-MAR-16
channel c1: starting incremental level 0 datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/oracle/oradata/TEST1/datafile/datalive800
backing up blocks 1 through 12800
channel c1: starting piece 1 at 06-MAR-16
channel c2: starting incremental level 0 datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/oracle/oradata/TEST1/datafile/o1_mf_sysaux_cc38tgc5_.dbf
backing up blocks 1 through 12800
channel c2: starting piece 1 at 06-MAR-16
channel c3: starting incremental level 0 datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/oracle/oradata/TEST1/datafile/o1_mf_system_cc38tg9t_.dbf
backing up blocks 1 through 12800
channel c3: starting piece 1 at 06-MAR-16
channel c4: starting incremental level 0 datafile backup set
channel c4: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/oracle/oradata/TEST1/datafile/o1_mf_undotbs1_cc38tgcg_.dbf
backing up blocks 1 through 12800
channel c4: starting piece 1 at 06-MAR-16
channel c4: finished piece 1 at 06-MAR-16
piece handle=/home/oracle/backup_20160306_TEST1xxx_8pqvqbpp_1_1 tag=TAG20160306T145905 comment=NONE
channel c4: backup set complete, elapsed time: 00:00:01
channel c4: starting incremental level 0 datafile backup set
channel c4: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/oracle/oradata/TEST1/datafile/datalive800
backing up blocks 12801 through 25600
channel c4: starting piece 2 at 06-MAR-16
channel c1: finished piece 1 at 06-MAR-16
piece handle=/home/oracle/backup_20160306_TEST1xxx_8mqvqbpp_1_1 tag=TAG20160306T145905 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:02
channel c1: starting incremental level 0 datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/oracle/oradata/TEST1/datafile/datalive800
backing up blocks 25601 through 38400
channel c1: starting piece 3 at 06-MAR-16
channel c2: finished piece 1 at 06-MAR-16
piece handle=/home/oracle/backup_20160306_TEST1xxx_8nqvqbpp_1_1 tag=TAG20160306T145905 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:02
channel c2: starting incremental level 0 datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/oracle/oradata/TEST1/datafile/datalive800
backing up blocks 38401 through 51200
channel c2: starting piece 4 at 06-MAR-16
channel c3: finished piece 1 at 06-MAR-16
piece handle=/home/oracle/backup_20160306_TEST1xxx_8oqvqbpp_1_1 tag=TAG20160306T145905 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:02
channel c3: starting incremental level 0 datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/oracle/oradata/TEST1/datafile/datalive800
backing up blocks 51201 through 64000
channel c3: starting piece 5 at 06-MAR-16
channel c1: finished piece 3 at 06-MAR-16
piece handle=/home/oracle/backup_20160306_TEST1xxx_8mqvqbpp_3_1 tag=TAG20160306T145905 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:00
channel c1: starting incremental level 0 datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/oracle/oradata/TEST1/datafile/datalive800
backing up blocks 64001 through 76800
channel c1: starting piece 6 at 06-MAR-16
channel c2: finished piece 4 at 06-MAR-16
piece handle=/home/oracle/backup_20160306_TEST1xxx_8mqvqbpp_4_1 tag=TAG20160306T145905 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:00
channel c2: starting incremental level 0 datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/oracle/oradata/TEST1/datafile/datalive800
backing up blocks 76801 through 89600
channel c2: starting piece 7 at 06-MAR-16
channel c4: finished piece 2 at 06-MAR-16
piece handle=/home/oracle/backup_20160306_TEST1xxx_8mqvqbpp_2_1 tag=TAG20160306T145905 comment=NONE
channel c4: backup set complete, elapsed time: 00:00:01
channel c4: starting incremental level 0 datafile backup set
channel c4: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/oracle/oradata/TEST1/datafile/datalive800
backing up blocks 89601 through 102400
channel c4: starting piece 8 at 06-MAR-16
channel c1: finished piece 6 at 06-MAR-16
piece handle=/home/oracle/backup_20160306_TEST1xxx_8mqvqbpp_6_1 tag=TAG20160306T145905 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
channel c1: starting incremental level 0 datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/oracle/oradata/TEST1/datafile/datalive800
backing up blocks 102401 through 115200
channel c1: starting piece 9 at 06-MAR-16
channel c2: finished piece 7 at 06-MAR-16
piece handle=/home/oracle/backup_20160306_TEST1xxx_8mqvqbpp_7_1tag=TAG20160306T145905 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:00
channel c2: starting incremental level 0 datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/oracle/oradata/TEST1/datafile/datalive800
backing up blocks 115201 through 128000
channel c2: starting piece 10 at 06-MAR-16
channel c3: finished piece 5 at 06-MAR-16
piece handle=/home/oracle/backup_20160306_TEST1xxx_8mqvqbpp_5_1tag=TAG20160306T145905 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:01
channel c3: starting incremental level 0 datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/oracle/oradata/TEST1/datafile/datalive800
backing up blocks 128001 through 131072
channel c3: starting piece 11 at 06-MAR-16
channel c1: finished piece 9 at 06-MAR-16
piece handle=/home/oracle/backup_20160306_TEST1xxx_8mqvqbpp_9_1 tag=TAG20160306T145905 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:00
channel c1: starting incremental level 0 datafile backup set
channel c1: specifying datafile(s) in backup set
....此处省略.....
RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 1 days
no obsolete backups found
released channel: c01
RMAN>
RMAN>
Recovery Manager complete.
END