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"}'

你可能感兴趣的:(oracle)