新聞中心
Oracle臨時(shí)表空間主要是用來做查詢和存放一些緩存的數(shù)據(jù)的,磁盤消耗的一個(gè)主要原因是需要對(duì)查詢的結(jié)果進(jìn)行排序,那么如何解決臨時(shí)表空間過大?本篇文章重點(diǎn)為大家講解一下Oracle臨時(shí)表空間過大解決方案。

創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),四方臺(tái)企業(yè)網(wǎng)站建設(shè),四方臺(tái)品牌網(wǎng)站建設(shè),網(wǎng)站定制,四方臺(tái)網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,四方臺(tái)網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
方案一:增加臨時(shí)表空間的大小
–1.臨時(shí)表空間的使用情況題
SELECT D.tablespace_name,
SPACE "SUM_SPACE(M)",
blocks "SUM_BLOCKS",
used_space "USED_SPACE(M)",
Round(Nvl(used_space, 0) / SPACE * 100, 2) "USED_RATE(%)",
SPACE - used_space "FREE_SPACE(M)"
FROM (SELECT tablespace_name,
Round(SUM(bytes) / (1024 * 1024), 2) SPACE,
SUM(blocks) BLOCKS
FROM dba_temp_files
GROUP BY tablespace_name) D,
(SELECT tablespace,
Round(SUM(blocks * 8192) / (1024 * 1024), 2) USED_SPACE
FROM v$sort_usage
GROUP BY tablespace) F
WHERE D.tablespace_name = F.tablespace(+)
AND D.tablespace_name like 'TEMP%';
–查看臨時(shí)表空間的總大小和最大擴(kuò)展大小(能看到數(shù)據(jù)文件)
select file_name,
tablespace_name,
bytes / 1024 / 1024 MB,
autoextensible,
maxbytes / 1024 / 1024 MAX_MB
from dba_temp_files;
–增加臨時(shí)表空間的大小
alter tablespace temp1 add tempfile '/data/prod/proddata/temp013.dbf' size 4G;
alter tablespace temp2 add tempfile '/data/prod/proddata/temp024.dbf' size 4G;
方案二:重建臨時(shí)表空間,解決臨時(shí)表空間過大的問題。
–0.查看目前默認(rèn)的臨時(shí)表空間
select *
from database_properties
where property_name = 'DEFAULT_TEMP_TABLESPACE';
–1.創(chuàng)建中轉(zhuǎn)臨時(shí)表空間
create temporary tablespace temp3 tempfile '/data/prod/proddata/temp31.dbf' size 4G tablespace group temp;
create temporary tablespace temp4 tempfile '/data/prod/proddata/temp41.dbf' size 4G tablespace group temp;
–2.刪除原臨時(shí)表空間組中的臨時(shí)表空間
–2.1從默認(rèn)臨時(shí)表空間組temp中移除temp1和temp2;
ALTER TABLESPACE temp1 TABLESPACE GROUP '';
ALTER TABLESPACE temp2 TABLESPACE GROUP '';
–2.2刪除臨時(shí)表空間temp1和temp2
drop tablespace temp1 including contents and datafiles;
drop tablespace temp2 including contents and datafiles;
–2.3如果刪除表空間的時(shí)候,hang住的話,可以使用下列語(yǔ)句,先把運(yùn)行在temp臨時(shí)表空間的sql語(yǔ)句kill掉,這樣的sql語(yǔ)句多為排序的語(yǔ)句
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;
–2.4 kill相關(guān)進(jìn)程
alter system kill session '584,23181';
alter system kill session '196,64972';
alter system kill session '262,19832';
alter system kill session '324,40273';
alter system kill session '326,38967';
alter system kill session '1266,54596';
or –重啟DB –關(guān)閉應(yīng)用–>關(guān)閉監(jiān)聽–>shutdown immediate –startup–>啟動(dòng)監(jiān)聽–>執(zhí)行以下操作后打開應(yīng)用
–2.5 創(chuàng)建臨時(shí)表空間,并加入臨時(shí)表空間組temp
create temporary tablespace temp1 tempfile '/data/prod/proddata/temp11.dbf' size 4G tablespace group temp;
create temporary tablespace temp2 tempfile '/data/prod/proddata/temp21.dbf' size 4G tablespace group temp;
–2.6 給臨時(shí)表空間組temp的成員temp1,temp2,temp3,temp4 各增加一個(gè)成員。
alter tablespace temp1 add tempfile '/data/prod/proddata/temp12.dbf' size 4G;
alter tablespace temp2 add tempfile '/data/prod/proddata/temp22.dbf' size 4G;
alter tablespace temp3 add tempfile '/data/prod/proddata/temp32.dbf' size 4G;
alter tablespace temp4 add tempfile '/data/prod/proddata/temp42.dbf' size 4G;
–2.7查看臨時(shí)表空間組temp
select * from dba_tablespace_groups;
–3 臨時(shí)表空間組仍然使用99.98%,
–3.1為每個(gè)臨時(shí)表空間添加4G空間
alter tablespace temp1 add tempfile '/data/prod/proddata/temp13.dbf' size 4G;
alter tablespace temp2 add tempfile '/data/prod/proddata/temp23.dbf' size 4G;
alter tablespace temp3 add tempfile '/data/prod/proddata/temp33.dbf' size 4G;
alter tablespace temp4 add tempfile '/data/prod/proddata/temp43.dbf' size 4G;
分享文章:Oracle臨時(shí)表空間過大解決方案
轉(zhuǎn)載注明:http://www.dlmjj.cn/article/dhhoghp.html


咨詢
建站咨詢
