Linux系統Oracle Temp01.dbf不斷變大應該這樣解決

來源:互聯網
上載者:User

標籤:oracle   暫存資料表空間   temp01.dbf   系統   越來越大   

Oracle安裝在centos系統上,系統磁碟空間本身不是很大,運行一段時間後發現Oracle的暫存資料表空間佔用磁碟越來越大,以至於系統處於崩潰的邊緣,解決該問題的方法如下:


第一步:
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;
第三步:
select d.file_name, d.file_id, d.tablespace_name, d.bytes
from dba_temp_files d;
第四步:
alter database tempfile ‘/opt/oracle/oradata/orcl/temp01.dbf‘ autoextend off;
(只是為瞭解決小問題,不深究。)
 
正常來說,在完成Select語句、create index等一些使用TEMP資料表空間的排序操作後,Oracle是會自動釋放掉臨時段a的。但有些有侯我們則會遇到臨時段沒有被釋放,TEMP資料表空間幾乎滿的狀況,甚至是我們重啟了資料庫仍沒有解決問題


在檢查centos系統的磁碟空間時,發現暫存資料表空間所在臨時資料檔案已經達到35G,已經佔用了100%。

因為是正式資料庫伺服器,不能隨便重啟資料庫。

以下的操作是用資料庫的sys超級使用者操作

剛開始打算把暫存資料表空間的資料檔案重新縮小就好了

執行:

SQL> alter database tempfile ‘/opt/oracle/oradata/orcl/temp01.dbf‘ resize 10240M;

資料庫報錯,重新設定的空間大小不能滿足需要。

看來需要重建立立新的暫存資料表空間替換當前的資料表空間了

1、首先查看當前的資料庫預設資料表空間:

SQL>select * from database_properties where property_name=‘DEFAULT_TEMP_TABLESPACE‘;

確認當前的暫存資料表空間為TEMP

2、查看目前暫存資料表空間的大小:

SQL>select file_name,tablespace_name,bytes/1024/1024 "MB",autoextensible from dba_temp_files;

3、建立新的暫存資料表空間:

SQL> create temporary tablespace temp02 tempfile ‘/opt/oracle/oradata/orcl/temp02.dbf‘ size 512M;

4、把建立的暫存資料表空間卻換成資料庫的預設暫存資料表空間

SQL> alter database default temporary tablespace temp02;

5、確認目前資料庫的預設暫存資料表空間

SQL>select * from database_properties where property_name=‘DEFAULT_TEMP_TABLESPACE‘;

確認temp02為當前的資料庫預設資料表空間

6、在刪除temp暫存資料表空間之前,先把運行在temp暫存資料表空間的sql語句kill掉,這樣的sql語句多為排序的語句

SQL>Select se.username,se.sid,se.serial#,su.extents,su.blocks*to_number(rtrim(p.value))as Space,

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

order by se.username,se.sid;

查詢出來之後,kill掉這些sql語句:

SQL>alter system kill session ‘524,778‘; (假如某一條啟動並執行sql語句的SID為524,serial#為778)

確認在temp暫存資料表空間中沒有啟動並執行sql語句之後,則可以刪除temp暫存資料表空間資料檔案了

7、刪除temp暫存資料表空間

SQL> drop tablespace temp including contents and datafiles;

這樣很快就可以刪除了暫存資料表空間的資料檔案

8、現在temp02暫存資料表空間佔據了別人的磁碟空間,需要重新把暫存資料表空間建立在原來的位置,重建立立temp暫存資料表空間

SQL> create temporary tablespace temp tempfile ‘/opt/oracle/oradata/orcl/temp01.dbf‘ size 512M autoextend on maxsize 15G;


建立一個512M的自動擴充暫存資料表空間,最大的擴充為15G。

查看建立的temp暫存資料表空間是否正確:

SQL>select file_name,tablespace_name,bytes/1024/1024,maxbytes/1024/1024,autoextensible from dba_temp_files;


9、把建立的temp暫存資料表空間卻換成資料庫的預設暫存資料表空間

SQL> alter database default temporary tablespace temp;

10、確認目前資料庫的預設暫存資料表空間

SQL>select * from database_properties

where property_name=‘DEFAULT_TEMP_TABLESPACE‘;

確認temp為當前的資料庫預設資料表空間

11、目前把原來的temp暫存資料表空間變成了512M,把剩餘的磁碟空間空了出來,temp02暫存資料表空間就沒有用了,刪除temp02暫存資料表空間
SQL> drop tablespace temp02 including contents and datafiles;


Linux系統Oracle Temp01.dbf不斷變大應該這樣解決

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.