如何对undo表空间大小进行设置

1.对于undo表空间大小的设置需要参考三组数据

  1. (UR)每秒钟的undo_retention
  2. (UPS)每秒钟生成的undo数据块的数量
  3. (DBS)undo表空间的db_block_size大小

2.undo表空间需要分配空间大小,通过一下公式进行计算

  其中两个配置可以在数据库中直接查询或配置:undo_retention和db_block_size,这个公式的第三部分需要到正在运行的数据库中进行查询,每秒钟使用的undo数据块可以从v$undostat视图中进行获取。

UndoSpace = UR * (UPS * DBS)

3.下面的公式计算每秒使用的峰值undo块

  ENT_TIME和BEGIN_TIME是时间数据类型,ENT_TIME减去BEGIN_TIME,就是这两个时间段的天数,将天数转换为秒数需要乘以86400,一天的描述(24*60*60)

SELECT undoblks/((end_time-begin_time)*86400) "Peak Undo Block Generation" FROM v$undostat WHERE undoblks=(SELECT MAX(undoblks) FROM v$undostat);

4.下面的查询计算处理峰值undo活动所需的字节数

SELECT (UR * (UPS * DBS)) AS "Bytes"
  FROM (SELECT value AS UR FROM v$parameter WHERE name = 'undo_retention'),
       (SELECT undoblks / ((end_time - begin_time) * 86400) AS UPS
          FROM v$undostat
         WHERE undoblks = (SELECT MAX(undoblks) FROM v$undostat)),
       (SELECT block_size AS DBS
          FROM dba_tablespaces
         WHERE tablespace_name =
               (SELECT UPPER(value)
                  FROM v$parameter
                 WHERE name = 'undo_tablespace'));

5.对于10G以上的版本使用下面的SQL语句进程查询

SELECT (UR * (UPS * DBS)) AS "Bytes"
  FROM (select max(tuned_undoretention) AS UR from v$undostat),
       (SELECT undoblks / ((end_time - begin_time) * 86400) AS UPS
          FROM v$undostat
         WHERE undoblks = (SELECT MAX(undoblks) FROM v$undostat)),
       (SELECT block_size AS DBS
          FROM dba_tablespaces
         WHERE tablespace_name =
               (SELECT UPPER(value)
                  FROM v$parameter
                 WHERE name = 'undo_tablespace'));

  

6.下面对实际生产库进行查询检验

SQL> set num 15
SQL> SELECT (UR * (UPS * DBS)) AS "Bytes"
  2    FROM (select max(tuned_undoretention) AS UR from v$undostat),
  3         (SELECT undoblks / ((end_time - begin_time) * 86400) AS UPS
  4            FROM v$undostat
  5           WHERE undoblks = (SELECT MAX(undoblks) FROM v$undostat)),
  6         (SELECT block_size AS DBS
  7            FROM dba_tablespaces
  8           WHERE tablespace_name =
  9                 (SELECT UPPER(value)
 10                    FROM v$parameter
 11                   WHERE name = 'undo_tablespace'));

          Bytes
---------------
63436368964.267

SQL> select 63436368964/1024/1024/1024 from dual;

63436368964/1024/1024/1024
--------------------------
            59.07972246781

  

查看undo表空间的大小

SQL> select sum(bytes/1024/1024/1024) "undo sizeG" from dba_data_files where TABLESPACE_NAME='UNDOTBS1';

     undo sizeG
---------------
  39.9462890625

  

经过上面的对比,发现实际分配的undo表空间比计算得到的空间大小差距较大,alert日志中最近一定存在ORA-01555错误

Tue Apr 24 15:41:44 2018
ORA-01555 caused by SQL statement below (SQL ID: 7ng6c01huuk1s, Query Duration=6 sec, SCN: 0x0022.1c41386c):
Tue Apr 24 15:41:44 2018

  

  

 

转载于:https://www.cnblogs.com/hanglinux/p/8967898.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值