SYSAUX資料表空間使用率高問題處理,sysaux資料表空間

來源:互聯網
上載者:User

SYSAUX資料表空間使用率高問題處理,sysaux資料表空間

SYSAUX資料表空間做為SYSTEM資料表空間的輔助資料表空間,主要存放EM相關的內容以及表統計資訊,AWR快照,審計資訊等,而如果SYSAUX資料表空間在預設條件下你如果不做任何配置,隨著時間的推移,會膨脹的越來越大。

經過幾次的不斷擴充增加SYSAUX資料表空間,目前已經20G了,所以現是考慮減肥的時候了。

 

1. 查看錶空間使用

SQL>

Select Tablespace_Name,

                             Sum_m,

                             Max_m,

                             Count_Blocks Free_Blk_Cnt,

                             Sum_Free_m,

                             To_Char(100 * Sum_Free_m / Sum_m, '99.9999')|| '%' As Pct_Free,

       100 - To_Char(100 * Sum_Free_m / Sum_m,'99.9999') || '%' As Pct_used   

         From (Select Tablespace_Name, Sum(Bytes) / 1024 / 1024 AsSum_m

                                               From Dba_Data_Files

                                      Group By Tablespace_Name)

         Left Join

 (Select Tablespace_Name As Fs_Ts_Name,

                                      Max(Bytes) / 1024 / 1024 As Max_m,

                                      Count(Blocks) As Count_Blocks,

                                      Sum(Bytes / 1024 / 1024) As Sum_Free_m

                   From Dba_Free_Space

          Group ByTablespace_Name)

On Tablespace_Name = Fs_Ts_Name

ORDER BY Sum_Free_m / Sum_m ;

 

TABLESPACE_NAME                     SUM_M      MAX_M FREE_BLK_CNT SUM_FREE_MPCT_FREE  PCT_USED

---------------------------------------- ---------- ------------ ---------- --------- ------------

SYSAUX                              21652       1031           13     1032.5  4.7686% 95.2314%

NTICKET_DB                         235520       7798         4922      46894 19.9108% 80.0892%

NTICKET_INDEX                      112640       2418          764      25382 22.5337% 77.4663%

SYSTEM                               2798       1884            7  1916.125  68.4820% 31.518%

USERS                                   5     3.6875            1     3.6875 73.7500% 26.25%

PORTALMAIL                            200    168.125            2        170 85.0000% 15%

UNDOTBS2                            10265       3596          200 9936.8125  96.8028% 3.1972%

UNDOTBS3                            10265       3593          248       9983 97.2528% 2.7472%

UNDOTBS1                            24455       3968          184 24280.625  99.2870% .713%

STRATEGY                            20480       3968            6      20478 99.9902% .0098%

 

 

2. 查看SYSAUX資料表空間內各個分類項目占儲存空間的比重,可以看到AWR快照佔用了近20G左右的空間,統計資訊為300M左右,同時資料庫關閉了審計audit_trail,所以審計表aud$不佔空間

 

SQL> col Item For a30

SQL> col "Space Used(GB)" For a10

SQL> col Schema For a20

SQL> col "MoveProcedure" For a200

SQL>

SQL> SELECT occupant_name"Item",

           round(space_usage_kbytes/1024/1024,3)"Space Used (GB)",

           schema_name "Schema",

           move_procedure "MoveProcedure"

      FROM v$sysaux_occupants

    ORDER BY 2 Desc;

 

Item                           Space UsedSchema               Move Procedure

---------------------------------------- -------------------- ---------------------------------------

SM/AWR                             19.103 SYS                 

SM/OPTSTAT                          0.311 SYS                 

SM/ADVISOR                          0.248 SYS                 

XDB                                 0.124 XDB                 XDB.DBMS_XDB.MOVEXDB_TABLESPACE

SDO                                 0.073MDSYS                MDSYS.MOVE_SDO

EM                                  0.045SYSMAN              emd_maintenance.move_em_tblspc

XSOQHIST                            0.037 SYS                  DBMS_XSOQ.OlapiMoveProc

AO                                  0.037SYS                  DBMS_AW.MOVE_AWMETA

ORDIM/ORDDATA                       0.013 ORDDATA             ordsys.ord_admin.move_ordim_tblspc

LOGMNR                              0.013 SYSTEM               SYS.DBMS_LOGMNR_D.SET_TABLESPACE

AUDIT_TABLES                            0 SYS                  DBMS_AUDIT_MGMT.move_dbaudit_tables

 

 

3. 修改統計資訊的保持時間,預設為31天,這裡修改為7天,到期的統計資訊會自動被刪除

SQL> selectdbms_stats.get_stats_history_retention from dual;

 

GET_STATS_HISTORY_RETENTION

---------------------------

                         31

 

SQL> exec dbms_stats.alter_stats_history_retention(15);

 

PL/SQL procedure successfullycompleted

 

SQL> selectdbms_stats.get_stats_history_retention from dual;

 

GET_STATS_HISTORY_RETENTION

---------------------------

                         15

                        

4. 修改AWR快照的儲存時間為7天(7*24*60),每小時收集一次,也可以通過EM介面查看和修改

 

--檢查當前系統的保留時間為8天,1小時採樣一次

SQL> select * fromdba_hist_wr_control;

 

      DBID SNAP_INTERVAL                           RETENTION                               TOPNSQL

------------------------------------------------- -------------------------------------------------

1494575446 +0000001:00:00.0                       +0000800:00:00.0                       DEFAULT

 

 

--

SQL>

begin

         dbms_workload_repository.modify_snapshot_settings(

            interval => 60,

            retention => 10080,--分鐘

            topnsql => 100

          );

end;

 

ORA-13541: 系統移動視窗基準大小 (691200)大於保留時間 (604800)

ORA-06512: 在"SYS.DBMS_WORKLOAD_REPOSITORY", line 174

ORA-06512: 在"SYS.DBMS_WORKLOAD_REPOSITORY", line 222

ORA-06512: 在 line 2

這裡 691200(8*24*60*60),604800(7*24*60*60)都是以秒為單位的。

 

發現執行報錯,因為當前系統移動視窗大於現在所設的時間視窗。

 

--查看系統的當前的MOVING_WINDOW_SIZE,

SQL> selectdbid,baseline_name,baseline_type,moving_window_size from dba_hist_baseline;

 

      DBID BASELINE_NAME                             BASELINE_TYPEMOVING_WINDOW_SIZE

--------------------------------------------------- ------------- ------------------

1494575446SYSTEM_MOVING_WINDOW                     MOVING_WINDOW                  8

 

--修改其大小為7,即7天。

SQL> execdbms_workload_repository.modify_baseline_window_size(7);

 

PL/SQL procedure successfullycompleted

 

 

--再次執行修改AWR快照的儲存時間

SQL> execDBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(interval=>60,retention=> 7*24*60 );

 

PL/SQL procedure successfullycompleted

 

註:當然也可通過EM進行修改AWR設定

 

 

5.刪除AWR快照,再次查看SYSAUX資料表空間使用率。

 

--查詢最最小和最大快照ID

SQL> selectmin(snap_id),max(snap_id) from dba_hist_snapshot;

 

MIN(SNAP_ID) MAX(SNAP_ID)

------------ ------------

        8188         8397

       

--刪除最早的24個AWR快照,也就是最早的24小時的快照。

SQL> execdbms_workload_repository.drop_snapshot_range(low_snap_id =>8188,high_snap_id => 8188+24);

 

 

最後,再次查看錶空間發現使用率已經減小。

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

相關文章

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.