ORACLE 中undo表空間爆滿的解決方法

wangyiou1988發表於2013-11-17

1. 啟動SQLPLUS,並用sys登陸到資料庫。
#su - oracle
$>sqlplus / as sysdba

2. 查詢資料庫的UNDO表空間名,確定當前例程正在使用的UNDO表空間:
Show parameter undo_tablespace。

3. 確認UNDO表空間;
SQL> select name from v$tablespace;
NAME
------------------------------
UNDOTBS1

4. 檢查資料庫UNDO表空間佔用空間情況以及資料檔案存放位置;
SQL>select file_name,bytes/1024/1024 from dba_data_files where tablespace_name like 'UNDOTBS%';

5. 檢視回滾段的使用情況,哪個使用者正在使用回滾段的資源,如果有使用者最好更換時間(特別是生產環境)。
SQL> select s.username, u.name from v$transaction t,v$rollstat r, v$rollname u,v$session s
where s.taddr=t.addr and t.xidusn=r.usn and r.usn=u.usn order by s.username;

6. 檢查UNDO Segment狀態;
SQL> select usn,xacts,rssize/1024/1024/1024,hwmsize/1024/1024/1024,shrinks
from v$rollstat order by rssize;
USN XACTS RSSIZE/1024/1024/1024 HWMSIZE/1024/1024/1024 SHRINKS
1 0 0 0.000358582 0.000358582 0
2 14 0 0.796791077 0.796791077 735
3 44 1 0.00920867919921875 3.99295806884766 996
這還原表空間中還存在3個回滾的物件。

7. 建立新的UNDO表空間,並設定自動擴充套件引數;
SQL> create undo tablespace undotbs2 datafile '/opt/oracle/oradata/ge01/UNDOTBS2.dbf' size 100m reuse autoextend on next 50m maxsize 5000m;
Tablespace created.

8. 切換UNDO表空間為新的UNDO表空間 , 動態更改spfile配置檔案;
SQL> alter system set undo_tablespace=undotbs2 scope=both;
System altered.

9.驗證當前資料庫的 UNDO表空間 【Linux公社 】
SQL> show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- --------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS2
9. 等待原UNDO表空間所有UNDO SEGMENT OFFLINE;
select usn,xacts,status,rssize/1024/1024,hwmsize/1024/1024, shrinks from v$rollstat order by rssize;
select t.segment_name,t.tablespace_name,t.segment_id,t.status from dba_rollback_segs t;
SEGMENT_NAME TABLESPACE_NAME SEGMENT_ID STATUS
1 SYSTEM SYSTEM 0 ONLINE
2 _SYSSMU1$ UNDOTBS1 1 OFFLINE
3 _SYSSMU2$ UNDOTBS1 2 OFFLINE
4 _SYSSMU47$ UNDOTBS1 47 OFFLINE
上面對應的UNDOTBS1還原表空間所對應的回滾段均為OFFLINE

10.到$ORACLE_HOME/dbs/init$ORACLE_SID.ora如下內容是否發生變更:
#cat $ORACLE_HOME/dbs/initddptest.ora
……
*.undo_management=’AUTO’
*.undo_retention=10800
*.undo_tablespace=’UNDOTBS2’
……
如果沒有發生變更請執行如下語句:
SQL> create pfile from spfile;
File created.

11. 刪除原有的UNDO表空間;
SQL> drop tablespace undotbs1 including contents;

最後需要在重啟資料庫或者重啟計算機後到儲存資料檔案的路徑下刪除資料檔案(為什麼要手動刪除呢:以上步驟只是刪除了ORACLE中undo表空間的邏輯關係,即刪除了資料檔案在資料字典中的關聯,不會自動刪除項關聯的資料檔案)。

drop tablespace undotbs1 including contents and datafiles;

本篇文章來源於 Linux公社網站() 原文連結:

[@more@]

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

相關文章