Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

Linux 上 Oracle temp01.dbf 持續膨脹的處理方法

Oracle 安裝在磁碟空間有限的 CentOS 上時,臨時表空間可能隨運行時間增加而持續變大,甚至拖垮系統。以下提供一套以重建臨時表空間為核心的處理流程。

一、快速處理思路

可先嘗試刪除舊臨時檔案、重建臨時表空間,並限制自動擴展:

alter database tempfile '/opt/oracle/oradata/orcl/temp01.dbf' drop;
alter tablespace temp add tempfile '/opt/oracle/oradata/orcl/temp01.dbf' size 2048M reuse autoextend on next 100M;
alter database tempfile '/opt/oracle/oradata/orcl/temp01.dbf' autoextend off;

二、確認目前臨時表空間

select * from database_properties where property_name='DEFAULT_TEMP_TABLESPACE';
select file_name,tablespace_name,bytes/1024/1024 "MB",autoextensible from dba_temp_files;

三、建立新的臨時表空間

create temporary tablespace temp02 tempfile '/opt/oracle/oradata/orcl/temp02.dbf' size 512M;
alter database default temporary tablespace temp02;

四、移除舊臨時表空間前,先處理仍在使用的 SQL

可先查詢使用 temp 的排序型 SQL:

Select se.username,se.sid,se.serial#,su.extents,su.blocks,tablespace,segtype,sql_text
from v$sort_usage su,v$parameter p,v$session se,v$sql s
where p.name='db_block_size'
and su.session_addr=se.saddr
and s.hash_value=su.sqlhash
and s.address=su.sqladdr;

確認後,可針對特定 session 執行:

alter system kill session 'SID,SERIAL#';

五、刪除舊表空間並重建

drop tablespace temp including contents and datafiles;
create temporary tablespace temp tempfile '/opt/oracle/oradata/orcl/temp01.dbf' size 512M autoextend on maxsize 15G;
alter database default temporary tablespace temp;
drop tablespace temp02 including contents and datafiles;

這樣可把臨時表空間重新放回原本位置,並設定合理的最大擴展上限,避免再次占滿磁碟。

Copyright © Linux教程網 All Rights Reserved