您好,欢迎访问一九零五行业门户网

通过案例学调优之--AWR BaseLine管理

通过案例学调优之--awrbaseline管理baselinebaseline是指一个特定时间段内的性能数据,保留这些数据是为了在性能问题产生时与其他类似的工作负载时间段进行比较
通过案例学调优之--awr baseline管理
baseline
     baseline 是指一个特定时间段内的性能数据,保留这些数据是为了在性能问题产生时与其他类似的工作负载时间段进行比较。baseline 中包含的快照将从自动 awr 清理进程中排除,并无限期的保留。
在 oracle database 中存在多种类型的 baseline:
     fixed baseline:fixed baseline 表示的是您指定的一个固定的、连续的时间段。在创建 fixed baseline 之前,请认真考虑您选作 baseline 的时间段,因为该 baseline 应该代表系统处于良好的性能下运行。您可以在将来将该 baseline 与在性能较差的时间段捕获的其他 baseline 或 snapshot 进行比较分析。 
     moving window baseline:表示的是 awr 保留期内存在的所有 awr 数据。在使用自适应阈值时,它非常有用,因为数据库可以使用整个 awr 保留期内的 awr 数据来计算指标值。
     oracle database 会自动维护系统定义的 moving window baseline。系统定义的 moving window baseline 的默认窗口大小就是当前的 awr 保留期,即默认为 8 天。如果您打算使用自适应阈值,请考虑使用更长的移动窗口——如30天,以便精确地计算阈值。您可以重新调整 moving window baseline,将移动窗口的大小调整为小于或等于 awr 的保留天数。因此,要增加移动窗口的大小,必须要先增加相应的 awr 保留期限。
     baseline template:您可以使用 baseline template 创建将来某个连续时间段的 baseline。oracle 中有两种 baseline 模板:single 和 repeating
     利用 single baseline template,您可以为将来某个单独的连续时间段创建 baseline。该技术在某些情况下非常有用。例如,如果您想捕获下周计划的系统测试期间的 awr 数据,您可以创建一个 single baseline template 来自动捕获测试发生的时间段的统计数据。
     利用 repeating baseline template ,可以根据重复的时间计划创建和删除 baseline。当您希望 oracle database 自动持续地捕获连续时间段的统计数据时,这非常有用。例如,您可能需要在长达一个月内捕获每周一早上的 awr 数据。在这种情况下,您可以创建一个 repeating baseline template ,以在每周一自动创建 baseline,在指定的过期期限内自动删除过时的 baseline。
案例:
1、创建基线
fixed baseline:fixed baseline 表示的是您指定的一个固定的、连续的时间段。
根据snap_id创建:dbms_workload_repository.create_baseline(   start_snap_id    in  number,   end_snap_id      in  number,   baseline_name    in  varchar2,   dbid             in  number default null,   expiration       in  number default null);根据时间创建: dbms_workload_repository.create_baseline(   start_time       in  date,   end_time         in  date,   baseline_name    in  varchar2,   dbid             in  number default null,   expiration       in  number default null);   查看snapshot:14:25:31 sys@ test1 >select snap_id,begin_interval_time,dbid from dba_hist_snapshot;   snap_id begin_interval_time                                                               dbid---------- --------------------------------------------------------------------------- ----------       435 04-nov-14 11.00.52.880 am                                                   1195893416       436 04-nov-14 12.00.07.338 pm                                                   1195893416       437 04-nov-14 01.00.22.331 pm                                                   1195893416       432 04-nov-14 12.00.04.575 am                                                   1195893416       434 04-nov-14 09.52.45.512 am                                                   1195893416       428 31-oct-14 02.58.47.186 pm                                                   1195893416       429 31-oct-14 04.00.51.633 pm                                                   1195893416       430 03-nov-14 10.19.24.000 am                                                   1195893416       433 04-nov-14 09.41.40.000 am                                                   1195893416       426 31-oct-14 11.25.58.000 am                                                   1195893416       427 31-oct-14 02.47.40.000 pm                                                   1195893416       431 03-nov-14 10.30.31.348 am                                                   119589341612 rows selected.创建baseline:14:27:46 sys@ test1 >exec dbms_workload_repository.create_baseline(start_snap_id=>435,end_snap_id=>436,baseline_name=>'work_bs1',dbid=>1195893416,expiration=>30);pl/sql procedure successfully completed.--435 是起始的 snapshot 序列号,436 是结束 snapshot 序列号。expiration => 30 表示该 baseline 将在30天后自动删除,expiration =>null表示,永不过期--创建 baseline 时,系统会自动分配一个唯一的 baseline id 给新建的 baseline。可以通过 dba_hist_baseline 视图查看。查看baseline:14:31:10 sys@ test1 >col baseline_name for a4014:31:30 sys@ test1 >select dbid,baseline_id,baseline_name,expiration,creation_time from dba_hist_baseline      dbid baseline_id baseline_name                            expiration creation_time---------- ----------- ---------------------------------------- ---------- -------------------1195893416           1 work_bs1                                         30 2014-11-04 14:29:081195893416           0 system_moving_window                                2013-06-23 12:43:59重命名baseline:14:31:30 sys@ test1 >exec dbms_workload_repository.rename_baseline (old_baseline_name => 'work_bs1', new_baseline_name => 'work_bl1', dbid => 1195893416);pl/sql procedure successfully completed.14:35:46 sys@ test1 >select dbid,baseline_id,baseline_name,expiration,creation_time from dba_hist_baseline;      dbid baseline_id baseline_name                            expiration creation_time---------- ----------- ---------------------------------------- ---------- -------------------1195893416           1 work_bl1                                         30 2014-11-04 14:29:081195893416           0 system_moving_window                                2013-06-23 12:43:59删除baseline:14:35:54 sys@ test1 >exec dbms_workload_repository.drop_baseline (baseline_name => 'work_bl1',cascade => false, dbid => 1195893416);pl/sql procedure successfully completed.14:38:24 sys@ test1 >select dbid,baseline_id,baseline_name,expiration,creation_time from dba_hist_baseline;      dbid baseline_id baseline_name                            expiration creation_time---------- ----------- ---------------------------------------- ---------- -------------------1195893416           0 system_moving_window                                2013-06-23 12:43:59--cascade 参数设置为 false,指定只删除。将此参数设置为 true 指定删除与该 baseline 相关联的所有快照。移动窗口(moving window)基线
其它类似信息

推荐信息