【转】Undo Tablespace 切换注意事项

转来的,原贴地址: http://blog.csdn.net/lwei_998/article/details/6537066#



oracle中经常遇到undo表空间不释放,如果设置了unod表空间自动扩展AUTOEXTEND ON则还有可能把磁盘撑爆。当undo被撑满了,经常会选择重建undo表空间,进行切换。虽然切换undo比较容易,但如果要在生产切换undo还是考虑的周到一些比较好。

 

注意事项:

1.       检查系统使用的参数文件是pfile还是spfile

    如果用pfile记得修改pfile中的undo_tablespace参数。否则容易导致下次重启数据库时找不到历史的undo表空间而启动失败。

select  name , value from v$parameter  where name='spfile';

 

2.     切换undo时检查是否还有事务存在。如果有事务,在删除旧undo时可能会遇到ORA-30013的错误。

select  count(*) from  v$transaction;

 

3.     检查undo对应的数据文件是否被真正删除。

摘自:How to Shrink the datafile of Undo Tablespace [ID 268870.1]

NOTE: Dropping the old tablespace may give ORA-30013 : undo tablespace '%s' is currently in use. This error indicates you must wait for the undo tablespace to become unavailable. In other words, you must wait for existing transaction to commit or rollback.    Also be aware that on some platforms, disk space is not freed to the OS until the database is restarted.  The disk space will remain "allocated" from the OS perspective until the database restart.

 

4.     虽然可以在线切换undo,但切换后如果能重启一下最好。以免留下后患。或者选择在可以重启的时候去切换undo。

 

 

 切换undo的步骤:

一、检查undo设置

SQL> show parameter undo

 

二、查看undo表空间的大小

SELECT D.TABLESPACE_NAME,D.FILE_NAME, SUM(D.BYTES) / 1024 / 1024 MB
  FROM DBA_DATA_FILES D
 WHERE D.TABLESPACE_NAME LIKE 'UNDO%'
 GROUP BY D.TABLESPACE_NAME,D.FILE_NAME;

 

三、检查参数文件类型

select  name , value from v$parameter  where name='spfile';

 

四、创建undo表空间

SQL> create undo tablespace UNDOTBS2 datafile 'D:/ORACLE/PRODUCT/10.2.0/ORADATA/ORCL2/UNDOTBS02.DBF' size 500M;

 

五、等待原undo表空间UNDO SEGMENT OFFLINE后可以切换undo

SQL> SELECT USN,

  2           XACTS,

  3           STATUS,

  4           RSSIZE / 1024 / 1024 / 1024 RSSIZE,

  5           HWMSIZE / 1024 / 1024 / 1024 HWMSIZE,

  6           SHRINKS

  7      FROM V$ROLLSTAT

  8     ORDER BY RSSIZE;

 

六、切换UNDO表空间

SQL>alter system set undo_tablespace=undotbs2 scope=both;

 

七、删除UNDO表空间及数据文件

SQL>drop tablespace UNDOTBS1 including contents and datafiles;

 

Metalink中记录了一种切换undo比较稳妥的方法,可以参考一下:

How to Change the Existing Undo Tablespace to a New Undo Tablespace [ID 431652.1]

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值