oracle的SYSAUX表空间满了怎么处理

清理SYSAUX表空间:

  1. 创建临时表,保存近8天的数据
create table test.ash_bak_20220119 as select * from sys.WRH$_ACTIVE_SESSION_HISTORY where SAMPLE_TIME>=sysdate-9;
SQL> select count(*)  from test.ash_bak_20220119;
  COUNT(*)
----------
     12648

1 row selected.
  1. 禁用AWR
exec dbms_workload_repository.modify_snapshot_settings(interval => 0);
  1. truncate WRH$_ACTIVE_SESSION_HISTORY
TRUNCATE TABLE sys.WRH$_ACTIVE_SESSION_HISTORY;
  1. truncate 完成后,重建 WRH$_ACTIVE_SESSION_HISTORY表的索引,并从备份表恢复数据
insert into sys.WRH$_ACTIVE_SESSION_HISTORY select * from test.ash_bak_20220119;
commit;
  1. 查看索引状态(USABLE是未失效,UNUSABLE是失效)
set line 300 pages 200
col owner for a20
col index_name for a30
select index_owner,
index_name,
partition_name,
status,
tablespace_name,
last_analyzed
from dba_ind_partitions
where index_name in (select index_name
from dba_indexes
where table_name in ('WRH$_ACTIVE_SESSION_HISTORY')
and table_owner = 'SYS');

INDEX_OWNER		       INDEX_NAME		      PARTITION_NAME		     STATUS   TABLESPACE_NAME		     LAST_ANAL
------------------------------ ------------------------------ ------------------------------ -------- ------------------------------ ---------
SYS			       WRH$_ACTIVE_SESSION_HISTORY_PK WRH$_ACTIVE_3552434506_0	     USABLE   SYSAUX			     04-DEC-21
SYS			       WRH$_ACTIVE_SESSION_HISTORY_PK WRH$_ACTIVE_SES_MXDB_MXSN      USABLE   SYSAUX			     07-FEB-20
  1. 如果索引失效重建索引(测试的时候是没有失效的,索引为本地索引)
ALTER INDEX SYS.WRH$_ACTIVE_SESSION_HISTORY_PK REBUILD PARTITION WRH$_ACTIVE_3552434506_0 tablespace SYSAUX;
ALTER INDEX SYS.WRH$_ACTIVE_SESSION_HISTORY_PK REBUILD PARTITION WRH$_ACTIVE_SES_MXDB_MXSN tablespace SYSAUX;
  1. 启动AWR
exec dbms_workload_repository.modify_snapshot_settings(interval => 60);
  1. 测试awr和ash可能正常生成
    —手动生成snapshot
exec dbms_workload_repository.create_snapshot;
@?/rdbms/admin/awrrpt
@?/rdbms/admin/ashrpt
  1. 删除备份表
drop table test.ash_bak_20220119 purge;

你可能感兴趣的:(oracle日常运维,oracle,数据库,dba,数据库开发,sql)