关于Multisection Backups(多节备份)和MAXPIECESIZE的区别以及对并发概念的引申

背景:
在学习rman备份的过程中,你可能会遇到一种情形:限制单个备份片的尺寸。这个诉求在生产环境下可以理解为两个点:第一,是显示当备份文件大小,可能是为了满足文件系统使用,或者是满足磁带的某些规则。第二,可能是尽早的释放缓存,因为高速读写操作会有缓存,可能是落地的,也可能不是,为了减轻缓存的压力,限制单个文件大小,对于缓存释放有利。第三,对于单个超大的数据文件,想对他并发的备份。
那么在网上查找,大概率你能查到两个语句:section size和maxpiecesize 他们都能限制,打到我们的目的,却有区别。

介绍

Multisection Incremental Backups(多节增量备份)
语句:section size
适用于单个大文件,比如备份一个特别大的数据文件,这个文件可能是数据仓库中的一个表空间的文件。比如有几百个GB。

举例:backup section size 500m datafile '/oracle/prod/system01.dbf';

MAXPIECESIZE
这是限制备份片(backup pieces)大小的参数。如果piece大于这个参数的值,就会再创建一个备份片,也就是备份文件的大小不会大于这个参数值。只要大过了就再写一个文件。
举例:allocate channel c1 device type disk maxpiecesize 4000m format '/s3/prod/max_%U';

区别

  1. 首先他们语法不通。section size 字段用在backup语句中,而maxpiecesize字段用在通道allocate channel中或者configure中。
  2. section size 通常作用于单个大文件,而maxpiecesize是对应通道,也就是对应整改作业,这个作业也许是整个库备份,也许是归档日志备份,这个不重要,因为它写在了通道的限制上。
  3. 用section size 语句通常于并发有关。
  4. 备份文件数量不同。

操作

对于上边的区别的内容,我有操作的记录帮助理解:
首先,我对数据字典:DBA_DATA_FILES做一个查询,看一看单个数据文件的大小,和数据块的数量:

col FILE_NAME for a40
select FILE_NAME,round(BYTES/1024/1024,2) "mb",blocks  from dba_data_files;

FILE_NAME			 mb			BLOCKS
------------------------------- ---------- ----------
/oracle/PROD/data1/system01.dbf       2000  256000
/oracle/PROD/data1/sysaux01.dbf       4096  524288
/oracle/PROD/data2/undotbs01.dbf       10000    1280000
/oracle/PROD/data1/users01.dbf400 51200
/oracle/PROD/data4/prod01.dbf      15360    1966080
/oracle/PROD/data4/prod02.dbf      15360    1966080
/oracle/PROD/data4/prod03.dbf      15360    1966080
/oracle/PROD/data3/prod04.dbf      12288    1572864
/oracle/PROD/data3/prod05.dbf      12288    1572864
/oracle/PROD/data5/prod06.dbf      15360    1966080
/oracle/PROD/data5/prod07.dbf      15360    1966080

FILE_NAME 			mb		BLOCKS
------------------------------ ---------- ----------
/oracle/PROD/data5/prod08.dbf      15360    1966080
/oracle/PROD/data6/prod09.dbf      15360    1966080
/oracle/PROD/data6/prod10.dbf      15360    1966080
/oracle/PROD/data6/prod11.dbf      15360    1966080
/oracle/PROD/data7/prod12.dbf      15360    1966080
/oracle/PROD/data3/portal.dbf     1024    131072

其次,我对prod01这个数据文件做Multisection Backups(多区备份),限制备份文件大小不超过4000m:

RMAN> backup section size 4000m datafile '/oracle/PROD/data4/prod01.dbf' format  '/s3dbtest/PROD_TEST/prod_%U';  

Starting backup at 2024-12-13 10:23:47
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=322 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/oracle/PROD/data4/prod01.dbf
backing up blocks 1 through 512000
channel ORA_DISK_1: starting piece 1 at 2024-12-13 10:23:49
channel ORA_DISK_1: finished piece 1 at 2024-12-13 10:24:24
piece handle=/s3dbtest/PROD_TEST/prod_113ciqtl_96289_1_1 tag=TAG20241213T102349 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/oracle/PROD/data4/prod01.dbf
backing up blocks 512001 through 1024000
channel ORA_DISK_1: starting piece 2 at 2024-12-13 10:24:24
channel ORA_DISK_1: finished piece 2 at 2024-12-13 10:24:39
piece handle=/s3dbtest/PROD_TEST/prod_113ciqtl_96289_2_1 tag=TAG20241213T102349 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/oracle/PROD/data4/prod01.dbf
backing up blocks 1024001 through 1536000
channel ORA_DISK_1: starting piece 3 at 2024-12-13 10:24:39
channel ORA_DISK_1: finished piece 3 at 2024-12-13 10:24:40
piece handle=/s3dbtest/PROD_TEST/prod_113ciqtl_96289_3_1 tag=TAG20241213T102349 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/oracle/PROD/data4/prod01.dbf
backing up blocks 1536001 through 1966080
channel ORA_DISK_1: starting piece 4 at 2024-12-13 10:24:40
channel ORA_DISK_1: finished piece 4 at 2024-12-13 10:24:41
piece handle=/s3dbtest/PROD_TEST/prod_113ciqtl_96289_4_1 tag=TAG20241213T102349 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2024-12-13 10:24:41

最后我用maxoiecesize的方法同样显示文件大小不超过4000m:

run{
allocate channel c1 device type disk maxpiecesize 4000m format '/s3dbtest/PROD_TEST/prod_max_%U';
backup datafile '/oracle/PROD/data4/prod01.dbf';
}


released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=322 device type=DISK

Starting backup at 2024-12-13 10:30:24
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00005 name=/oracle/PROD/data4/prod01.dbf
channel c1: starting piece 1 at 2024-12-13 10:30:24
channel c1: finished piece 1 at 2024-12-13 10:30:59
piece handle=/s3dbtest/PROD_TEST/prod_max_153cira0_96293_1_1 tag=TAG20241213T103024 comment=NONE
channel c1: starting piece 2 at 2024-12-13 10:30:59
channel c1: finished piece 2 at 2024-12-13 10:31:14
piece handle=/s3dbtest/PROD_TEST/prod_max_153cira0_96293_2_1 tag=TAG20241213T103024 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:50
Finished backup at 2024-12-13 10:31:14
released channel: c1

查看备份文件的大小:

oraPROD@bjscpldbtest2:/s3dbtest/PROD_TEST> ll -h
total 12G
-rw-r--r-- 1 root root  64K Dec 13 10:24 prod_113ciqtl_96289_3_1
-rw-r--r-- 1 root root  64K Dec 13 10:24 prod_113ciqtl_96289_4_1
-rw-r--r-- 1 root root 4.0G Dec 13 10:25 prod_113ciqtl_96289_1_1
-rw-r--r-- 1 root root 1.7G Dec 13 10:25 prod_113ciqtl_96289_2_1
-rw-r--r-- 1 root root 1.7G Dec 13 10:31 prod_max_153cira0_96293_2_1
-rw-r--r-- 1 root root 4.0G Dec 13 10:31 prod_max_153cira0_96293_1_1

说明

section size

我们能看到备份片和block的数量绑定的:

block piece filesize
blocks 1 through 512000 1_1 4.0G
blocks 512001 through 1024000 2_1 1.7G
blocks 1024001 through 1536000 3_1 64K
blocks 1536001 through 1966080 4_1 64K

再数据字段中也能看到prod01的块数量就是1966080,
而且oracle的块大小是8k,512000*8kb/1024=4000mb,因为我限制的是4000m,所以第一个piece才到512000,
也就是说,rman是可以以这样的算法将一个数据文件分割的,然后在不同的通道了做备份,也就是并行,提高效率。
然而,再看不通的piece的大小,可以发现,第三第四的piece只有64k,说明对应的数据文件的block中没有数据。
对比maxpiecesize的备份集,只有两个piece,不是四个piece。
可以推断出,section size的方式备份数据文件,piece的文件大小不一定相同。

详细去看上面的操作和产生的日志信息,可以深刻的明白区别。

posted @ 2024-12-13 15:04  老牛的田  阅读(5)  评论(0编辑  收藏  举报