如果在日常工作中遇见了AWR数据量太大,可以通过如下方式做以清除:
SQL> select distinct dbid,db_name,instance_name from wrm$_database_instance;
DBID DB_NAME INSTANCE_NAME
---------- --------- ----------------
2691876695 MYDB mydb
运行如下脚本,清除AWR数据:
SQL> @?rdbmsadmincatnoawr.sql
(略)
不重启的话,清空共享池
alter system flush shared_docker中文入门学习手册
iis7站长之家;
运行重建AWR脚本:
SQL> @?rdbmsadmincatawrtb.sql
(略)
会话已更改
SQL> @?rdbmsadminutlrp.sql
(略)
Oracle 11g需要需要运行如下脚本:
SQL> @?rdbmsadminexecsvrm.sql
SQL> exec dbms_workload_repository.create_snapshot;
PL/SQL 过程已成功完成。
SQL> exec dbms_workload_repository.create_snapshot;
BEGIN dbms_workload_repository.create_snapshot; END;
*
第 1 行出现错误:
ORA-13516: AWR 操作失败: AWR Schema not initialized
ora-06512: 在 "sys.dbms_workload_repository", line 99
ORA-06512: 在 "SYS.DBMS_WORKLOAD_REPOSITORY", line 122
ORA-06512: 在 line 1
在重新编译了存储过程后,存储过程运行正常
隔5分钟后,再次运行:
SQL> exec dbms_workload_repository.create_snapshot;
PL/SQL 过程已成功完成。
SQL> @?/rdbms/admin/awrrpt.sql
注意在RAC环境下的话,需要取消集群参数后,待执行完成后再次修改过来:
alter system set cluster_database = false scope = spfile;
当然在重建后我们需要进一步检查下相关对象是否存在异常,对于存在异常的对象需要重新编译:
pool objects.lst
set pagesize500
set linesize 100
select substr(comp_name,1,40) comp_name, status, substr(version,1,10) version
from dba_registry
order by comp_name;
select substr(object_name,1,40) object_name,substr(owner,1,15) owner,object_type
from dba_objects
where status='INVALID' order by owner,object_type;
select owner,object_type,count(*)
from dba_objects
where status='INVALID'
group by owner,object_type order by owner,object_type ;
spool off
alter package . compile;
alter package . compile body;
alter view . compile;
alter trigger