RMAN PARALLELISM

(一)RMAN Channel and RMAN Session

RMAN CHANNEL与数据库的server session对应

An RMAN channel represents one stream of data to a device, and corresponds to one database server session. During a backup or restore operation, the channel reads data from the input device, processes it, and writes it to the output device.

RMAN SESSION指rman client连接使用的session

An RMAN session begins when the RMAN client is started and ends when you exit from the client or the RMAN process is terminated. Multiple RMAN commands can be executed in a single RMAN session.

The RMAN client directs database server sessions to perform all backup and recovery tasks. What constitutes a session depends on the operating system. For example, on Linux, a server session corresponds to a server process, whereas on Windows it corresponds to a thread within the database service. The RMAN client itself does not perform backup, restore, or recovery operations.

Most RMAN commands are executed by channels, which must be either configured to persist across RMAN sessions, or manually allocated in each RMAN session.

As illustrated in Figure 3-2, a channel establishes a connection from the RMAN client to a target or auxiliary database instance by starting a server session on the instance.

(二)Multiplexed RMAN Backup Sets

每个channel对应的server session是并行I/O操作的, 称为backup multiplexing

When creating backup sets, RMAN can simultaneously read multiple files from disk and then write their blocks into the same backup set. For example, RMAN can read from two data files simultaneously, and then combine the blocks from these data files into a single backup piece. The combination of blocks from multiple files is called backup multiplexing.

Note: If RMAN creates a multisection backup of a data file, then the data file is not multiplexed with any other data file or file section.

Note: Image copies, by contrast, are never multiplexed.

As Figure 8-1 illustrates, RMAN can back up three data files into a backup set that contains only one backup piece. This backup piece contains the intermingled data blocks of the three input data files.

Figure 8-1 Data File Multiplexing

每个channel的并发度由MAXOPENFILES配置,但同时受FILESPERSET影响

The basic multiplexing algorithm is as follows:

  1. Number of files in each backup set

FILESPERSET为备份集中最多包含的datafile个数(不是BP个数),超过则会创建新备份集

Specifies the maximum number of input files to include in each output backup set. This parameter is only relevant when BACKUP generates backup sets.

RMAN backs up the files in each backupSpec as one or more backup sets. When the number of files in each backupSpec exceeds the FILESPERSET setting, then RMAN splits the files into multiple backup sets accordingly. The default value for FILESPERSET is 64.

  1. The level of multiplexing

This is the number of input files simultaneously read and then written into the same backup piece. The level of multiplexing is the minimum of MAXOPENFILES and the number of files in each backup set. The MAXOPENFILES default is 8.

Suppose that you back up 12 data files with one channel when FILEPERSET is set to 4. The level of multiplexing is the lesser of this number and 8. Thus, the channel simultaneously writes blocks from 4 data files into each backup piece.

Now suppose that you back up 50 data files with one channel. The number of files in each backup set is 50. The level of multiplexing is the lesser of this number and 8. Thus, the channel simultaneously writes blocks from 8 data files into each backup piece.

RMAN multiplexing of backup sets is different from media manager multiplexing

One type of media manager multiplexing occurs when the media manager writes the concurrent output from multiple RMAN channels to a single sequential device. Another type occurs when a backup mixes database files and non-database files on the same tape.

Note: Oracle recommends that you never use media manager multiplexing for RMAN backups.

(三)Improve RMAN concurrency

除了设置单个channel下并行度,还可通过增加channel来提高并行度,channel个数通常设为逻辑cpu数

备份流程:

  1. 将多个被备份文件分配给多个channel
  2. 每个channel产生单独的备份集
  3. Channel下是并行读取多个被分配的备份文件,并行写入同一备份集的多个备份片中

被备份文件(datafile)与备份集(BS)及备份后文件(BP)的关系:

多个datafile可以备份于同一或多个BS中

同一datafile只能备份在一个BS

同一datafile可以备份成同一BS下不同BP中

datafile少于channel数就会有空闲channel

  1. SECTION

SECTION备份相当于把datafile细分为多个section,注意不是将备份后文件分section.

不同channel可以对同一datafile的多个section并行操作,这时将只产生1个备份集,它包含多个备份片。这在备份文件少于channel数量时提高并行度,如:

RMAN> backup datafile 5 SECTION SIZE 10M ; 

备份前查看datafile 5大小为65MB(select file_id, bytes/1024/1024 from dba_data_files),则它相当于把datafile 5分成7个区,备份后只产生一个BS,BS下包含7个BP,整个备份集也只有4MB

SECTION功能是11.1版本开始的,在12.1版本支持section的增量备份

Multisection full backups of databases and data files are supported starting with Oracle Database 11g Release 1. Starting with Oracle Database 12c Release 1 (12.1), RMAN supports multisection incremental backups. Wherever applicable, RMAN also uses unused block compression and block change tracking while creating multisection incremental backups. When backup sets are used, you can create multisection full or incremental backups.

To create level 0 multisection incremental backups, the COMPATIBLE parameter must be set to 11.0 or higher. However, to create multisection incremental backups of level 1 or higher, you must set the COMPATIBLE parameter to 12.0.0 or higher. RMAN always creates multisection incremental backups with FILESPERSET set to 1.

增量Section备份示例

BACKUP INCREMENTAL LEVEL 1 SECTION SIZE 100M DATAFILE '/oradata/datafiles/users_df.dbf';

最多支持将备份文件分为256个section,如果超过则Oracle将自动调整产生256 section

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.

通过V$BACKUP_SET的MULTI_SECTION或 RC_BACKUP_SET查看备份是否为SECTION BACKUP.

通过V$BACKUP_DATAFILE与RC_BACKUP_DATAFILE视图查看每个section backup包含的块数

注:如果备份中出现某个SECTION备份失败而其它SECTION成功,需要删除成功备份部分,从新备份整个文件

For non-multisection backups, RMAN only records backup sets in the repository that complete successfully. There is no such thing as a partial backup set.

This differs from an unsuccessful multisection backup, where it is possible for RMAN metadata to contain a record for a partial backup set. In the latter case, you must use the DELETE command to delete the partial backup set.

在12.1版本也支持镜像文件的全量SECTION备份,它仍然只产生一个文件

While an image copy is being created, RMAN uses multiple channels to write files sections. However, the output of this operation is one copy for each data file.

Multisection backups provide better performance by using multiple channels to back up large files in parallel. Starting with Oracle Database 12c Release 1 (12.1), you can create multisection full backups that are stored as image copies.

镜象文档的Section备份

BACKUP AS COPY SECTION SIZE 500M DATABASE;

  1. MAXPIECESIZE

MAXPIECESIZE为备份片的最大大小,超过则生成新备份片,只能在channel中设置

RMAN> RUN {

ALLOCATE CHANNEL c1 DEVICE TYPE disk MAXPIECESIZE 10m;

ALLOCATE CHANNEL c2 DEVICE TYPE disk MAXPIECESIZE 10m;

BACKUP datafile 4; }   

此选项为设置channel产生BP大小,不能提高并发度

  1. FILESPERSET

这个参数在第二部分已说,它可以提高单channel下并发度.下面产生3个备份集而不是两个

RMAN> RUN {

ALLOCATE CHANNEL c1 DEVICE TYPE disk;

ALLOCATE CHANNEL c2 DEVICE TYPE disk;

BACKUP datafile 4,7,13 FILESPERSET 1;}   

  1. MAXSETSIZE

设置每个备份集最大大小,超过将报错RMAN-06183,它与并行度无关:

RMAN> backup database MAXSETSIZE 2M ;                         

  1. 多个backup命令为顺序操作而非并发

下面只使用channel c1顺序备份了3个datafiles,并行度为1

RMAN> RUN{

ALLOCATE CHANNEL c1 DEVICE TYPE DISK;

ALLOCATE CHANNEL c2 DEVICE TYPE DISK;

BACKUP datafile 2;

BACKUP datafile 3;

BACKUP datafile 4;

}  

  1. Format不会增加并行度

RMAN> RUN{

ALLOCATE CHANNEL c1 DEVICE TYPE DISK;

ALLOCATE CHANNEL c2 DEVICE TYPE DISK;

Backup databfile 5 format 'backup_%U';

}

  1. 使用ALLOCATE CHANNEL命令会覆盖SHOW ALL中PARALLELISM设置,此配置只是默认分配多少个channel

RMAN> SHOW ALL

CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;

下面将使用系统默认的2个channel,并发度为2

RMAN> BACKUP datafile 4,7,13;

下面命令将只使用c1 channel,即并发为1

RMAN> RUN {

ALLOCATE CHANNEL c1 DEVICE TYPE disk;

BACKUP datafile 4,7,13}   

示例:

2个channel,生成2个备份集,这里自动分配每个CHANNEL备份的文件

RMAN> RUN {

ALLOCATE CHANNEL c1 DEVICE TYPE disk MAXPIECESIZE 300M;

ALLOCATE CHANNEL c2 DEVICE TYPE disk MAXPIECESIZE 300M;

BACKUP datafile 1,2,3;}   

2个channel,生成2个备份集,这里手动分配每个CHANNEL备份的文件

RMAN> RUN {

ALLOCATE CHANNEL c1 DEVICE TYPE disk;

ALLOCATE CHANNEL c2 DEVICE TYPE disk;

BACKUP (DATAFILE 1,2 CHANNEL c1)(DATAFILE 3 CHANNEL c2);}

只有3个datafile,所以即使有4 channel,产生了3个备份集

RMAN> RUN{

ALLOCATE CHANNEL t1 DEVICE TYPE disk;

ALLOCATE CHANNEL t2 DEVICE TYPE disk;

ALLOCATE CHANNEL t3 DEVICE TYPE disk;

ALLOCATE CHANNEL t4 DEVICE TYPE disk;   

BACKUP DATAFILE 3,4,5 FILESPERSET 2; }   

产生一个备份集

RMAN> RUN{

ALLOCATE CHANNEL c1 DEVICE TYPE DISK MAXPIECESIZE 300M;

ALLOCATE CHANNEL c2 DEVICE TYPE DISK MAXPIECESIZE 300M;

ALLOCATE CHANNEL c2 DEVICE TYPE DISK MAXPIECESIZE 300M;

BACKUP datafile 2 ; }

2 channel生成2个备份集

RMAN>RUN{

ALLOCATE CHANNEL c1 DEVICE TYPE DISK;

ALLOCATE CHANNEL c2 DEVICE TYPE DISK;

BACKUP datafile 2,3,4 ; }   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值