System表空間不足的報警問題淺析
廢話不多說了,具體代碼如下所示:
--SYSTEM表空間不足的報警 登錄之后,查詢,發(fā)現(xiàn)是sys.aud$占的地方太多。 SQL> select owner, segment_name, segment_type, sum(bytes)/1024/1024 space_m from dba_segments where tablespace_name = 'SYSTEM' group by owner, segment_name, segment_type having sum(bytes)/1024/1024 >= 20 order by space_m desc ; 4 5 6 7 OWNER SEGMENT_NAME SEGMENT_TYPE SPACE_M -------- ------------------------------- ------- SYS AUD$ TABLE 4480 SYS IDL_UB1$ TABLE 272 SYS SOURCE$ TABLE 72 SYS IDL_UB2$ TABLE 32 SYS C_OBJ#_INTCOL# CLUSTER 27 SYS C_TOID_VERSION# CLUSTER 24 6 rows selected. SQL> 查看是哪個記得比較多。 col userhost format a30 select userid, userhost, count(1) from sys.aud$ where ntimestamp# >=CAST(to_date('2014-03-01 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) group by userid, userhost having count(1) > 500 order by count(1) desc ; 再繼續(xù)找哪天比較多。 select to_char(ntimestamp#, 'YYYY-MM-DD') audit_date, count(1) from sys.aud$ where ntimestamp# >=CAST(to_date('2014-03-01 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) and userid = 'xxxx' and userhost = 'xxxx' group by to_char(ntimestamp#, 'YYYY-MM-DD') order by count(1) desc ; select spare1, count(1) from sys.aud$ where ntimestamp# between CAST(to_date('2014-03-10 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) and CAST(to_date('2014-03-11 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) and userid = 'xxxx' and userhost = 'xxxx' group by spare1 ; select action#, count(1) from sys.aud$ where ntimestamp# between CAST(to_date('2014-03-10 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) and CAST(to_date('2014-03-11 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) and userid = 'xxxx' and userhost = 'xxxx' and spare1 = 'xxxx' group by action# order by count(1) desc ; 結(jié)果如下: ACTION# COUNT(1) ---------- ---------- 101 124043 100 124043 SQL> 其實是上次打開的audit一直沒有關(guān)閉。 關(guān)閉: SQL> noaudit session; 清空: truncate table sys.aud$; ------------------------------------------------------------------------ 實戰(zhàn) ------------------------------------------------------------------------ --1,查詢表空間占用情況 select dbf.tablespace_name as tablespace_name, dbf.totalspace as totalspace, dbf.totalblocks as totalblocks, dfs.freespace freespace, dfs.freeblocks freeblocks, (dfs.freespace / dbf.totalspace) * 100 as freeRate from (select t.tablespace_name, sum(t.bytes) / 1024 / 1024 totalspace, sum(t.blocks) totalblocks from DBA_DATA_FILES t group by t.tablespace_name) dbf, (select tt.tablespace_name, sum(tt.bytes) / 1024 / 1024 freespace, sum(tt.blocks) freeblocks from DBA_FREE_SPACE tt group by tt.tablespace_name) dfs where trim(dbf.tablespace_name) = trim(dfs.tablespace_name) --2,查看哪里占的比較多 SYSTEM 為step1中查詢 tablespace_name 內(nèi)容 select owner, segment_name, segment_type, sum(bytes)/1024/1024 space_m from dba_segments where tablespace_name = 'SYSTEM' group by owner, segment_name, segment_type having sum(bytes)/1024/1024 >= 20 order by space_m desc --3,查看是哪個記得比較多 count(1) 越大,說明占得比較多 select userid, userhost, count(1) from sys.aud$ where ntimestamp# >=CAST(to_date('2014-03-01 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) group by userid, userhost having count(1) > 500 order by count(1) desc --4,再繼續(xù)找哪天比較多 userid userhost 為上一步查詢內(nèi)容 select to_char(ntimestamp#, 'YYYY-MM-DD') audit_date, count(1) from sys.aud$ where ntimestamp# >=CAST(to_date('2015-03-01 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) and userid = 'userid' and userhost = 'userhost' group by to_char(ntimestamp#, 'YYYY-MM-DD') order by count(1) desc ; select spare1, count(1) from sys.aud$ where ntimestamp# between CAST(to_date('2016-03-10 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) and CAST(to_date('2016-12-11 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) and userid = 'userid' and userhost = 'userhost' group by spare1 ; --spare1 為上一步查詢內(nèi)容 select action#, count(1) from sys.aud$ where ntimestamp# between CAST(to_date('2016-03-10 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) and CAST(to_date('2016-12-11 00:00:00', 'YYYY-MM-DD hh24:mi:ss') AS TIMESTAMP) and userid = 'userid' and userhost = 'userhost' and spare1 = 'Administrator' group by action# order by count(1) desc --5,關(guān)閉seeion noaudit session; --6,清空: truncate table sys.aud$;
總結(jié)
以上所述是小編給大家介紹的System表空間不足的報警,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對我們網(wǎng)站的支持!
您可能感興趣的文章
- 01-10SQLServer數(shù)據(jù)庫中開啟CDC導(dǎo)致事務(wù)日志空間被占滿的原因
- 01-10SQL Server獲取磁盤空間使用情況
- 01-10Sql Server臨時表和游標(biāo)的使用小結(jié)
- 01-10SQL Server 公用表表達式(CTE)實現(xiàn)遞歸的方法
- 01-10SQL Server中修改“用戶自定義表類型”問題的分析與方法
- 01-10sqlserver 樹形結(jié)構(gòu)查詢單表實例代碼
- 01-10SqlServer給表增加多個字段的語法
- 01-10SqlServer使用公用表表達式(CTE)實現(xiàn)無限級樹形構(gòu)建
- 01-10SQL Server在AlwaysOn中使用內(nèi)存表的“踩坑”記錄
- 01-10SQL update 多表關(guān)聯(lián)更新的實現(xiàn)代碼


閱讀排行
本欄相關(guān)
- 01-10SQLServer存儲過程實現(xiàn)單條件分頁
- 01-10SQLServer中防止并發(fā)插入重復(fù)數(shù)據(jù)的方
- 01-10SQL Server 2012降級至2008R2的方法
- 01-10SQL Server性能調(diào)優(yōu)之緩存
- 01-10SQL Server數(shù)據(jù)庫定時自動備份
- 01-10Sql Server 死鎖的監(jiān)控分析解決思路
- 01-10實現(xiàn)SQL Server 原生數(shù)據(jù)從XML生成JSON數(shù)
- 01-10SqlServer快速檢索某個字段在哪些存儲
- 01-10SqlServer 在事務(wù)中獲得自增ID的實例代
- 01-10SQLServer性能優(yōu)化--間接實現(xiàn)函數(shù)索引或
隨機閱讀
- 01-10使用C語言求解撲克牌的順子及n個骰子
- 01-11ajax實現(xiàn)頁面的局部加載
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 01-10delphi制作wav文件的方法
- 01-10C#中split用法實例總結(jié)
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 08-05織夢dedecms什么時候用欄目交叉功能?
- 04-02jquery與jsp,用jquery