Parnassus data recovery manager for oracle database user guide v0.3
Does rman backup benefit from large pool
1. Does Rman Backup
benefit from Large
Pool?
by Maclean.liu
liu.maclean@gmail.com
www.oracledatabase12g.com
2. About Me
l Email:liu.maclean@gmail.com
l Blog:www.oracledatabase12g.com
l Oracle Certified Database Administrator Master
10g and 11g
l Over 6 years experience with Oracle DBA
technology
l Over 7 years experience with Linux technology
l Member Independent Oracle Users Group
l Member All China Users Group
l Presents for advanced Oracle topics: RAC,
DataGuard, Performance Tuning and Oracle Internal.
3. 我们在学习 Oracle 的过程中,或多或少会存在个人对概念的理解错误、误解或者根本是
教材编写存在不严谨的地方,这样或以讹传讹或三人言虎,导致 在 Oracle 圈子存在着一
些古老相传的迷信(superstition),因为这些迷信已经深入人心了,所以我们几乎很难纠正
过来;这其实很有意 思,IT 作为一个高科技的领域也会出现迷信,说明我们在 IT 技术
的”教学”和”思考”上存在问题,这一点值得深思。
这里我列出几个最为常见的迷信,算作抛砖引玉:
1.几乎所有的 Oracle 入门教程都会在介绍 Large pool 的时候这样描述:”RMAN 备份使用
large pool 作为磁盘 I/O 缓冲区,配置 Large pool 有助于提高 RMAN 备份性能”
Truth:除非你启用了 slaves IO,否则 rman 并不使用 large pool
RMAN I/O 可以分成三种模式:
Mode Disk tape
绝 大多数操作系统支持 AIO,
磁 带设备本身不支持 AIO(tape I/O is always
默认 disk_asynch_io 为 TRUE,
synchronous),虽然默认 tape_asynch_io 为
即默认启用磁盘异步 IO。如果
TRUE,但磁带设备只能通过 IO slaves 模拟
磁盘设备不支持 AIO,那么会
Asynchronous 异步 IO,所以启用磁带 AIO 需要另外设置
使用 synchronous I/O。磁盘异
I/O backup_tape_io_slaves=TRUE。此模式下
步模式下 RMAN I/O 缓冲区域
RMAN I/O 缓冲区从 shared pool 或者 large
从 PGA 中分配,相关 IO 性能
pool 中分配,相关 IO 性能信息存放在
信息存放在 V$backup_async_io
V$backup_async_io 视图中
视图中
5. If I/O slaves are used, I/O buffers are obtained from the SGA ,or the large pool, if configured.If
LARGE_POOL_SIZE is set, then Oracle attempts to get memory from the large pool. If this
value is not large enough, then Oracle does not try to get buffers from the shared pool.If Oracle
cannot get enough memory, then it obtains I/O buffer memory from local process memory and
writes a message to the alert.log file indicating that synchronous I/O is used for this backup.
在默认情况下 Oracle 对于磁盘设备使用 AIO 模式(disk_asynch_io=true & dbwr_io_slaves=0
by default),而对于磁带设备使用 synchronous I/O(tape_asynch_io=true &
backup_tape_io_slaves=false by default),都不会启用 slaves I/O,所以默认情况下 RMAN 总
是从 PGA 中分配缓存。换而言之在默认情况下,即便配置了较大的 Large pool 也不会为
RMAN 所用。
RMAN allocates the tape buffers in the SGA or the PGA, depending on whether I/O slaves are
used. If you set the initialization parameter BACKUP_TAPE_IO_SLAVES = true, then RMAN
allocates tape buffers from the SGA or the large pool if the LARGE_POOL_SIZE initialization
parameter is set. If you set the parameter to false, then RMAN allocates the buffers from the
PGA.
我们来通过以下演示,进一步验证 AIO/Slave Io 环境下 RMAN 内存缓冲区从哪里分配,
并加强印象:
SQL> select * From v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> show parameter async
NAME TYPE VALUE
------------------------------------ -----------
------------------------------
6. disk_asynch_io boolean TRUE
tape_asynch_io boolean TRUE
SQL> select * From v$sgastat where pool='large pool';
POOL NAME BYTES
------------ -------------------------- ----------
large pool PX msg pool 903840
large pool free memory 15873376
backup as backupset database skip offline;
SQL> select * From v$sgastat where pool='large pool';
POOL NAME BYTES
------------ -------------------------- ----------
large pool PX msg pool 903840
large pool free memory 15873376
/* 在 AIO 模式下,全库备份后发现 large pool 未发生变化 */
SQL> alter system set disk_asynch_io=false scope=spfile;
System altered.
SQL> alter system set dbwr_io_slaves=2 scope=spfile;
System altered.
/* 以上启用了磁盘 I/O Slave 特性 */
SQL> startup force;
[oracle@rh2 ~]$ ps -ef|grep i10|grep -v grep
oracle 20761 1 0 20:44 ? 00:00:00 ora_i101_G10R2
oracle 20763 1 0 20:44 ? 00:00:00 ora_i102_G10R2
/* 启用 I/O Slave 后会出现 ora_ixxx_SID 这样的后台进程 */
SQL> select * From v$sgastat where pool='large pool';
POOL NAME BYTES
------------ -------------------------- ----------
large pool PX msg pool 903840
large pool free memory 15873376
RMAN> backup as backupset database skip offline;
SQL> select * From v$sgastat where pool='large pool';
POOL NAME BYTES
------------ -------------------------- ----------
large pool PX msg pool 903840
large pool free memory 24151392
large pool KSFQ Buffers 25276416
SQL> /
7. POOL NAME BYTES
------------ -------------------------- ----------
large pool PX msg pool 903840
large pool free memory 41006432
large pool KSFQ Buffers 8421376
/* 启用了 I/O Slave 后执行备份操作,
large pool 中出现了 KSFQ Buffers,这个 KSFQ buffer 就是 RMAN 所使用的缓冲区,
实际决定该 buffer 大小的是隐藏参数_backup_ksfq_bufsz 和_backup_ksfq_bufcnt */
SQL> col name for a30
SQL> col describ for a70
SQL> SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc describ
2 FROM SYS.x$ksppi x, SYS.x$ksppcv y
3 WHERE x.inst_id = USERENV ('Instance')
4 AND y.inst_id = USERENV ('Instance')
5 AND x.indx = y.indx
6 AND x.ksppinm LIKE '%ksfq%';
NAME VALUE DESCRIB
------------------------------ ----------
----------------------------------------------------------------------
_backup_ksfq_bufsz 0 size of the ksfq buffer used for
backup/restore
_backup_ksfq_bufcnt 0 number of the ksfq buffers used for
backup/restore
/* 在 10g 中似乎 Oracle 会自动调控以上 2 个参数 */
SQL> alter system set "_backup_ksfq_bufsz"=131072;
System altered.
SQL> alter system set "_backup_ksfq_bufcnt"=1;
System altered.
RMAN> backup tablespace data01;
/* I/O slaves 的 IO 统计信息仍存放在 V$backup_sync_io 视图中,
而非可能是你所预期的 v$backup_sync_io 视图 */
SQL> select type,buffer_size,buffer_count from v$backup_async_io;
TYPE BUFFER_SIZE BUFFER_COUNT
--------- ----------- ------------
AGGREGATE 0 0
INPUT 131072 1
OUTPUT 1048576 4
另外 large pool 的使用量可以通过下列公式来估算:
LARGE_POOL_SIZE =
(4 * {RMAN Channels} * {DB_BLOCK_SIZE} * {DB_DIRECT_IO_COUNT} *
{Multiplexing Level})