数据库
首页 > 数据库> > oracle设置awr采集间隔和保留时间

oracle设置awr采集间隔和保留时间

作者:互联网

环境:

OS:Centos 6

DB:11.2.0.4

1.查看当前awr采集时间间隔和保留时间
SQL> col SNAP_INTERVAL for a20
SQL> col RETENTION for a20
SQL> select * from dba_hist_wr_control;

DBID SNAP_INTERVAL RETENTION TOPNSQL
------------------------------ -------------------- -------------------- ------------------------------
2510643529 +00000 01:00:00.0 +00008 00:00:00.0 DEFAULT
可以看到当前的采集间隔是1小时,保留时间是7天

2.修改采集间隔和保留时间
修改采集间隔为1小时,保留时间是3天
SQL> BEGIN
2 DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(
3 interval => 60,
4 retention => 3*24*60);
5 END;
6 /
BEGIN
*
ERROR at line 1:
ORA-13541: system moving window baseline size (604800) greater than retention (259200)
ORA-06512: at "SYS.DBMS_WORKLOAD_REPOSITORY", line 174
ORA-06512: at "SYS.DBMS_WORKLOAD_REPOSITORY", line 222
ORA-06512: at line 2


报错解决办法,修改基数值
SQL> SELECT dbid, baseline_name, baseline_type, moving_window_size from dba_hist_baseline;

DBID BASELINE_NAME BASELINE_TYPE MOVING_WINDOW_SIZE
------------------------------ ---------------------
2510643529 SYSTEM_MOVING_WINDOW MOVING_WINDOW 8

当前的基数值为8,这里我们修改成7(基数值必须小于或等于AWR快照所设置的保留值)

修改基数值:
SQL> exec DBMS_WORKLOAD_REPOSITORY.MODIFY_BASELINE_WINDOW_SIZE(7)

 

再次执行:
SQL> BEGIN
2 DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(
3 interval => 60,
4 retention => 3*24*60);
5 END;
6 /

PL/SQL procedure successfully completed.


3.查看修改结果
SQL> select * from dba_hist_wr_control;

DBID SNAP_INTERVAL RETENTION TOPNSQL
------------------------------ -------------------- -------------------- ------------------------------
2510643529 +00000 01:00:00.0 +00003 00:00:00.0 DEFAULT

标签:00,WORKLOAD,REPOSITORY,DBMS,------------------------------,间隔,awr,SQL,oracle
来源: https://www.cnblogs.com/hxlasky/p/15204507.html