【RMAN】I/O Read Rate of Backups

如何控制RMAN备份时的I/O速度呢?
这是在客户生产环境中遇到的现实问题,因为客户的存储实在是弱爆了,RMAN备份的时候由于I/O较高,导致应用出现停顿,严重时存储直接挂掉。所以考虑限制RMAN备份时的速度。
在Oracle的Channel Control中提示可以通过两种哦国内方式控制I/O,单位为KB/s,MB/s,GB/s
Set limits on I/O bandwidth consumption in kilobytes, megabytes, or gigabytes (ALLOCATE CHANNEL … RATE, CONFIGURE CHANNEL … RATE)
下面是Oracle对Rate设置的案例介绍
I/O Read Rate of Backups
By default, RMAN uses all available I/O bandwidth to read/write to disk. You can limit the I/O resources consumed by a backup job with the RATE option of the ALLOCATE CHANNEL or CONFIGURE CHANNEL commands. The RATE option specifies the maximum number of bytes for each second that RMAN reads on the channel.
For example, you can configure automatic channels to limit each channel to read 1 MB a second:
CONFIGURE DEVICE TYPE sbt PARALLELISM 2;
CONFIGURE DEFAULT DEVICE TYPE TO sbt;
CONFIGURE CHANNEL DEVICE TYPE sbt RATE 1M;

根据Oracle给出的提示,我们在11.2.0.2的库上分别测试I/O限制为5M,20M及不限制IO时RMAN的备份速度,借助osw观察I/O变化情况。
备份的数据文件为system01.dbf,大小约为700MB。

-bash-3.2$ ls -lh system01.dbf
 -rw-r----- 1 oracle dba 701M Nov 21 15:30 system01.dbf

操作系统的块大小为4096(4KB),数据库的块大小为8192(8KB)

[[email protected] ~]# getconf PAGESIZE
 4096
 SQL> show parameter db_block_size
NAME TYPE VALUE
 ------------------------------------ ----------- ------------------------------
 db_block_size integer 8192

开启OSW(OS Watcher),收集信息时间间隔为10秒,保留10天(240小时)。

[[email protected] osw]# ./startOSW.sh 10 240 >> osw.log &
 [1] 16589
 [[email protected] osw]#
 [1]+ Done ./startOSW.sh 10 240 >> osw.log
 [[email protected] osw]#
 [[email protected] osw]# cat osw.log
Testing for discovery of OS Utilities...
VMSTAT found on your system.
 IOSTAT found on your system.
 MPSTAT found on your system.
 NETSTAT found on your system.
 TOP found on your system.
Discovery completed.
Starting OSWatcher v3.0.1 on Mon Nov 21 15:56:22 CST 2011
 With SnapshotInterval = 10
 With ArchiveInterval = 240
OSWatcher - Written by Carl Davis, Center of Expertise, Oracle Corporation
Starting Data Collection...
osw heartbeat:Mon Nov 21 15:56:22 CST 2011

1.I/O限制为5M,备份时间为2分25秒

RMAN> configure CHANNEL DEVICE TYPE DISK RATE 5M;
new RMAN configuration parameters:
 CONFIGURE CHANNEL DEVICE TYPE DISK RATE 5 M;
 new RMAN configuration parameters are successfully stored
RMAN> show CHANNEL;
RMAN configuration parameters for database with db_unique_name ORCL are:
 CONFIGURE CHANNEL DEVICE TYPE DISK RATE 5 M;
RMAN> backup datafile '/oracle/oradata/orcl/system01.dbf';
Starting backup at 21-NOV-11
 allocated channel: ORA_DISK_1
 channel ORA_DISK_1: SID=143 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=00001 name=/oracle/oradata/orcl/system01.dbf
 channel ORA_DISK_1: starting piece 1 at 21-NOV-11
 channel ORA_DISK_1: finished piece 1 at 21-NOV-11
 piece handle=/oracle/fast_recovery_area/ORCL/backupset/2011_11_21/o1_mf_nnndf_TAG20111121T155646_7dn11yc3_.bkp tag=TAG20111121T155646 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:02:25
 channel ORA_DISK_1: throttle time: 0:02:14
 Finished backup at 21-NOV-11
Starting Control File and SPFILE Autobackup at 21-NOV-11
 piece handle=/oracle/fast_recovery_area/ORCL/autobackup/2011_11_21/o1_mf_s_767807951_7dn16hq2_.bkp comment=NONE
 Finished Control File and SPFILE Autobackup at 21-NOV-11

2.I/O限制为20M,备份时间为45秒

RMAN> configure CHANNEL DEVICE TYPE DISK RATE 20M;
old RMAN configuration parameters:
 CONFIGURE CHANNEL DEVICE TYPE DISK RATE 5 M;
 new RMAN configuration parameters:
 CONFIGURE CHANNEL DEVICE TYPE DISK RATE 20 M;
 new RMAN configuration parameters are successfully stored
 released channel: ORA_DISK_1
RMAN> show CHANNEL;
RMAN configuration parameters for database with db_unique_name ORCL are:
 CONFIGURE CHANNEL DEVICE TYPE DISK RATE 20 M;
RMAN> backup datafile '/oracle/oradata/orcl/system01.dbf';
Starting backup at 21-NOV-11
 allocated channel: ORA_DISK_1
 channel ORA_DISK_1: SID=143 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=00001 name=/oracle/oradata/orcl/system01.dbf
 channel ORA_DISK_1: starting piece 1 at 21-NOV-11
 channel ORA_DISK_1: finished piece 1 at 21-NOV-11
 piece handle=/oracle/fast_recovery_area/ORCL/backupset/2011_11_21/o1_mf_nnndf_TAG20111121T160009_7dn1896h_.bkp tag=TAG20111121T160009 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
 channel ORA_DISK_1: throttle time: 0:00:30
 Finished backup at 21-NOV-11
Starting Control File and SPFILE Autobackup at 21-NOV-11
 piece handle=/oracle/fast_recovery_area/ORCL/autobackup/2011_11_21/o1_mf_s_767808054_7dn19ptr_.bkp comment=NONE
 Finished Control File and SPFILE Autobackup at 21-NOV-11

3.RMAN I/O无限制,备份时间为15秒

 RMAN> configure CHANNEL DEVICE TYPE DISK clear;
old RMAN configuration parameters:
 CONFIGURE CHANNEL DEVICE TYPE DISK RATE 20 M;
 old RMAN configuration parameters are successfully deleted
 released channel: ORA_DISK_1
RMAN> show CHANNEL;
RMAN configuration parameters for database with db_unique_name ORCL are:
 RMAN configuration has no stored or default parameters
RMAN> backup datafile '/oracle/oradata/orcl/system01.dbf';
Starting backup at 21-NOV-11
 allocated channel: ORA_DISK_1
 channel ORA_DISK_1: SID=143 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=00001 name=/oracle/oradata/orcl/system01.dbf
 channel ORA_DISK_1: starting piece 1 at 21-NOV-11
 channel ORA_DISK_1: finished piece 1 at 21-NOV-11
 piece handle=/oracle/fast_recovery_area/ORCL/backupset/2011_11_21/o1_mf_nnndf_TAG20111121T160152_7dn1cjf8_.bkp tag=TAG20111121T160152 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
 Finished backup at 21-NOV-11
Starting Control File and SPFILE Autobackup at 21-NOV-11
 piece handle=/oracle/fast_recovery_area/ORCL/autobackup/2011_11_21/o1_mf_s_767808127_7dn1czqj_.bkp comment=NONE
 Finished Control File and SPFILE Autobackup at 21-NOV-11

根据数据文件大小列出预计的RMAN备份时间与实际RMAN备份时间:
IO test chat

可以通过OSW收集的数据,很明显的看到percent busy(PB), reads per second(RPS) and writes per second(WPS)变化
percent busy(PB)
OSWg sda OS IO PB
reads per second(RPS)
OSWg sda OS IO RPS
writes per second(WPS)
OSWg sda OS IO WPS

从OSW生成的图片的整体趋势上,已经能看到设置RATE参数对磁盘I/O的影响。
但是可能是由于一些暂时未知的原因,RPS的趋势并非如我们所愿,限制为10M后仍有个别时段物理读超出限制。
今天看到一款可以监控程序IO的软件,改天重新进行一下测试。

总结:
Oracle 11gR2在做RMAN备份时,可以通过设置RATE参数限制磁盘IO。
设置方式如下:
configure CHANNEL DEVICE TYPE DISK RATE 20M;
重置方式如下:
configure CHANNEL DEVICE TYPE DISK clear;
单位可以设置为KB,MB,GB

参考:

Oracle® Database Backup and Recovery Advanced User’s Guide 10g Release 1 (10.1) Part Number B10734-01
计算机中KB与Kb的技术差别详解
RMAN备份数据文件和控制文件
利用RATE参数限制RMAN备份的IO速度
Unix/Linux 磁盘 I/O 性能监控命令

普人特福的博客cnzz&51la for wordpress,cnzz for wordpress,51la for wordpress