签到成功

知道了

CNDBA社区CNDBA社区

How v$recovery_file_dest.space_used is calculated from v$asm_file.bytes in ASM

2016-11-25 15:50 1609 0 原创 Oracle 11g
作者: dave

 

http://www.cndba.cn/dave/article/831

Oracle Server - Enterprise Edition - Version: 11.1.0.7 and later   [Release: 11.1 and later ]

 http://www.cndba.cn/dave/article/831

       The purpose of this note is to provide insight on how space allocation ( v$asm_file.space column ) in ASM can be calculated depending on Allocation Unit size, redundancy and striping scheme. http://www.cndba.cn/dave/article/831http://www.cndba.cn/dave/article/831http://www.cndba.cn/dave/article/831


       There will be big space gap for Flashback logs in recovery destination diskgrop as the default redundancy and striping method for Flashback logs are "Mirror" and "High" and the way of how v$recovery_file_dest.space_used is calculated in ASM. As a result of this space gap, recovery destination clean up mechanism sometimes won't kick in even db_recovery_file_dest_size is used up.


       db_recovery_file_dest_size should be calculated carefully by taking into redundancy, striping and AU boundary as it can cause database hung in a situation when archivelog can not be generated.


This note will be useful -
1. Calculate the exact size of a file in ASM environment.
2. Calculate v$recovery_file_dest.space_used for flashback logs and archived log files.
http://www.cndba.cn/dave/article/831

 

注意事项:
       This script is provided for educational purposes only and not supported by Oracle Support Services. It has been tested internally, however, and works as documented. We do not guarantee that it will work for you, so be sure to test it in your environment before relying on it.

       Proofread this script before using it! Due to the differences in the way text editors, e-mail packages and operating systems handle text formatting (spaces, tabs and carriage returns), this script may not be in an executable state when you first receive it. Check over the script to ensure that errors of this type are corrected.



ASM space allocation consideration

       1.    The space of each ASM file is allocated in Allocation Unit boundary - default 1M but can be specified at the creation of a diskgroup with an attribute.

      2. Each file on ASM is created with a corresponding template either explictly or implictly depending on file type.
- Check v$asm_template
- Attribute can be altered.
SQL> alter diskgroup <diskgroup_name> alter template <template_name> attributes ( coarse ) ;


3.  v$asm_file.bytes is calculated from v$asm_file.blocks * v$asm_file.block_size .

4.  v$asm_file.block_size varies to the file type - online redo - 512 bytes, control file - 16K etc .

5. v$asm_file.space is calculated by taking into account of AU boundary, redundancy and striping width. See Useful SQL statement - SQL1.
-  For FINE striping scheme with 128K, striping width is 8 AU (Allocation Units. )
- 1st 128K needs 1AU space allocation and 2nd 128K needs another 1AU, subsequently 1M with 128K striping width needs 8AU space allocation.

6. Big space gap between v$asm_file.bytes and v$asm_file.space can be seen if an ASM file is created with a combination of FINE striping and normal or high redundancy.

7. In Oracle instance side, v$recovery_file_dest.space_used only takes into account of AU boundary of v$asm_file.bytes, doesn't take into striping and redundancy.
- See Useful SQL satement - SQL2.
- This is mainly because v$asm_file.space does not mean all space in these extent is full.
- v$recovery_file_dest.space_used = sum(ceil (( v$asm_file.bytes + 1) / AU ) * AU )

8. But recovery destination cleanup mechanism will kick in by the usage of based on v$asm_file.space.



Useful SQL statement

SQL1
How v$asm_file.space is calculated from v$asm_file.bytes depending on striping and redundancy scheme of a diskgroup. http://www.cndba.cn/dave/article/831


- Please note that space allocation on ASM diskgroup is based on v$asm_file.space, not from v$asm_file.bytes.


-------------------------
set linesize 140

col g_n format 999
col f_n format 9999
col bytes format 999,999,999,999
col space format 999,999,999,999
col a_i format 999
col blocks format 999,999
col block_size format 999,999
col ftype format a16
col dir format a3
col s_created format a10
col full_alias_path format a40
col striped format a6
col rdun format a6
col au format 99999999
col calculated format 999,999,999,999

select x.gnum g_n,
x.filnum f_n,
substr(x.full_alias_path,1, 40) full_alias_path,
f.striped,
f.redundancy rdun,
f.bytes,
f.space,
case when calculated / x.au > 60 then calculated + 3 * x.au -- Over 60 direct extents consideration
else calculated
end calculated
from ( SELECT gnum,filnum,au, concat('+'||gname, sys_connect_by_path(aname, '/')) full_alias_path
from ( SELECT g.name gname,
g.allocation_unit_size au,
a.parent_index pindex,
a.name aname,
a.reference_index rindex,
a.group_number gnum,
a.file_number filnum
FROM v$asm_alias a, v$asm_diskgroup g
WHERE a.group_number = g.group_number)
START WITH (mod(pindex, power(2, 24))) = 0 CONNECT BY PRIOR rindex = pindex) x,
(select f.group_number gnum,
f.file_number filnum,
f.type ftype ,
f.bytes,
f.space,
f.blocks,
f.block_size,
f.striped,
f.redundancy,
case f.striped when 'FINE'
then ceil(((f.blocks * f.block_size + 1) / g.allocation_unit_size) / 8)
* decode(f.redundancy, 'HIGH', 3 , 'MIRROR', 2, 'UNPROT', 1 ) * 8 * g.allocation_unit_size
else ceil((f.blocks * f.block_size + 1) / g.allocation_unit_size)
* decode(f.redundancy, 'HIGH', 3 , 'MIRROR', 2, 'UNPROT', 1 ) * g.allocation_unit_size
end calculated
from v$asm_file f , v$asm_diskgroup g
where f.group_number = g.group_number
order by f.group_number,file_number) f
where x.filnum != 4294967295
and x.gnum=f.gnum and x.filnum=f.filnum
/
-------------------------

SQL2. How v$recovery_file_dest.space_used is calculated from v$asm_file.bytes.

-------------------------
set linesize 140

col g_n format 999
col f_n format 9999
col bytes format 999,999,999,999
col space format 999,999,999,999
col a_i format 999
col blocks format 999,999
col block_size format 999,999
col ftype format a16
col dir format a3
col s_created format a10
col full_alias_path format a40
col striped format a6
col redundancy format a10
col au format 99999999
col size_au format 999,999,999,999

break on report
compute sum of size_au on report

select x.gnum g_n,
x.filnum f_n,
substr(x.full_alias_path,1, 40) full_alias_path,
f.ftype,
f.bytes,
ceil((f.bytes + 1 ) / x.au ) * x.au size_au, -- take into account only AU boundary of actual bytes
f.space,
f.striped,
f.redundancy
from (select gname, gnum,filnum, au, concat('+'||gname, sys_connect_by_path(aname, '/')) full_alias_path
from ( select g.name gname,
g.allocation_unit_size au,
a.parent_index pindex,
a.name aname,
a.reference_index rindex,
a.group_number gnum,
a.file_number filnum
from v$asm_alias a, v$asm_diskgroup g
where a.group_number = g.group_number)
start with (mod(pindex, power(2, 24))) = 0 connect by prior rindex = pindex
) x,
(select f.group_number gnum,
f.file_number filnum,
f.type ftype ,
f.bytes,
f.space,
f.redundancy,
f.striped
from v$asm_file f
order by f.group_number,file_number
) f
where x.filnum != 4294967295
and x.gname = '&DB_RECOVERY_FILE_DEST' -- Put the diskgroup name seen in db_recovery_file_dest
and x.gnum=f.gnum
and x.filnum=f.filnum
/
---------------------------------

SQL3. v$asm_template - striping and redundancy information for ASM files.

---------------------------
set linesize 140
col g_n format 99
col e_n format 999
col name format a20

select group_number g_n,
entry_number e_n,
name,
redundancy,
stripe,
system
from v$asm_template
order by g_n, e_n
/
---------------------------

SQL4. SQL for querying v$recovery_file_dest
---------------------------------
set linesize 140

col name format a20
col space_limit format 999,999,999,999
col space_used format 999,999,999,999
col space_reclaimable format 999,999,999,999
col number_of_files format 999,999,999,999

select name,
space_limit,
space_used,
space_reclaimable,
number_of_files
from v$recovery_file_dest
/

 

 http://www.cndba.cn/dave/article/831

 

From Oracle

-------------------------------------------------------------------------------------------------------

Blog http://blog.csdn.net/tianlesoftware

Email: dvd.dba@gmail.com

DBA1 群:62697716();   DBA2 群:62697977()   DBA3 群:62697850()  

DBA 超级群:63306533();  DBA4 群: 83829929  DBA5群: 142216823   

聊天 群:40132017   聊天2群:69087192http://www.cndba.cn/dave/article/831http://www.cndba.cn/dave/article/831

--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请

版权声明:本文为博主原创文章,未经博主允许不得转载。

oracle 11g

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2261
    原创
  • 3
    翻译
  • 578
    转载
  • 191
    评论
  • 访问:7983200次
  • 积分:4346
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ