oracle UNDO表空間一個bug——undo表空間快速擴充套件

atlantisholic發表於2011-10-13

最近發現在有兩個資料庫的undo表空間使用率一直在增長,過兩天就加一次,已經加到快40G了,後來感覺這個現象有點不正常了,因為資料庫的事務並不那太頻繁,不至於總是到達100%
的地步,於是在網上查了下,果然這是oracle的一個bug造成的。這個bug應該是oracle10.2版本的所有平臺上都存在。該bug oracle說在10.2.0.4版本上已經修補,但我還確實在AIX上發現了


BUG號:5387030、420525.1

環境:
OS\DB: AIX 5.3\oracle 10.2.0.2 64-bit
OS\DB: HP-Unix\oracle 10.2.0.2 64-bit

現象:
檢視當前undo表空間使用率:
SQL>select t.tablespace_name, total, free, round(100*(1-(free/total)),3)||'%' 已使用的空間比例
   from (select tablespace_name, sum(bytes)/1024/1024 total from dba_data_files
         where tablespace_name='UNDOTBS1'
        group by tablespace_name) t,
   (select tablespace_name, sum(bytes)/1024/1024 free from dba_free_space
    group by tablespace_name) f where t.tablespace_name=f.tablespace_name(+)
   order by tablespace_name;
  
TABLESPACE_NAME                     TOTAL       FREE 已使用的空間比例
------------------------------ ---------- ---------- -----------------------------------------
UNDOTBS1                            39000 1442.0625 95.027%


undo表空間是非自動擴充套件的:
SQL> Select file_name,Autoextensible From Dba_Data_Files
2 Where tablespace_name='UNDOTBS1'
3 Order By File_id;
FILE_NAME                                                                        AUTOEXTENSIBLE
-------------------------------------------------------------------------------- --------------
/gsfs02/oradata/CICGSFSP/undotbs01.dbf                                           NO
/gsfs03/oradata/CICGSFSP/undotbs02.dbf                                           NO
.........

SQL> show parameter undo_retention

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_retention                       integer     1800


解決:
設表空間為自動擴充套件並設表空間最大值為表空間現在大小,其作用跟表空不自動擴充套件效果是一樣的,這樣避免這個bug的產生
--生成修改資料檔案指令碼
Select 'alter database datafile ''' || file_name || ''' Autoextend on ' || 'Maxsize ' || to_char(bytes/1024/1024) || 'm;' From Dba_Data_Files
Where tablespace_name='UNDOTBS1'
Order By File_id

alter database datafile '/gsfs02/oradata/CICGSFSP/undotbs01.dbf' Autoextend on Maxsize 2000m;
alter database datafile '/gsfs03/oradata/CICGSFSP/undotbs02.dbf' Autoextend on Maxsize 2000m;
alter database datafile '/gsfs04/oradata/CICGSFSP/undotbs03.dbf' Autoextend on Maxsize 2000m;
alter database datafile '/gsfs05/oradata/CICGSFSP/undotbs04.dbf' Autoextend on Maxsize 2000m;
.......

SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'YYYY-MM-DDHH2
------------------------------
2010-10-29 10:40:03

然後執行其指令碼修改資料檔案自動擴充套件屬性為on

第隔幾分鐘再次觀察undo表空間使用情況,使用率在直線下降:

TABLESPACE_NAME                     TOTAL       FREE 已使用的空間比例
------------------------------ ---------- ---------- -----------------------------------------
UNDOTBS1                            29000 3790.0625 86.931%

TABLESPACE_NAME                     TOTAL       FREE 已使用的空間比例
------------------------------ ---------- ---------- -----------------------------------------
UNDOTBS1                            29000 10837.0625 62.631%

TABLESPACE_NAME                     TOTAL       FREE 已使用的空間比例
------------------------------ ---------- ---------- -----------------------------------------
UNDOTBS1                            38000 27496.9375 27.64%

然後再看看一重要檢視v$undostat的tuned_undoretention欄位的建議值:
--2010-10-29 10:42:18 這個時間正好是我修改完資料檔案屬性之後的時間

SQL> select to_char(begin_time,'yyyy-mm-dd hh24:mi:ss'),to_char(end_time,'yyyy-mm-dd hh24:mi:ss'),undoblks,tuned_undoretention,maxquerylen,maxqueryid from v$undostat WHERE rownum < 20;

TO_CHAR(BEGIN_TIME,'YYYY-MM-DD TO_CHAR(END_TIME,'YYYY-MM-DDHH   UNDOBLKS TUNED_UNDORETENTION MAXQUERYLEN MAXQUERYID
------------------------------ ------------------------------ ---------- ------------------- ----------- -------------
2010-10-29 10:52:18            2010-10-29 10:56:39                  1128                1800          88 5kma9ywsgcwhm
2010-10-29 10:42:18            2010-10-29 10:52:18                  6848                1800          88 5kma9ywsgcwhm
2010-10-29 10:32:18            2010-10-29 10:42:18                  5847              345600         200 cykr0t05sxa73
2010-10-29 10:22:18            2010-10-29 10:32:18                  3770              345600         199 70r1113n3vwyu
2010-10-29 10:12:18            2010-10-29 10:22:18                  5014              345600         105 4cp98gmy1q8qk
2010-10-29 10:02:18            2010-10-29 10:12:18                  5292              345600         229 3156qc5zh5pwn
2010-10-29 09:52:18            2010-10-29 10:02:18                  4113              345600         142 1amcb16ytfpbx
2010-10-29 09:42:18            2010-10-29 09:52:18                  6184              345600          79 7qbdzfacr8srx
2010-10-29 09:32:18            2010-10-29 09:42:18                  3939              345600          78 bunvx480ynf57
2010-10-29 09:22:18            2010-10-29 09:32:18                  5575              345600          56 3s4zvp29gjsz0

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23071790/viewspace-709105/,如需轉載,請註明出處,否則將追究法律責任。

相關文章