禁用awr需要下载: dbmsnoawr.plb 文件。注意这里的禁用我们指的是完全停用。当然通过设置STATISTICS_LEVEL也可以从一定程度上实现类似的目的。如果将参数STATISTICS_LEVEL设置为BASIC,下列重要的统计信息将不会被收集。 Automatic Workload Repository (AWR) Snapshots
Automatic Database Diagnostic Monitor (ADDM)
All server-generated alerts
Automatic SGA Memory Management
Automatic optimizer statistics collection
Object level statistics
End to End Application Tracing (V$CLIENT_STATS)
Database time distribution statistics (V$SESS_TIME_MODEL and V$SYS_TIME_MODEL)
Service level statistics
Buffer cache advisory
MTTR advisory
Shared pool sizing advisory
Segment level statistics
PGA Target advisory
Timed statistics
Monitoring of statistics
演示禁用AWR
oracle@USDB:~> export ORACLE_SID=HKBO5
oracle@USDB:~> sqlplus / as sysdba
sys@HKBO5> select * from v$version where rownum<2;
BANNER
----------------------------------------------------------------
Oracle Database 10g Release 10.2.0.3.0 - 64bit Production
--查看禁用前awr的使用频率
sys@HKBO5> SELECTname,
2 detected_usages detected,
3 total_samples samples,
4 currently_used used,
5 to_char(last_sample_date,'MMDDYYYY:HH24:MI') last_sample,
6 sample_interval interval
7 FROM dba_feature_usage_statistics
8 WHEREname = 'Automatic Workload Repository';
NAME DETECTED SAMPLES USED LAST_SAMPLE INTERVAL
---------------------------------------------------------------- ---------- ---------- ----- -------------- ----------
Automatic Workload Repository 0 207 FALSE 09112014:00:12 604800
oracle@USDB:~> ll *awr*
-rw-r--r-- 1 oracle oinstall 2369 2014-08-21 17:26 dbmsnoawr.plb
--执行dbmsnoawr.plb,其实质是添加了一个名为dbms_awr的pkg到当前数据库
sys@HKBO5> @dbmsnoawr.plb
Package created.
Package body created.
sys@HKBO5> exec dbms_awr.disable_awr();
PL/SQL procedure successfully completed.
sys@HKBO5> desc dbms_awr
FUNCTION AWR_ENABLED RETURNS BOOLEAN
FUNCTION AWR_STATUS RETURNS VARCHAR2
PROCEDURE DISABLE_AWR
PROCEDURE ENABLE_AWR
--查看disable后awr的状态,返回值为disable
sys@HKBO5> select dbms_awr.awr_status from dual;
AWR_STATUS
-------------------------------------------------------------
DISABLED
--查询awr的数据字典,发现SNAP_INTERVAL变成了0值
sys@HKBO5> select * from dba_hist_wr_control;
DBID SNAP_INTERVAL RETENTION TOPNSQL
---------- ---------------------------------------- ---------------------------------------- ----------
733951103 +40150 00:00:00.0 +00007 00:00:00.0 DEFAULT
--再次enable awr
sys@HKBO5> exec dbms_awr.enable_awr();
PL/SQL procedure successfully completed.
--此时SNAP_INTERVAL采样恢复到了缺省值,也就是说过程DISABLE_AWR修改了SNAP_INTERVAL设置
sys@HKBO5> select * from dba_hist_wr_control;
DBID SNAP_INTERVAL RETENTION TOPNSQL
---------- ---------------------------------------- ---------------------------------------- ----------
733951103 +00000 01:00:00.0 +00007 00:00:00.0 DEFAULT
卸载awr
卸载awr通用用于awr相关功能或特性异常的时候。通过先卸载在安装来达到使awr特性正常化。下面给出步骤。
卸载awr脚本:$ORACLE_HOME/rdbms/admin/catnoawr.sql
安装awr脚本:$ORACLE_HOME/rdbms/admin/catawr.sql
sqlplus /nolog
connect / as sysdba
show parameters statistics_level
alter system set statistics_level=basic scope=spfile;
shutdown immediate
startup restrict
$ORACLE_HOME/rdbms/admin/catnoawr
shutdown immediate
startup
--转自