Oracle undo資料表空間爆滿的解決步驟:
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資料表空間 【幫客之家 http://www.bkjia.com 】
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;