AWR不自動刪除導致SYSAUX表空間滿

goodlatch發表於2016-12-29
不知何時何原因,一個資料庫的AWR不自動刪除了,然後慢慢的SYSAUX表空間滿了,alert日誌也開始報警

其主要是WRH$_ACTIVE_SESSION_HISTORY 的一個分割槽表佔了很多,沒遇到過的問題,總是感覺很緊張,尤其又是生產庫

於是乎,想了個笨方法開始手動刪WRH$_ACTIVE_SESSION_HISTORY的資料,刪的差不多了就開始收縮表,收縮完表空間有地了

可是過段時間又滿了,心想這笨方法可不行,開始找方法

在官方發現文件 387914.1就是說的這個問題

CAUSE

Oracle decides what rows need to be purged based on the retention policy. There is a special mechanism which is used in the case of the large AWR tables where we store the snapshot data in partitions. One method of purging data from these tables is by removing partitions that only contain rows that have exceeded the retention criteria. During the nightly purge task, we only drop the partition if all the data in the partition has expired. If the partition contains at least one row which, according to the retention policy shouldn't be removed,  then  the partition won't be dropped and as such the table will contain old data.

If partition splits do not occur (for whatever reason), then we can end up with a situation where we have to wait for the latest entries to expire before the partition that they sit in can be removed. This can mean that some of the older entries can be retained significantly past their expiry date. The result of this is that the data is not purged as expected.


SOLUTION

A potential solution to this issue is to manually split the partitions of the partitioned AWR objects such that there is more chance of the split partition being purged.You will still have to wait for all the rows in the new partitions to reach their retention time but with split partitions there is more chance of this happening. you can manually split the partitions using the following undocumented command:

alter session set "_swrf_test_action" = 72;

To perform a single split of all the AWR partitions.

  1.  Check the partition details for the offending table before the split:   
     SELECT owner,
      segment_name,
      partition_name,
      segment_type,
      bytes/1024/1024/1024 Size_GB
    FROM dba_segments
    WHERE segment_name='WRH$_ACTIVE_SESSION_HISTORY';
  2. Split the partitions so that there is more chance of the smaller partition being purged:
    alter session set "_swrf_test_action" = 72;
    NOTE: This command will split partitions for ALL partitioned AWR objects. It also initiates a single split; it does not need to be disabled and will need to be repeated if multiple splits are required.
      
  3.  Check the partition details for the offending table after the split:      
    SELECT owner,
      segment_name,
      partition_name,
      segment_type,
      bytes/1024/1024/1024 Size_GB
    FROM dba_segments
    WHERE segment_name='WRH$_ACTIVE_SESSION_HISTORY';

其方法就是執行alter session set "_swrf_test_action" = 72; 讓AWR相關的分割槽表都建立一個新的分割槽,等待老分割槽的資料過期,oracle就會自動刪除。

可眼下表空間已經滿了,等不到老分割槽的資料過期,可咋辦

那麼可以先修改AWR的有效保留期,比如改成5天。等5天后oracle刪掉分割槽在把保留期改回來。如果老資料需要保留可以匯出AWR的資訊。

但是也有個問題,這次的資料已經刪了,那麼以後oracle會自動刪嗎?不會每次都要手動執行一下這個命了吧?希望有經驗的朋友告訴下,或者讓時間證明

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29339009/viewspace-2131604/,如需轉載,請註明出處,否則將追究法律責任。

相關文章