[Fault] Troubleshooting the problem that the SYSAUX table space usage is too high


SYSAUX table space usage is too high to deal with the problem

 

  • The table space of Oracle database is mainly divided into two categories, one is database system table space, such as SYSTEM, SYSAUX, TEMP, UNDO , and the other is user-defined table space, which is mainly suitable for data processing of various businesses. The SYSTEM tablespace is mainly used to store the data dictionary and metadata information of the database, and the capacity of the tablespace varies with the size of the database objects; the SYSAUX tablespace was born in 10G , as the auxiliary space of the SYSTEM tablespace, and is designed for To store the statistical information of database objects and historical performance data such as database snapshots, its space capacity continues to expand over time . We need to set management strategies and set the retention time of historical data according to oracle 's corresponding management methods.
  • The capacity of the UNDO and TEMP tablespaces is related to the activity of the database. The more active the database is and the larger the transaction processing scale, the larger the corresponding space capacity will be. We need to set the capacity of the TEMP and UNDO tablespaces according to the scale of database transactions generated by the business .
  • We use the following SQL statement to query the database system tablespace usage information:
SELECT * FROM (
    SELECT D.TABLESPACE_NAME,
            SPACE || 'M' "SUM_SPACE(M)",
            BLOCKS "SUM_BLOCKS",
            SPACE - NVL (FREE_SPACE, 0) || 'M' "USED_SPACE(M)",
            ROUND ( (1 - NVL (FREE_SPACE, 0) / SPACE) * 100, 2) || '%'
               "USED_RATE(%)",
            FREE_SPACE || 'M' "FREE_SPACE(M)"
       FROM (  SELECT TABLESPACE_NAME,
                      ROUND (SUM (BYTES) / (1024 * 1024), 2) SPACE,
                      SUM (BLOCKS) BLOCKS
                 FROM DBA_DATA_FILES
             GROUP BY TABLESPACE_NAME) D,
            (  SELECT TABLESPACE_NAME,
                      ROUND (SUM (BYTES) / (1024 * 1024), 2) FREE_SPACE
                 FROM DBA_FREE_SPACE
             GROUP BY TABLESPACE_NAME) F
      WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
     UNION ALL                                                           
     SELECT D.TABLESPACE_NAME,
            SPACE || 'M' "SUM_SPACE(M)",
            BLOCKS SUM_BLOCKS,
            USED_SPACE || 'M' "USED_SPACE(M)",
            ROUND (NVL (USED_SPACE, 0) / SPACE * 100, 2) || '%' "USED_RATE(%)",
            NVL (FREE_SPACE, 0) || 'M' "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_NAME,
                      ROUND (SUM (BYTES_USED) / (1024 * 1024), 2) USED_SPACE,
                      ROUND (SUM (BYTES_FREE) / (1024 * 1024), 2) FREE_SPACE
                 FROM V$TEMP_SPACE_HEADER
             GROUP BY TABLESPACE_NAME) F
      WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
     ORDER BY 1)  
     WHERE TABLESPACE_NAME IN ('SYSAUX','SYSTEM','UNDOTBS1','TEMP');
TABLESPACE_NAME  SUM_SPACE(M) SUM_BLOCKS USED_SPACE(M) USED_RATE(%)  FREE_SPACE(M)
---------------  -----------   ---------  ------------   -----------   ------------
SYSAUX             840M           107520      792.31M         94.32%         47.69M
SYSTEM             810M           103680      809.56M         99.95%         .44M                       
TEMP               47M             6016        47M              100%           0M
UNDOTBS1           405M           51840       404M             99.75%        1M
  • We use the following statement to query the proportion of storage space of each category item in the SYSAUX tablespace:
SELECT occupant_name "Item",
           space_usage_kbytes / 1048576 "Space Used (GB)",
           schema_name "Schema",
           move_procedure "Move Procedure"
  FROM v$sysaux_occupants
 ORDER BY 1

  • Modify the retention time of statistical information, the default is 31 days, here is modified to 7 days, the expired statistical information will be automatically deleted :

(1) Query the retention time of database statistics

 

SQL> select dbms_stats.get_stats_history_retention from dual; 
GET_STATS_HISTORY_RETENTION 
--------------------------- 
                         31 

        (2) The retention time for changing database statistics is 7 days

SQL> exec dbms_stats.alter_stats_history_retention(7);       
    PL/SQL procedure successfully completed. 

(3) Query the retention time of database statistics again

SQL> select dbms_stats.get_stats_history_retention from dual; 

GET_STATS_HISTORY_RETENTION 
--------------------------- 
       7
  • Modify the storage time of AWR snapshots to 7 days (7*24*60), which is collected every hour, and can also be viewed and modified through the EM interface

 (1) Query the MIN(SNAP_ID) and MAX(SNAP_ID) of the database snapshot

 

SQL> select min(snap_id),max(snap_id) from dba_hist_snapshot;
MIN(SNAP_ID) MAX(SNAP_ID)
------------ ------------
         701          716

 (2) If the error ORA-13541 and ORA-06512 occurs when modifying the retention time of the database snapshot, the processing method is as follows

ERROR
begin
*
Error at line 1:
ORA-13541: system moving window baseline size (691200) greater than retention time (604800)
ORA-06512: at "SYS.DBMS_WORKLOAD_REPOSITORY", line 39
ORA-06512: at "SYS.DBMS_WORKLOAD_REPOSITORY", line 87
ORA-06512: on line 2
  • The error message for querying ORA-13541 is as follows:

ORA-13541: system moving window baseline size (string) greater than retention (string)
Cause: The system moving window baseline size must be less than the retention setting.
            The specified window size or retention violate this.
Action:Check the moving window baseline size or retention.
  • Take a look at the numbers above for baseline size ( 691200 ) and retention time ( 604800 )

  • Baseline size 691200

SQL> select 691200/60/60/24 from dual;

691200/60/60/24
---------------
              8
Note: 8 days
  • Retention time 604800

SQL> select 604800/60/24/60 from dual;

604800/60/24/60
---------------
              7
  • Check the current moving window baseline size

SQL> SELECT dbid, baseline_name, baseline_type, moving_window_size from dba_hist_baseline;

      DBID BASELINE_NAME            BASELINE_TYPE MOVING_WINDOW_SIZE
---------- ------------------------ ------------- ------------------
4096851118 SYSTEM_MOVING_WINDOW     MOVING_WINDOW                  8
  • It matches the number corresponding to the 8 days above (8*60*60*24=691200).

  • Call the following procedure to modify the mobile window baseline size to 7 days

SQL> exec dbms_workload_repository.modify_baseline_window_size(7);
PL/SQL procedure completed successfully.
  • Then continue with the above modification

SQL> begin
           dbms_workload_repository.modify_snapshot_settings (
             interval => 30,
             retention => 7*24*60,
             topnsql => 100
           );
     end;
     /
PL/SQL procedure completed successfully.
SQL> select * from dba_hist_wr_control;

      DBID SNAP_INTERVAL         RETENTION             TOPNSQL
---------- --------------------- --------------------- ----------
4096851118 +00000 00:30:00.0     +00007 00:00:00.0            100
SQL> SELECT dbid, baseline_name, baseline_type, moving_window_size from dba_hist_baseline;

      DBID BASELINE_NAME           BASELINE_TYPE MOVING_WINDOW_SIZE
---------- ----------------------- ------------- ------------------
4096851118 SYSTEM_MOVING_WINDOW    MOVING_WINDOW                  7
  •  Modify the retention time of snapshots in Enterprise Manager

 


 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326930049&siteId=291194637