rman performence part_1

来源:互联网 发布:javascript 改变class 编辑:程序博客网 时间:2024/06/06 04:20

这篇文章主要想说一下rman的性能优化,在继续我们的话题之前,我们可能需要更多关注一下rman备份的 原理

For the purposes of illustration, you can think of the byte stream as
passing from the input buffers in memory through the CPU to the output
buffers, and from there to the storage device. To direct a backup to
two tape devices, you allocate two tape channels so that each byte
stream goes to a different device.

bytes stream=> memory(inpurt buffer)=>cpu => memory(output buffer )

上面的原理介绍,我想到是我们的rman compress应该是第三部分完成的。

且官方对rman的描述是这样的

这里写图片描述

大致分为三个过程,read,copy ,write

引用一个这三部分的定义

Read Phase

A channel reads blocks from disk into input I/O buffers.

Copy Phase

A channel copies blocks from input buffers to output buffers and
performs additional processing on the blocks.

Write Phase

A channel writes the blocks from output buffers to storage media. The
write phase can take either of the following mutually exclusive forms,
depending on the type of backup media:

如果rman是往磁带机,或者远程机器的话:

这里写图片描述

当然,关于buffer的大小,rman也有自己的算法
Data File Read Buffer Sizing Algorithm
rman 备份文件时的算法
multiplexing 即“多路复用性”,我们可以同时将n个物理文件备份到一个备份文件中,那我们的 multiplexing=n

这里写图片描述

If a channel is backing up files stored in ASM, then the number of
input disk buffers equals the number of physical disks in the ASM disk
group. For example, if a data file is stored in an ASM disk group that
contains 16 physical disks, then the channel allocates 16 input
buffers for the data file backup.

If a channel is restoring a backup from disk, then 4 buffers are
allocated. The size of the buffers is dependent on the operating
system.

disk bufffer allocation
注意官方文档的这段描述

If a channel is backing up files stored in ASM, then the number of
input disk buffers equals the number of physical disks in the ASM disk
group. For example, if a data file is stored in an ASM disk group that
contains 16 physical disks, then the channel allocates 16 input
buffers for the data file backup.

If a channel is restoring a backup from disk, then 4 buffers are
allocated. The size of the buffers is dependent on the operating
system.

In the example shown in Figure below, one channel is backing up four
data files. MAXOPENFILES is set to 4 and FILESPERSET is set to 4.
Thus, the level of multiplexing is 4. So, the total size of the
buffers for each data file is 4 MB. The combined size of all the
buffers is 16 MB.

这里的multiplexing=4 故此 input buffer=16m
disk buffer allocation

这个算法很好的限制了rman说能耗去的IO。比如我们的input buffer可以达到16MB,不管我们存储的IO性能有多么强大,input buffer的大小被限制住了。当然IO可以让我们的bytes stream将buffer里面的数据更快的刷进磁盘中去。 但是我们的水管就这么大,只能说冲速更快,更猛。

有了如上知识,我们还需要讨论一下异步IO的问题:

ORACLE官方这要号召我们来做这件事情

when reading from an ASM disk group, you should use asynchronous disk
I/O if possible. Also, if a channel reads from a raw device managed
with a volume manager, then asynchronous disk I/O also works well.
Some operating systems support native asynchronous disk I/O. The
database takes advantage of this feature if it is available.

You can control disk I/O slaves by setting the DBWR_IO_SLAVES
initialization parameter, which is not dynamic. The parameter
specifies the number of I/O server processes used by the database
writer process (DBWR). By default, the value is 0 and I/O server
processes are not used. If asynchronous I/O is disabled, then RMAN
allocates four backup disk I/O slaves for any nonzero value of
DBWR_IO_SLAVES.

实际上rman已经偷偷地为我们分配了四个进程。
也就是dbwr_io_slaves=4

同时,我们也要关注内存方面的

When attempting to get shared buffers for I/O slaves, the database
does the following:

If the LARGE_POOL_SIZE initialization parameter is set, and if the
DBWR_IO_SLAVES parameter is set to a nonzero value, then the database
attempts to get memory from the large pool. If this value is not large
enough, then an error is recorded in the alert log, the database does
not try to get buffers from the shared pool, and asynchronous I/O is
not used.

If the LARGE_POOL_SIZE initialization parameter is not set or is set
to zero, then the database attempts to get memory from the shared
pool.

If the database cannot get enough memory, then it obtains I/O buffer
memory from the Program Global Area (PGA) and writes a message to the
alert.log file indicating that synchronous I/O is used for this
backup.

这个启用异步IO的内存获取的逻辑大致如下:
large pool => shared_pool => PGA

The memory from the large pool is used for many features, including
the shared server, parallel query, and RMAN I/O slave buffers.
Configuring the large pool prevents RMAN from competing with other
subsystems for the same memory.

Requests for contiguous memory allocations from the shared pool are
usually small (under 5 KB). However, a request for a large contiguous
memory allocation can either fail or require significant memory
housekeeping to release the required amount of contiguous memory.
Although the shared pool may be unable to satisfy this memory request,
the large pool can do so. The large pool does not have a least
recently used (LRU) list; the database does not attempt to age memory
out of the large pool.
large pool 对于很多特性都很有用,比如并行执行,且是按照LRU管理。

如果是input buffer,out buffer 限制了我们水管的粗细的话,那么我们的读取速度可以限制吗? 答案是肯定的

RATE Channel Parameter In the ALLOCATE and CONFIGURE CHANNEL commands,
the RATE parameter specifies the bytes per second that are read on a
channel. You can use this parameter to set an upper limit for bytes
read so that RMAN does not consume excessive disk bandwidth and
degrade online performance. Essentially, RATE serves as a backup
throttle. For example, if you set RATE 1500K, and if each disk drive
delivers 3 megabytes per second, then the channel leaves some disk
bandwidth available to the online system.

不过rate参数这个真的很少用。我们通常希望都是读取速度越快越好,且备份都是在夜间。

不如我这里限制读取速度

RMAN> configure channel device type disk rate 1000m;old RMAN configuration parameters:CONFIGURE CHANNEL DEVICE TYPE DISK RATE 100 K;new RMAN configuration parameters:CONFIGURE CHANNEL DEVICE TYPE DISK RATE 1000 M;new RMAN configuration parameters are successfully storedreleased channel: ORA_DISK_1released channel: ORA_DISK_2released channel: ORA_DISK_3released channel: ORA_DISK_4released channel: ORA_DISK_5released channel: ORA_DISK_6RMAN> backup as compressed  backupset tablespace test001;Starting backup at 14-AUG-17allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=5 device type=DISKallocated channel: ORA_DISK_2channel ORA_DISK_2: SID=63 device type=DISKallocated channel: ORA_DISK_3channel ORA_DISK_3: SID=129 device type=DISKallocated channel: ORA_DISK_4channel ORA_DISK_4: SID=9 device type=DISKallocated channel: ORA_DISK_5channel ORA_DISK_5: SID=132 device type=DISKallocated channel: ORA_DISK_6channel ORA_DISK_6: SID=72 device type=DISKchannel ORA_DISK_1: starting compressed full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00005 name=/u02/oradata/ORCL/datafile/o1_mf_test001_ds17lv9r_.dbfchannel ORA_DISK_1: starting piece 1 at 14-AUG-17channel ORA_DISK_1: finished piece 1 at 14-AUG-17piece handle=/u02/backup/ORCL/backupset/2017_08_14/o1_mf_nnndf_TAG20170814T161629_ds2q2xtb_.bkp tag=TAG20170814T161629 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:03channel ORA_DISK_1: throttle time: 0:00:01Finished backup at 14-AUG-17Starting Control File Autobackup at 14-AUG-17piece handle=/u02/backup/ORCL/autobackup/2017_08_14/o1_mf_n_952013792_ds2q30z1_.bkp comment=NONEFinished Control File Autobackup at 14-AUG-17RMAN> 

总结一下:
input buffer的大小是和rman multiplexed(多路复用)相关的,
这里又不得不引用官方言论,毕竟这是最准确的

The allocation of the input buffers depends on how the files are multiplexed. Backup multiplexing is RMAN’s ability to read several files in a backup simultaneously from different sources and then write them to a single backup piece. The level of multiplexing, which is the number of input files simultaneously read and then written into the same backup piece, is determined by the algorithm described in “Multiplexed Backup Sets”. Review this section before proceeding.

官网也曾这样描述

An RMAN backup set in which each backup piece contains a file section,
which is a contiguous range of blocks in a data file. A multisection
backup set contains multiple backup pieces, but a backup set never
contains only a part of a data file.

You create a multisection backup by specifying the SECTION SIZE
parameter on the BACKUP command. An RMAN channel can process each file
section independently, either serially or in parallel. Thus, in a
multisection backup, multiple channels can back up a single file.

以上是rman performance的read阶段的内容。