回滾表空間爆滿解決

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表空間佔用空間情況以及數據文件存放位置;


select file_name, bytes / 1024 / 1024 / 1024 from dba_data_files where tablespace_name like 'UNDOTBS%';


 


5. 查看回滾段的使用情況,哪個用戶正在使用回滾段的資源,如果有用戶最好更換時間(特別是生產環境)。


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狀態;


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


8 0 0.00017547607421875 3.11521148681641 700


3 0 0.00023651123046875 3.22954559326172 632


0 0 0.00035858154296875 0.00035858154296875 0


1 0 0.00206756591796875 3.04867553710938 920


10 0 0.00206756591796875 0.648170471191406 819


7 0 0.00231170654296875 3.94835662841797 730


4 0 0.00304412841796875 2.00011444091797 651


11 0 0.00695037841796875 2.26921844482422 740


9 0 0.00792694091796875 2.07530975341797 773


6 0 0.00792694091796875 1.31906890869141 775


2 0 0.00890350341796875 3.13677215576172 699


5 0 1.96833801269531 3.99906921386719 267


 


這還原表空間中還存在12個回滾的對象。


 


7. 創建新的UNDO表空間,並設置自動擴展參數;


create undo tablespace undotbs2 datafile '/u02/pnrdb/undotbs2_01.dbf' size 100m reuse autoextend on next 100m maxsize unlimited;


 


8. 切換UNDO表空間爲新的UNDO表空間 , 動態更改spfile配置文件;


 


alter system set undo_tablespace=undotbs2 scope=both;  


 


9.驗證當前數據庫的 UNDO表空間


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 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


_SYSSMU1$ UNDOTBS1 1 OFFLINE


_SYSSMU2$ UNDOTBS1 2 OFFLINE


_SYSSMU3$ UNDOTBS1 3 OFFLINE


_SYSSMU4$ UNDOTBS1 4 OFFLINE


_SYSSMU5$ UNDOTBS1 5 OFFLINE


_SYSSMU6$ UNDOTBS1 6 OFFLINE


_SYSSMU7$ UNDOTBS1 7 OFFLINE


_SYSSMU8$ UNDOTBS1 8 OFFLINE


_SYSSMU9$ UNDOTBS1 9 OFFLINE


_SYSSMU10$ UNDOTBS1 10 OFFLINE


_SYSSMU11$ UNDOTBS1 11 OFFLINE


_SYSSMU12$ UNDOTBS1 12 OFFLINE


_SYSSMU13$ UNDOTBS1 13 OFFLINE


_SYSSMU14$ UNDOTBS1 14 OFFLINE


_SYSSMU15$ UNDOTBS1 15 OFFLINE


_SYSSMU16$ UNDOTBS1 16 OFFLINE


_SYSSMU17$ UNDOTBS1 17 OFFLINE


_SYSSMU18$ UNDOTBS1 18 OFFLINE


_SYSSMU19$ UNDOTBS1 19 OFFLINE


_SYSSMU20$ UNDOTBS1 20 OFFLINE


_SYSSMU21$ UNDOTBS1 21 OFFLINE


_SYSSMU22$ UNDOTBS1 22 OFFLINE


_SYSSMU23$ UNDOTBS1 23 OFFLINE


_SYSSMU24$ UNDOTBS1 24 OFFLINE


_SYSSMU25$ UNDOTBS1 25 OFFLINE


_SYSSMU26$ UNDOTBS1 26 OFFLINE


_SYSSMU27$ UNDOTBS1 27 OFFLINE


_SYSSMU28$ UNDOTBS1 28 OFFLINE


_SYSSMU29$ UNDOTBS1 29 OFFLINE


_SYSSMU30$ UNDOTBS1 30 OFFLINE


_SYSSMU31$ UNDOTBS1 31 OFFLINE


_SYSSMU32$ UNDOTBS1 32 OFFLINE


_SYSSMU33$ UNDOTBS1 33 OFFLINE


_SYSSMU34$ UNDOTBS1 34 OFFLINE


_SYSSMU35$ UNDOTBS1 35 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表空間;


 


drop tablespace undotbs1 including contents and datafiles;


 


12. os級別釋放undo數據文件;


 


到root下執行


lsof |grep /u02/pnrdb/undotbs01.dbf


 


lsof |grep /u02/pnrdb/undotbs01.dbf |awk '{printf"kill -9 "$2"\n"}'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章