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表空间和数据文件的关系,否则拒绝申请
分享到:
相关推荐
`db_recovery_file_dest_size`是Oracle数据库中一个重要的初始化参数,它定义了用于恢复文件(如联机重做日志、控制文件备份等)的闪回区域的最大大小。这个参数与数据库的归档模式和数据保护策略密切相关。 在...
### Oracle 10g中的db_recovery_file_dest与log_archive_dest详解 #### 一、概述 在Oracle 10g数据库管理中,为了确保数据的安全性和完整性,合理的配置归档策略至关重要。本文主要针对两个重要的参数——`db_...
SELECT space_limit, space_used, space_reclaimable FROM v$recovery_file_dest; ``` 这将帮助我们了解剩余可用空间以及可回收的空间。 - 计算Flash Recovery Area的使用率百分比: ```sql SELECT space_used/...
归档日志路径三个参数DB_RECOVERY_FILE_DEST和LOG_ARCHIVE_DEST和LOG_ARCHIVE_DEST_n LOG_ARCHIVE_DEST:指定归档文件存放的路径,该路径只能是本地磁盘,默认为’’。 LOG_ARCHIVE_DEST_n:默认值为’’。...
1. **识别丢失日志**:首先,我们需要在备用数据库上通过查询`V$ARCHIVE_GAP`动态性能视图来确定丢失的日志。这个视图显示了当前存在的所有日志缺口,包括线程号(THREAD#)、丢失的最小序列号(LOW_SEQUENCE#)和...
29. **V$RECOVERY_FILE_DEST**: 指定了恢复文件的目的地。 30. **V$RECOVERY_FILE_STATUS**: 显示恢复文件的状态信息。 31. **V$RECOVERY_LOG**: 显示恢复日志的信息。 32. **V$RECOVERY_PROGRESS**: 显示恢复进度的...
在更改参数LOG_ARCHIVE_DEST_1之后,V$ARCHIVED_LOG视图中的文件名显示为空。这可能是因为数据库无法正确地识别或解析ASM之外的非ASM存储路径。 当重新将归档目标设置回ASM时,例如`LOCATION=+DISK/testrac/`,V$...
is_file($destination_dir . $dest_file_name)) { $content = ""; foreach ($array_files as $file) { $content .= file_get_contents($file); } // 可以在此处添加代码进行文件内容压缩 // minify_my_js($...
is_file($destination_dir . $dest_file_name)){ $content = ""; foreach ($array_files as $file){ $content .= file_get_contents($file); } // 可以在这里添加文件压缩功能 // minify_my_js($content); $...
### Oracle 11g 中 log_archive_dest, log_archive_dest_n 和 standby_archive_dest 参数详解 #### 一、引言 在Oracle数据库中,归档日志是实现数据恢复的关键组件之一。为了确保系统的高可用性和灾难恢复能力,...
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)
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 ...
`和`SELECT ARCH_NAME, ARCH_TYPE, ARCH_DEST, ARCH_FILE_SIZE, ARCH_SPACE_LIMIT, ARCH_TIMER_NAME, ARCH_IS_VALID FROM SYS.V$DM_ARCH_IN`来获取归档相关的配置。 这些查询语句和系统视图是数据库管理员日常运维...
- `SELECT * FROM V$RECOVERY_FILE_DEST`:查看RMAN恢复文件的目标位置和使用情况。 12. **V$LOG视图**: - `SELECT * FROM V$LOG`:了解重做日志的状态,确保归档和日志切换正常。 13. **V$DATABASE视图**: -...
Oracle的`V$`动态性能视图是数据库管理系统中用于监控和诊断的关键组件,它提供了丰富的数据库运行状态信息。这些视图允许DBA(数据库管理员)实时查看和分析数据库的活动,从而优化性能、诊断问题和规划资源。以下...
if(isset($_FILES['image']) && $_FILES['image']['error'] === UPLOAD_ERR_OK) { $temp_file = $_FILES['image']['tmp_name']; $file_name = basename($_FILES['image']['name']); $upload_dir = 'uploads/'; //...
- `v$recovery_file_dest` 视图显示恢复文件区域的详细信息,包括配额、已使用空间、可回收空间和文件数量。 8. **Oracle DG 重启**: - **DG 备机重启**: - 方法1:取消恢复,立即关闭数据库,非挂载启动,...
imagecopymerge($dst, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 50); // 50是透明度 ``` 5. **批量处理**:对于批量操作,可以遍历文件夹中的所有图片,逐个执行上述步骤。...
- 选项A:`DB_RECOVERY_FILE_DEST`参数用于指定恢复文件(如归档日志和RMAN备份)的存放位置,与块更改跟踪文件无关。 - 选项B:启用块更改跟踪应使用`ALTER DATABASE`命令,而非`ALTER SYSTEM`。 - 选项C:...
SELECT * FROM v$recovery_file_dest; ``` - **说明**:查看快速恢复区域的配置情况。 - **应用场景**:了解快速恢复区域是否已经足够大,以满足归档日志和其他恢复文件的存储需求。 2. **设置快速恢复区域大小...