查看和修改AWR配置
作者:互联网
有时遇到系统遇到复杂问题,处理周期长,需要保留系统的快照周期,便于分析问题,这时,需要延长延长快照时间周期(默认一般是一周时间)。
一、查看当前AWR配置
10g版本中默认是保留7天,11g版本中默认保留8天,采集间隔是1小时,这个信息可以从DBA_HIST_WR_CONTROL视图中获得。
SQL> select * from dba_hist_wr_control;
DBID SNAP_INTERVAL RETENTION TOPNSQL CON_ID
---------- -------------------- -------------------- -------------------- ----------
2541626938 +00000 01:00:00.0 +00008 00:00:00.0 DEFAULT 0
参数说明:
snap_interval: 快照间隔,单位是分钟
retention: 快照保留周期,单位是分钟
SNAP_INTERVAL=+00000 01:00:00.0 表示采样间隔是1小时
RETENTION=+00008 00:00:00.0 表示采样数据保留期限是8天
二、调整AWR配置
可使用使用DBMS_WORKLOAD_REPOSITORY包中的MODIFY_SNAPSHOT_SETTINGS存储过程修改AWR配置。
DBMS_WORKLOAD_REPOSITORY包结构如附录【1】。
1、调整AWR产生 snapshot 的频率和保留策略
例:将采样间隔改为30 分钟,保留30天时间(注:单位都是为分钟):
SQL> exec dbms_workload_repository.modify_snapshot_settings(interval=>30, retention=>30*24*60);
PL/SQL procedure successfully completed.
验证修改结果:
SQL> select * from dba_hist_wr_control;
DBID SNAP_INTERVAL RETENTION TOPNSQL CON_ID
---------- -------------------- -------------------- -------------------- ----------
2541626938 +00000 00:30:00.0 +00030 00:00:00.0 DEFAULT 0
已将采样间隔改为30 分钟,保留时间修改为30天。
2、关闭AWR
把interval设为0则关闭自动捕捉快照
三、AWR相关内容补充
1、手工创建一个快照
SQL> exec DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();
2、查看快照
SQL> select * from sys.wrh$_active_session_history
3、手工删除指定范围的快照
SQL> exec WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE(low_snap_id => 11, high_snap_id => 26, dbid => 3561526973);
4、创建baseline
SQL> exec dbms_workload_repository.create_baseline (56,59,'apply_interest_1')
5、删除baseline
SQL> exec DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE(baseline_name => ' apply_interest_1', cascade => FALSE);
6、生产AWR报告
SQL> @?/rdbms/admin/awrrpt.sql
AWR收集统计信息的特性受statistics_level影响,该参数有3个可选值。
BASIC:AWR统计信息收集和所有自我调整特性都被关闭
TYPICAL:数据库收集部分统计信息,这些信息为典型的数据库监控需要,默认设置
ALL:所有可能统计信息被收集
附录:
【1】
SQL> desc DBMS_WORKLOAD_REPOSITORY
PROCEDURE ADD_COLORED_SQL
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
SQL_ID VARCHAR2 IN
DBID NUMBER IN DEFAULT
FUNCTION ASH_GLOBAL_REPORT_HTML RETURNS AWRRPT_HTML_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM VARCHAR2 IN
L_BTIME DATE IN
L_ETIME DATE IN
L_OPTIONS NUMBER IN DEFAULT
L_SLOT_WIDTH NUMBER IN DEFAULT
L_SID NUMBER IN DEFAULT
L_SQL_ID VARCHAR2 IN DEFAULT
L_WAIT_CLASS VARCHAR2 IN DEFAULT
L_SERVICE_HASH NUMBER IN DEFAULT
L_MODULE VARCHAR2 IN DEFAULT
L_ACTION VARCHAR2 IN DEFAULT
L_CLIENT_ID VARCHAR2 IN DEFAULT
L_PLSQL_ENTRY VARCHAR2 IN DEFAULT
L_DATA_SRC NUMBER IN DEFAULT
L_CONTAINER VARCHAR2 IN DEFAULT
FUNCTION ASH_GLOBAL_REPORT_TEXT RETURNS AWRDRPT_TEXT_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM VARCHAR2 IN
L_BTIME DATE IN
L_ETIME DATE IN
L_OPTIONS NUMBER IN DEFAULT
L_SLOT_WIDTH NUMBER IN DEFAULT
L_SID NUMBER IN DEFAULT
L_SQL_ID VARCHAR2 IN DEFAULT
L_WAIT_CLASS VARCHAR2 IN DEFAULT
L_SERVICE_HASH NUMBER IN DEFAULT
L_MODULE VARCHAR2 IN DEFAULT
L_ACTION VARCHAR2 IN DEFAULT
L_CLIENT_ID VARCHAR2 IN DEFAULT
L_PLSQL_ENTRY VARCHAR2 IN DEFAULT
L_DATA_SRC NUMBER IN DEFAULT
L_CONTAINER VARCHAR2 IN DEFAULT
FUNCTION ASH_REPORT_ANALYTICS RETURNS CLOB
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
DBID NUMBER IN DEFAULT
INST_ID NUMBER IN DEFAULT
BEGIN_TIME DATE IN
END_TIME DATE IN
REPORT_LEVEL VARCHAR2 IN DEFAULT
FILTER_LIST VARCHAR2 IN DEFAULT
FUNCTION ASH_REPORT_HTML RETURNS AWRRPT_HTML_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM NUMBER IN
L_BTIME DATE IN
L_ETIME DATE IN
L_OPTIONS NUMBER IN DEFAULT
L_SLOT_WIDTH NUMBER IN DEFAULT
L_SID NUMBER IN DEFAULT
L_SQL_ID VARCHAR2 IN DEFAULT
L_WAIT_CLASS VARCHAR2 IN DEFAULT
L_SERVICE_HASH NUMBER IN DEFAULT
L_MODULE VARCHAR2 IN DEFAULT
L_ACTION VARCHAR2 IN DEFAULT
L_CLIENT_ID VARCHAR2 IN DEFAULT
L_PLSQL_ENTRY VARCHAR2 IN DEFAULT
L_DATA_SRC NUMBER IN DEFAULT
L_CONTAINER VARCHAR2 IN DEFAULT
FUNCTION ASH_REPORT_TEXT RETURNS AWRRPT_TEXT_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM NUMBER IN
L_BTIME DATE IN
L_ETIME DATE IN
L_OPTIONS NUMBER IN DEFAULT
L_SLOT_WIDTH NUMBER IN DEFAULT
L_SID NUMBER IN DEFAULT
L_SQL_ID VARCHAR2 IN DEFAULT
L_WAIT_CLASS VARCHAR2 IN DEFAULT
L_SERVICE_HASH NUMBER IN DEFAULT
L_MODULE VARCHAR2 IN DEFAULT
L_ACTION VARCHAR2 IN DEFAULT
L_CLIENT_ID VARCHAR2 IN DEFAULT
L_PLSQL_ENTRY VARCHAR2 IN DEFAULT
L_DATA_SRC NUMBER IN DEFAULT
L_CONTAINER VARCHAR2 IN DEFAULT
FUNCTION AWR_DIFF_REPORT_HTML RETURNS AWRRPT_HTML_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
DBID1 NUMBER IN
INST_NUM1 NUMBER IN
BID1 NUMBER IN
EID1 NUMBER IN
DBID2 NUMBER IN
INST_NUM2 NUMBER IN
BID2 NUMBER IN
EID2 NUMBER IN
FUNCTION AWR_DIFF_REPORT_TEXT RETURNS AWRDRPT_TEXT_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
DBID1 NUMBER IN
INST_NUM1 NUMBER IN
BID1 NUMBER IN
EID1 NUMBER IN
DBID2 NUMBER IN
INST_NUM2 NUMBER IN
BID2 NUMBER IN
EID2 NUMBER IN
FUNCTION AWR_GLOBAL_DIFF_REPORT_HTML RETURNS AWRRPT_HTML_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
DBID1 NUMBER IN
INST_NUM1 AWRRPT_INSTANCE_LIST_TYPE IN
BID1 NUMBER IN
EID1 NUMBER IN
DBID2 NUMBER IN
INST_NUM2 AWRRPT_INSTANCE_LIST_TYPE IN
BID2 NUMBER IN
EID2 NUMBER IN
FUNCTION AWR_GLOBAL_DIFF_REPORT_HTML RETURNS AWRRPT_HTML_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
DBID1 NUMBER IN
INST_NUM1 VARCHAR2 IN
BID1 NUMBER IN
EID1 NUMBER IN
DBID2 NUMBER IN
INST_NUM2 VARCHAR2 IN
BID2 NUMBER IN
EID2 NUMBER IN
FUNCTION AWR_GLOBAL_DIFF_REPORT_TEXT RETURNS AWRDRPT_TEXT_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
DBID1 NUMBER IN
INST_NUM1 AWRRPT_INSTANCE_LIST_TYPE IN
BID1 NUMBER IN
EID1 NUMBER IN
DBID2 NUMBER IN
INST_NUM2 AWRRPT_INSTANCE_LIST_TYPE IN
BID2 NUMBER IN
EID2 NUMBER IN
FUNCTION AWR_GLOBAL_DIFF_REPORT_TEXT RETURNS AWRDRPT_TEXT_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
DBID1 NUMBER IN
INST_NUM1 VARCHAR2 IN
BID1 NUMBER IN
EID1 NUMBER IN
DBID2 NUMBER IN
INST_NUM2 VARCHAR2 IN
BID2 NUMBER IN
EID2 NUMBER IN
FUNCTION AWR_GLOBAL_REPORT_HTML RETURNS AWRRPT_HTML_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM AWRRPT_INSTANCE_LIST_TYPE IN
L_BID NUMBER IN
L_EID NUMBER IN
L_OPTIONS NUMBER IN DEFAULT
FUNCTION AWR_GLOBAL_REPORT_HTML RETURNS AWRRPT_HTML_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM VARCHAR2 IN
L_BID NUMBER IN
L_EID NUMBER IN
L_OPTIONS NUMBER IN DEFAULT
FUNCTION AWR_GLOBAL_REPORT_TEXT RETURNS AWRDRPT_TEXT_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM AWRRPT_INSTANCE_LIST_TYPE IN
L_BID NUMBER IN
L_EID NUMBER IN
L_OPTIONS NUMBER IN DEFAULT
FUNCTION AWR_GLOBAL_REPORT_TEXT RETURNS AWRDRPT_TEXT_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM VARCHAR2 IN
L_BID NUMBER IN
L_EID NUMBER IN
L_OPTIONS NUMBER IN DEFAULT
FUNCTION AWR_REPORT_HTML RETURNS AWRRPT_HTML_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM NUMBER IN
L_BID NUMBER IN
L_EID NUMBER IN
L_OPTIONS NUMBER IN DEFAULT
FUNCTION AWR_REPORT_TEXT RETURNS AWRRPT_TEXT_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM NUMBER IN
L_BID NUMBER IN
L_EID NUMBER IN
L_OPTIONS NUMBER IN DEFAULT
PROCEDURE AWR_SET_REPORT_THRESHOLDS
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
TOP_N_EVENTS NUMBER IN DEFAULT
TOP_N_FILES NUMBER IN DEFAULT
TOP_N_SEGMENTS NUMBER IN DEFAULT
TOP_N_SERVICES NUMBER IN DEFAULT
TOP_N_SQL NUMBER IN DEFAULT
TOP_N_SQL_MAX NUMBER IN DEFAULT
TOP_SQL_PCT NUMBER IN DEFAULT
SHMEM_THRESHOLD NUMBER IN DEFAULT
VERSIONS_THRESHOLD NUMBER IN DEFAULT
TOP_N_DISKS NUMBER IN DEFAULT
OUTLIER_PCT NUMBER IN DEFAULT
OUTLIER_CPU_PCT NUMBER IN DEFAULT
FUNCTION AWR_SQL_REPORT_HTML RETURNS AWRRPT_HTML_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM NUMBER IN
L_BID NUMBER IN
L_EID NUMBER IN
L_SQLID VARCHAR2 IN
L_OPTIONS NUMBER IN DEFAULT
FUNCTION AWR_SQL_REPORT_TEXT RETURNS AWRSQRPT_TEXT_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_DBID NUMBER IN
L_INST_NUM NUMBER IN
L_BID NUMBER IN
L_EID NUMBER IN
L_SQLID VARCHAR2 IN
L_OPTIONS NUMBER IN DEFAULT
PROCEDURE CONTROL_RESTRICTED_SNAPSHOT
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
ALLOW BOOLEAN IN
PROCEDURE CREATE_BASELINE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
START_SNAP_ID NUMBER IN
END_SNAP_ID NUMBER IN
BASELINE_NAME VARCHAR2 IN
DBID NUMBER IN DEFAULT
EXPIRATION NUMBER IN DEFAULT
FUNCTION CREATE_BASELINE RETURNS NUMBER
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
START_SNAP_ID NUMBER IN
END_SNAP_ID NUMBER IN
BASELINE_NAME VARCHAR2 IN
DBID NUMBER IN DEFAULT
EXPIRATION NUMBER IN DEFAULT
PROCEDURE CREATE_BASELINE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
START_TIME DATE IN
END_TIME DATE IN
BASELINE_NAME VARCHAR2 IN
DBID NUMBER IN DEFAULT
EXPIRATION NUMBER IN DEFAULT
FUNCTION CREATE_BASELINE RETURNS NUMBER
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
START_TIME DATE IN
END_TIME DATE IN
BASELINE_NAME VARCHAR2 IN
DBID NUMBER IN DEFAULT
EXPIRATION NUMBER IN DEFAULT
PROCEDURE CREATE_BASELINE_TEMPLATE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
START_TIME DATE IN
END_TIME DATE IN
BASELINE_NAME VARCHAR2 IN
TEMPLATE_NAME VARCHAR2 IN
EXPIRATION NUMBER IN DEFAULT
DBID NUMBER IN DEFAULT
PROCEDURE CREATE_BASELINE_TEMPLATE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
DAY_OF_WEEK VARCHAR2 IN
HOUR_IN_DAY NUMBER IN
DURATION NUMBER IN
START_TIME DATE IN
END_TIME DATE IN
BASELINE_NAME_PREFIX VARCHAR2 IN
TEMPLATE_NAME VARCHAR2 IN
EXPIRATION NUMBER IN DEFAULT
DBID NUMBER IN DEFAULT
PROCEDURE CREATE_SNAPSHOT
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
FLUSH_LEVEL VARCHAR2 IN DEFAULT
DBID NUMBER IN DEFAULT
SOURCE_NAME VARCHAR2 IN DEFAULT
FUNCTION CREATE_SNAPSHOT RETURNS NUMBER
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
FLUSH_LEVEL VARCHAR2 IN DEFAULT
DBID NUMBER IN DEFAULT
SOURCE_NAME VARCHAR2 IN DEFAULT
PROCEDURE DROP_BASELINE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
BASELINE_NAME VARCHAR2 IN
CASCADE BOOLEAN IN DEFAULT
DBID NUMBER IN DEFAULT
PROCEDURE DROP_BASELINE_TEMPLATE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
TEMPLATE_NAME VARCHAR2 IN
DBID NUMBER IN DEFAULT
PROCEDURE DROP_SNAPSHOT_RANGE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
LOW_SNAP_ID NUMBER IN
HIGH_SNAP_ID NUMBER IN
DBID NUMBER IN DEFAULT
PROCEDURE MODIFY_BASELINE_WINDOW_SIZE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
WINDOW_SIZE NUMBER IN
DBID NUMBER IN DEFAULT
PROCEDURE MODIFY_SNAPSHOT_SETTINGS
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
RETENTION NUMBER IN DEFAULT
INTERVAL NUMBER IN DEFAULT
TOPNSQL NUMBER IN DEFAULT
DBID NUMBER IN DEFAULT
PROCEDURE MODIFY_SNAPSHOT_SETTINGS
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
RETENTION NUMBER IN DEFAULT
INTERVAL NUMBER IN DEFAULT
TOPNSQL VARCHAR2 IN
DBID NUMBER IN DEFAULT
PROCEDURE PURGE_SQL_DETAILS
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
NUMROWS NUMBER IN DEFAULT
DBID NUMBER IN DEFAULT
PROCEDURE REMOVE_COLORED_SQL
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
SQL_ID VARCHAR2 IN
DBID NUMBER IN DEFAULT
PROCEDURE RENAME_BASELINE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
OLD_BASELINE_NAME VARCHAR2 IN
NEW_BASELINE_NAME VARCHAR2 IN
DBID NUMBER IN DEFAULT
FUNCTION SELECT_BASELINE_DETAILS RETURNS AWRBL_DETAILS_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_BASELINE_ID NUMBER IN
L_BEG_SNAP NUMBER IN DEFAULT
L_END_SNAP NUMBER IN DEFAULT
L_DBID NUMBER IN DEFAULT
FUNCTION SELECT_BASELINE_METRIC RETURNS AWRBL_METRIC_TYPE_TABLE
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
L_BASELINE_NAME VARCHAR2 IN
L_DBID NUMBER IN DEFAULT
L_INSTANCE_NUM NUMBER IN DEFAULT
PROCEDURE UPDATE_DATAFILE_INFO
PROCEDURE UPDATE_OBJECT_INFO
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
MAXROWS NUMBER IN DEFAULT
标签:--------,查看,DEFAULT,------------------------------,AWR,NUMBER,修改,VARCHAR2,------ 来源: https://blog.csdn.net/Ruishine/article/details/118892368