Your SlideShare is downloading. ×
Does rman backup benefit from large pool
Does rman backup benefit from large pool
Does rman backup benefit from large pool
Does rman backup benefit from large pool
Does rman backup benefit from large pool
Does rman backup benefit from large pool
Does rman backup benefit from large pool
Does rman backup benefit from large pool
Does rman backup benefit from large pool
Does rman backup benefit from large pool
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Does rman backup benefit from large pool

475

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
475
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
21
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Does Rman Backupbenefit from Large Pool? by Maclean.liu liu.maclean@gmail.com www.oracledatabase12g.com
  • 2. About Mel Email:liu.maclean@gmail.coml Blog:www.oracledatabase12g.coml Oracle Certified Database Administrator Master10g and 11gl Over 6 years experience with Oracle DBAtechnologyl Over 7 years experience with Linux technologyl Member Independent Oracle Users Groupl Member All China Users Groupl 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 poolRMAN 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 视图中 视图中
  • 4. 若 disk_asynch_io 设置为 false,或操作系统不支持异步 默认 backup_tape_io_slaves 为 false,即磁带 IO,且 dbwr_io_slaves=0 时启 设备默认不启用 AIO 而使用 SynchronousSynchronous 用 Synchronous I/O。此时 I/O。此时 RMAN I/O 缓冲区从 PGA 中分配,I/O RMAN I/O 缓冲区从 PGA 中分 相关性能信息存放在 V$backup_sync_io 视图 配,相关 IO 性能信息存放在 中 V$backup_sync_io 视图中 启 用 disk slaves I/O,要求设置 disk_asynch_io=false 且 设置 tape_asynch_io=true 且 dbwr_io_slaves>0。此模式下 backup_tape_io_slaves=true 时启用,磁带的Slaves I/O RMAN I/O 缓冲区从 shared pool AIO 模式其实就是使用 slaves Io 模拟获得的。 或者 large pool 中分配,相关 所以此模式下的一切和 tape AIO 完全一样 IO 性能信息存放在 V$backup_async_io 视图中我们在使用 RMAN 备份数据库时无论是磁盘备份还是磁带备份总是优先期望使用 AIO 异步 IO 特性(tape aio 比较特殊,见上表),使用 AIO 的前提是设置合理的初始化参数以及操作系统支持 AIO,如果我们使用的操作系统不支持 AIO 那么我们将不得不使用Synchronous IO 同步 IO。这并不是世界末日,因为 Oracle 提供了 IO 从属进程(slaves IO)来模拟 AIO,当然这是退而求其次的。为了启用 slaves IO,我们需要手动设置backup_tape_io_slaves 或 dbwr_io_slaves 参数来启用 IO 从属特性,当使用磁带备份时设置backup_tape_io_slaves(此时 tape_asynch_io 应当为 true) 为 true,当使用磁盘设备时设置dbwr_io_slaves(此时 disk_asynch_io 应当为 false)为非零值。在启用 slaves IO 的前提下RMAN 才会从 Large pool 当中分配内存并加以利用,如果没有配置 large pool(注意如果启用了 ASMM,那么 Oracle 会自动为 large pool 分配一个 granule 大小的空间)或者 large pool过小,那么 RMAN 的内存缓冲区将从 shared pool 中分配。如果 Oracle 仍不能获得足够内存,那么将本地进程获取足够的 IO 缓存。若我们启用了 I/O slaves,那么很有必要配置一个足够大的 Large pool(一般 60-100M 就足够了),这样 RMAN 的 I/O 缓存区可以从 largepool 中分配,避免了 RMAN 的 I/O buffer 和 shared pool 中的 library cache 等其他组件发生竞争。
  • 5. If I/O slaves are used, I/O buffers are obtained from the SGA ,or the large pool, if configured.IfLARGE_POOL_SIZE is set, then Oracle attempts to get memory from the large pool. If thisvalue is not large enough, then Oracle does not try to get buffers from the shared pool.If Oraclecannot get enough memory, then it obtains I/O buffer memory from local process memory andwrites 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=0by 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 areused. If you set the initialization parameter BACKUP_TAPE_IO_SLAVES = true, then RMANallocates tape buffers from the SGA or the large pool if the LARGE_POOL_SIZE initializationparameter is set. If you set the parameter to false, then RMAN allocates the buffers from thePGA.我们来通过以下演示,进一步验证 AIO/Slave Io 环境下 RMAN 内存缓冲区从哪里分配,并加强印象:SQL> select * From v$version;BANNER----------------------------------------------------------------Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64biPL/SQL Release 10.2.0.4.0 - ProductionCORE 10.2.0.4.0 ProductionTNS for Linux: Version 10.2.0.4.0 - ProductionNLSRTL Version 10.2.0.4.0 - ProductionSQL> show parameter asyncNAME TYPE VALUE------------------------------------ -----------------------------------------
  • 6. disk_asynch_io boolean TRUEtape_asynch_io boolean TRUESQL> select * From v$sgastat where pool=large pool;POOL NAME BYTES------------ -------------------------- ----------large pool PX msg pool 903840large pool free memory 15873376backup as backupset database skip offline;SQL> select * From v$sgastat where pool=large pool;POOL NAME BYTES------------ -------------------------- ----------large pool PX msg pool 903840large 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 greporacle 20761 1 0 20:44 ? 00:00:00 ora_i101_G10R2oracle 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 903840large pool free memory 15873376RMAN> backup as backupset database skip offline;SQL> select * From v$sgastat where pool=large pool;POOL NAME BYTES------------ -------------------------- ----------large pool PX msg pool 903840large pool free memory 24151392large pool KSFQ Buffers 25276416SQL> /
  • 7. POOL NAME BYTES------------ -------------------------- ----------large pool PX msg pool 903840large pool free memory 41006432large 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 a30SQL> col describ for a70SQL> 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 forbackup/restore_backup_ksfq_bufcnt 0 number of the ksfq buffers used forbackup/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 0INPUT 131072 1OUTPUT 1048576 4另外 large pool 的使用量可以通过下列公式来估算:LARGE_POOL_SIZE =(4 * {RMAN Channels} * {DB_BLOCK_SIZE} * {DB_DIRECT_IO_COUNT} *{Multiplexing Level})
  • 8. +(4 * {RMAN Channels} * {Tape Buffer Size})事实上如果你 probe 过 PGA 的内存使用情况,那么你或许会在 PGA headdump 中看到过”KSFQ heap”的相关信息。显然当在非 slaves IO 模式下,RMAN 会从 PGA HEAP->KSFQ heap 这个 subheap 子堆中分配必要的 buffer。我们在磁盘 AIO 模式下执行必要的 backup 操作,之后找出 RMAN 相关的 shadow process并对其做 heapdump,分析其 pga 内存使用情况:SQL> select spid,pga_used_mem,pga_max_mem from v$process where addr in 2 (select paddr from v$session where program like %rman%) 3 order by pga_used_mem desc ;SPID PGA_USED_MEM PGA_MAX_MEM------------ ------------ -----------24424 5750341 1441082924425 4717957 1213412524413 3308341 962670124423 435773 993005SQL> oradebug setospid 24424;Oracle pid: 25, Unix process pid: 24424, image: oracle@rh2.oracle.com (TNSV1-V3)SQL> oradebug dump heapdump 536870917;Statement processed.SQL> oradebug tracefile_name;/s01/admin/G10R2/udump/g10r2_ora_24424.trc==========================heapdump details==============================FIVE LARGEST SUB HEAPS for heap name="pga heap" desc=0x68d3ec0 Subheap ds=0x87c83e8 heap name= KSFQ heap size= 4205296 owner=(nil) latch=(nil)******************************************************HEAP DUMP heap name="KSFQ heap" desc=0x87c83e8extent sz=0x1040 alt=32767 het=32767 rec=0 flg=2 opc=2parent=0x68d3ec0 owner=(nil) nex=(nil) xsz=0x20228EXTENT 0 addr=0x7f86bf788dd8 Chunk 7f86bf788de8 sz= 1049112 freeable "KSFQ Buffers "EXTENT 1 addr=0x7f86bf988dd8 Chunk 7f86bf988de8 sz= 1049112 freeable "KSFQ Buffers "EXTENT 2 addr=0x7f86bfb88dd8 Chunk 7f86bfb88de8 sz= 1049112 freeable "KSFQ Buffers "EXTENT 3 addr=0x7f86bfc98dd8
  • 9. Chunk 7f86bfc98de8 sz= 1049112 freeable "KSFQ Buffers "EXTENT 4 addr=0x7f86bfddf358 Chunk 7f86bfddf368 sz= 5192 freeable "KSFQ ctx "EXTENT 5 addr=0x87c7680 Chunk 0087c7690 sz= 984 perm "perm " alo=984 Chunk 0087c7a68 sz= 1944 free " " Chunk 0087c8200 sz= 464 freeable "KSFQ buffer poo"Total heap size = 4205032FREE LISTS:Bucket 0 size=0 Chunk 0087c7a68 sz= 1944 free " "Total free space = 1944UNPINNED RECREATABLE CHUNKS (lru first):PERMANENT CHUNKS: Chunk 0087c7690 sz= 984 perm "perm " alo=984Permanent space = 984/* 以上可以看到 KSFQ Heap 子堆共占用了 4205296=4M 内存, 而该服务进程的 pga_used_memory 总量为 5750341 bytes,即 KSFQ 占该进程 PGA 的 73% 另外这里 KSFQ Buffer 的大多 Chunk 是 freeable 的,仅少量为 perm */另外磁带 I/O 缓冲区的大小可以在配置通道时指定,其默认值由操作系统决定,一般为64k。我们使用 allocate channel 命令设置磁带 I/O 缓冲区,为了达到最佳性能,可以将磁带 I/O 缓冲区大小设置为 256KB 或更大,如:allocate channel maclean1 device type sbtparms="blksize=262144,ENV=(NB_ORA_SERV=nas,NB_ORA_POLICY=racdb,NB_ORA_CLIENT=rh2)";结论: 1. 在默认情况下(即 disk backup 使用 AIO 而 tape backup 使用 sync IO),RMAN backup 并不会从 Large Pool 中获益,而是从 PGA 中的 KSFQ heap 中分配必要的 I/O 内存 缓冲区。当然我们还是推荐设置 Large_pool_size 为 100M 左右,因为即使是 PC 服 务器也不会缺这一点内存 2. 仅当启用 I/O slaves 时 RMAN backup 从 Large Pool 中分配 ksfq buffer(ksfq buffer used for backup/restore),在 9i/10g 中常有因 large pool 过小而引起 ORA-04031 错误 的案例;若 large pool 大小为 0,那么 ksfq buffer 会从 shared pool 中分配,一方面 ORA-04031:(“shared pool”,”unknown object”,”sga heap(1,0)”,”KSFQ Buffers”)错误的 概率将大大增加,另一个方面将造成 KSFQ 与 library cache 间的竞争,不利于性能。 这种情况下 RMAN backup 的确从 Large pool 中得到收益,设置 large_pool_size 为 100M 仍是被推荐的
  • 10. 3. 在非 slaves IO 模式下 RMAN 从 PGA 的 KSFQ heap 子堆中分配 I/O 缓冲区,因为在 非 slaves IO 模式下该内存缓冲区没有共享的必要© 2011, www.oracledatabase12g.com. 版权所有.文章允许转载,但必须以链接方式注明源地址,否则追求法律责任.

×