中午接到电话,值班人员告诉我一台服务器的oracle数据文件的文件系统使用率达到94%,剩余空间约3G。经查,原因为oracle tempfile开启了文件自扩展特性,该文件今天从12G增长至18G。其实一般情况下,都不建议用户开启oracle tempfile的自扩展特性,该数据库由于当时在实施时没有dba的介入,所以上生产后才会出现这种现象。
考虑到剩余文件系统空间较少,故决定回缩temp表空间,同时关闭tempfile文件自扩展特性。
具体执行步骤如下:
SQL>create temporary tablespace temp2 tempfile '/oradata/rccadb/temp02.dbf' size 500M autoextend off;
SQL>alter database default temporary tablespace temp2;
SQL>drop tablespace temp;
cd /oradata/rccadb/
rm temp01.dbf
SQL>create temporary tablespace temp tempfile '/oradata/rccadb/temp01.dbf ' size 5G autoextend off;
SQL>select file_name,autoexentsible from dba_temp_files;
确认文件自扩展特性已经关闭
SQL>alter database default temporary tablespace temp;
SQL>drop tablespace temp2;
cd /oradata/rccadb/
rm temp02.dbf
其中,在执行删除temp表空间步骤时,无法删除该表空间,等待事件’enq: TS – contention’。经查,应用用户正在执行存储过程call p_transform()。怀疑就是因为该存储过程导致了tempfile持续增长的。
当时oracle的文件系统剩余空间约700M,故决定杀掉该会话。
通过v$session查出对应会话的process,sid,serial#
$ps –ef|grep
$kill -9
SQL>select sid,serial#,event from v$session where sid=;
SQL>alter system kill session ‘sid,serial#’;
Kill session后drop tablespace temp步骤正常完成。
另,查询默认temp表空间的语句如下:
select * from database_properties where property_name like '%TEMP%';
关闭单个tempfile自扩展特性的语句如下:
ALTER DATABASE TEMPFILE '/oradata/rccadb/temp01.dbf' AUTOEXTEND OFF;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20750200/viewspace-695419/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/20750200/viewspace-695419/