今天生产库进行FLASHBACK query闪回查询的时候遇到一个问题, ORA-01555: snapshot too old .......数据已经不能被闪回了...吸取教训了,在安装文档里就要对此项参数装完数据库后即刻作出调整。
我的环境是数据库版本是Oracle10g Release 2的,查看的数据库参数undo_retention设置,发现这个参数被在10g中缺省的被设置为900秒(15分钟),这个时间长度是太短了,再安装的时候忘记修改了,马上将这个参数修改为10800,3个小时:
ALTER SYSTEM SET undo_retention=10800 SCOPE=BOTH;
为什么是3个小时?
以前一度这个参数的缺省值被设为10800,可是随之而来的是UNDO表空间的过分扩展,难以回收,Oracle在不同版本中,也在进行不停的加权和折中。
Oracle也许会这样想:如果很少有人使用Flashback Query,而过大的undo_retention又会带来麻烦,那么干脆,设小点。
如何理解这个参数的作用呢?
链接:http://blog.youkuaiyun.com/seagal890/article/details/3044226
Oracle10g中的自动撤销管理(AUM)
UNDO_TABLESPACE
|
SQL> show parameter undo_tablespace;
NAME TYPE VALUE
------------------------------------ ----------- -----------------------
undo_tablespace string UNDOTBS1
SQL> show parameter undo_management;
NAME TYPE VALUE
------------------------------------ ----------- -----------------------
undo_management string AUTO
SQL> show parameter undo_retention;
NAME TYPE VALUE
------------------------------------ ----------- -----------------------
undo_retention integer 900
SQL>
|
|
Initialization Parameter
|
Description
|
|
UNDO_MANAGEMENT
|
If AUTO, use automatic undo management. The default is MANUAL
|
|
UNDO_TABLESPACE
|
An optional dynamic parameter specifying the name of an undo tablespace. This parameter should be used only when the database has multiple undo tablespaces and you want to direct the database instance to use a particular undo tablespace.
|
|
UNDO_RETENTION
|
The UNDO_RETENTION parameter is ignored for a fixed size undo tablespace. The database may overwrite unexpired undo information when tablespace space becomes low.
For an undo tablespace with the AUTOEXTEND option enabled, the database attempts to honor the minimum retention period specified by UNDO_RETENTION. When space is low, instead of overwriting unexpired undo information, the tablespace auto-extends. If the MAXSIZE clause is specified for an auto-extending undo tablespace, when the maximum size is reached, the database may begin to overwrite unexpired undo information.
|
UNDO_RETENTION的值应该设置为多少才合理?
|
CREATE UNDO TABLESPACE UNDOTBS01
DATAFILE
‘E:/oracle/product/10.2.0/oradata/keymen/UNDOTBS01.DBF’
SIZE 500M AUTOEXTEND ON
RETENTION GUARANTEE
|
|
ALTER DATABASE UNDOTBS01 RETENTION GUARANTEE
|
|
ALTER DATABASE UNDOTBS01 RETENTION NOGUARANTEE
|
设置撤销表空间的尺寸
也就是说,如果有其他事务需要回滚空间,而空间出现不足时,这些信息仍然会被覆盖。
很多时候这是不希望看到的。
从Oracle10g开始,如果你设置UNDO_RETENTION为0,那么Oracle启用自动调整以满足最长运行查询的需要。当然如果空间不足,那么Oracle满足最大允许的长时间查询。而不再需要用户手工调整。
同时Oracle增加了Guarantee控制,也就是说,你可以指定UNDO表空间必须满足UNDO_RETENTION的限制。
SQL> alter tablespace undotbs1 retention guarantee; Tablespace altered SQL> alter tablespace undotbs1 retention noguarantee; Tablespace altered 在DBA_TABLESPACES视图中增加了RETENTION字段用以描述该选项: SQL> select tablespace_name,contents,retention from dba_tablespaces; TABLESPACE_NAME CONTENTS RETENTION ------------------------------ --------- ----------- SYSTEM PERMANENT NOT APPLY UNDOTBS1 UNDO NOGUARANTEE SYSAUX PERMANENT NOT APPLY TEMP TEMPORARY NOT APPLY USERS PERMANENT NOT APPLY 14 rows selected |
在Oracle官方文档上这样解释:
RETENTION Undo tablespace retention:
GUARANTEE - Tablespace is an undo tablespace with RETENTION specified as GUARANTEE
A RETENTION value of GUARANTEE indicates that unexpired undo in all undo segments in the undo tablespace should be retained even if it means that forward going operations that need to generate undo in those segments fail.
NOGUARANTEE - Tablespace is an undo tablespace with RETENTION specified as NOGUARANTEE
NOT APPLY - Tablespace is not an undo tablespace.
本文详细解析了Oracle数据库中UNDO_RETENTION参数的作用、如何理解其作用、参数设置及其对数据库性能的影响。重点讨论了参数的合理设置策略,包括不同类型的数据库系统(OLTP、混合、DSS系统、闪回查询)对应的不同保留时间,并介绍了如何通过初始化参数、UNDOAdvisor等工具来优化参数设置,以确保数据库高效稳定运行。
2383

被折叠的 条评论
为什么被折叠?



