对oracle数据库undo表空间的监控和管理是我们日常最重要的工作之一,undo表空间通常都是oracle自动化管理(通过undo_management初
对oracle数据库undo表空间的监控和管理是我们日常最重要的工作之一,undo表空间通常都是oracle自动化管理(通过undo_management初始化参数确定);undo表空间是用于存储dml操作的前镜像数据,它是实例恢复,数据回滚,一致性查询功能的重要组件;我们常常会忽略对它的监控,这会导致undo表空间可能出现以下问题:
1).空间使用率100%,导致dml操作无法进行。
2).告警日志中出现大量的ora-01555告警错误。
3).实例恢复失败,数据库无法正常打开。
--------------------------------------------------------------------------------
rman备份与恢复之undo表空间丢失
关于oracle 释放过度使用的undo表空间
oracle undo的一些理解
oracle undo 镜像数据探究
oracle 回滚(rollback)和撤销(undo)
linux-6-64下安装oracle 12c笔记
在centos 6.4下安装oracle 11gr2(x64)
oracle 11gr2 在vmware虚拟机中安装步骤
debian 下 安装 oracle 11g xe r2
--------------------------------------------------------------------------------
一.对oracle自动化管理undo进行干预。
由于undo是自动化管理,可干预的地方非常的少,,更多的是监控,通过以下几个地方可对undo表空间实施一定的干预:
1).初始化参数
undo_management=auto 表示实例自动化管理undo表空间,从oracle 9i开始,oracle引进了aum(automatic undo management)。
undo_retention=900 事务提交后,相应的undo数据保留的时间,单位:秒。
undo_tablespace=undotbs1 活动的undo表空间。
_smu_debug_mode=33554432
_undo_autotune=true
2).automatic undo retention
automatic undo retention是10g的新特性,在10g和之后的版本的数据库,这个特性是默认启用的。
在oracle database 10g中当自动undo管理被启用,总是存在一个当前的undo retention,oracle database尝试至少保留旧的undo信息到该时间。数据库收集使用情况统计信息,基于这些统计信息和undo表空间大小来调整undo retention的时间。
oracle database基于undo表空间大小和系统活动自动调整undo retention,通过设置undo_retention初始化参数指定undo retention的最小值。
查看oracle自动调整undo retention的值可以通过以下查询获得:
select to_char(begin_time, 'mm/dd/yyyy hh24:mi:ss') begin_time,
tuned_undoretention from v$undostat;
针对自动扩展的undo表空间,系统至少保留undo到参数指定的时间,自动调整undo retention以满足查询对undo的要求,这可能导致undo急剧扩张,可以考虑不设置undo retention值。
针对固定的undo表空间,系统根据最大可能的undo retention进行自动调整,参考基于undo表空间大小和使用历史进行调整,这将忽略undo_retention,除非表空间启用了retention guarantee。
自动调整undo retention不支持lob,因为不能在undo表空间中存储任何有关lobs事务的undo信息。
可以通过设置_undo_autotune=false显示的关闭automatic undo retention功能。
3).tuned_undoretention计算的值很大导致undo表空间增长很快?
当使用的undo表空间非自动增长,tuned_undoretention是基于undo表空间大小的使用率计算出来的,在一些情况下,特别是较大的undo表空间时,这将计算出较大的值。
为了解决此行为,设置以下的实例参数:
_smu_debug_mode=33554432
设置该参数,tuned_undoretention就不基于undo表空间大小的使用率计算,代替的是设置(maxquerylen +300)和undo_retention的最大值。
4).undo表空间数据文件自动扩展
如果undo表空间是一个自动扩展的表空间,那么很有可能undo表空间状态为expired的extent不会被使用(这是为了减少报ora-01555错误的几率),这将导致undo表空间变得很大;如果将undo表空间设置为非自动扩展,那么状态为expired的extent就能被利用,这样可以一定程度控制undo表空间的大小,但这样会增加ora-01555报错和undo空间不足报错的风险。合理的非自动扩展的undo表空间大小,以及合理的undo_retention设置可以确保稳定的undo空间使用。
5).undo表空间guarantee属性
如果undo表空间是noguarantee状态,oracle不确保提交后的事务对应的undo表空间中的数据会保留undo_retention指定的时长,如果undo表空间不足,其他事务将可能偷盗相应的未过期的空间;将undo表空间设置为guarantee能够确保提交后的事务对应undo表空间中的数据在任何情况下都将保留undo_retention指定的时长。
sql> select tablespace_name, retention from dba_tablespaces where tablespace_name='undotbs1';
tablespace_name retention
------------------------------------------------------------ ----------------------
undotbs1 noguarantee
sql> alter tablespace undotbs1 retention guarantee;
表空间已更改。
sql> select tablespace_name, retention from dba_tablespaces where tablespace_name='undotbs1';
tablespace_name retention
------------------------------------------------------------ ----------------------
undotbs1 guarantee
6).undo表空间大小