`
qjoycn
  • 浏览: 1215425 次
文章分类
社区版块
存档分类
最新评论

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

 
阅读更多

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

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.


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.

注意事项:
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.


- 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
/

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群:69087192

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

分享到:
评论

相关推荐

    oracle数据库设置db_recovery_file_dest_size参数为0

    当我们设置数据库的归档路径时,就没有必要在使用db_recovery_file_dest参数,可是如果db_recovery_file_dest_size的值不为0,那么该如何设置呢?

    10g中db_recovery_file_dest和log_archive_dest_greatwhite

    在10g中,如果指定了db_recovery_file_dest 参数,那么归档日志将存放到这个参数指向的目录下,如果同时指定了log_archive_dest,则将同时往这两个参数指定的目录中归档。

    关于归档日志三个参数的说明.txt

    归档日志路径三个参数DB_RECOVERY_FILE_DEST和LOG_ARCHIVE_DEST和LOG_ARCHIVE_DEST_n LOG_ARCHIVE_DEST:指定归档文件存放的路径,该路径只能是本地磁盘,默认为’’。 LOG_ARCHIVE_DEST_n:默认值为’’。...

    达梦数据库常用系统视图及查询语句.pdf

    达梦数据库常⽤系统视图及查询语句 ⼀、常⽤的系统视图: dba_objects:显⽰... select ARCH_NAME, ARCH_TYPE, ARCH_DEST, ARCH_FILE_SIZE, ARCH_SPACE_LIMIT, ARCH_TIMER_NAME, ARCH_IS_VALID from SYS.V$DM_AR CH_IN

    ORACLE DATAGUARD中手工处理日志v$archive_GAP的方法

    从9i以后,oracle dataguard 备库一般都不需要手工处理丢失的日志,FAL自动会帮我们处理,本文主要通过个案例来讲下手工处理丢失的日志的方法。

    python批量复制文件到另一个文件夹

    import shutil ... for file_name in os.listdir(src_folder): src_file = os.path.join(src_folder, file_name) dest_file = os.path.join(dest_folder, file_name) shutil.copy2(src_file, dest_file)

    GENESIS 2000 DFM PE

    The DFM Programming Environment is one of the many unique concepts of the Genesis 2000 system. Unlike any existing tool, the DFM Programming Environment (DFMPE) enables any user with elementary ...

    jewelry_origin_dest.pdf

    jewelry_origin_dest.pdf

    linux下的Oracle数据库安装,卸载和静默安装

    audit_file_dest=$ORACLE_BASE/admin/orcl/adump background_dump_dest=$ORACLE_BASE/admin/orcl/bdump core_dump_dest=$ORACLE_BASE/admin/orcl/cdump user_dump_dest=$ORACLE_BASE/admin/orcl/udump control_files...

    Short Message peer to peer Protocol specification v3.4

    SMPP Protocol Specification v3.4 Table of Contents Issue 1.2 ©SMPP Developers Forum Page 5 of 169 4.1.7 “OUTBIND” Operation. ...............................................................54 4.1....

    ORACLE数据库 安装配置规范 (V2.0.1)

    目录 1 前言 7 1.1 编写目的 7 1.2 预期读者 8 2 数据库部署模式及选择建议 8 2.1 数据库部署模式 8 2.2 单机模式 8 ...7.1 ASM 57 7.2 FLASH BACK数据库 57 8 附件 57 8.1 Oracle参数说明 57 8.2 合规性检查 58

    coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip

    detection资源文件,下载后放到app下的build下的zips中,同时修改download_model.gradle文件,屏蔽task downloadZipFile,并把task downloadAndUnzipFile 中的 from zipTree(downloadZipFile.dest) 修改为 from ...

    oracle实验报告

    mydb.__oracle_base='E:\\app\\oracle'#ORACLE_BASE set from environment mydb.__pga_aggregate_target=322961408 orcl.__sga_target=536870912 mydb.__shared_io_pool_size=0 orcl.__shared_pool_size=...

    jQuery实现的多选框多级联动插件

    标签的属性”name”和选中的属性”value” // 后台用json格式传输数据 // 格式: { value:的属性”value”, text:的显示文本 } (function($) { $.fn.extend({ autoSelect: function(dest, url) { return this.each...

    php批量上传图片php批量上传图片

    php批量上传图片php批量上传图片php批量上传图片php批量上传图片

    YUV2转JPEG的DEMO

    static void put_jpeg_yuv420p_file(FILE *fp, unsigned char *image, int width, int height, int quality) { int i, j; JSAMPROW y[16],cb[16],cr[16]; // y[2][5] = color sample of row 2 and ...

    tcp.rar_This Is Happy_des_send tcp_sendtcp_tcp dest

    1)以命令行形式运行:SendTCP source_IP source_port dest_ip dest_port 其中,SendTCP为程序名,source_IP为源端IP地址,source_port为源端口,dest_ip 为目的IP地址,dest_port为目的端口 2)其他的TCP头部参数请...

    解决Oracle数据库归档日志占满磁盘空间问题

    1、常用命令 SQL&gt; show parameter log_archive_dest;...SQL&gt; select sum(percent_space_used)*3/100 from v$flash_recovery_area_usage; 2.9904 SQL&gt; show parameter recover; db_recovery_file_dest

    log_archive_dest, log_archive_dest_n和standby_archive_dest

    在oracle的初始化参数中,与归档日志目录有关的有:log_archive_dest, log_archive_dest_n和standby_archive_dest, 那么这三个参数的相互关系如何呢,下面就通过试验进行详细讲解。实验环境为oracle11g。

    发送TCP数据包源代码+设计报告

    发送TCP数据包 设计题目 本设计的目的是填充一个TCP数据包,并发送给目的主机。...3)数据字段为“This is my homework of network,I am very happy!”。 4)成功发送后在屏幕上输出“send OK”。

Global site tag (gtag.js) - Google Analytics