ORACLE AWR 和 ASH
一.关于ASH
我们都知道,用户在 ORACLE 数据库中执行操作时,必然要创建相应的连接和会话, 其中,所有当前的会话信息都保存在动态性能视图 V$SESSION 中,通过该视图,DBA 可 以查看用户实际执行的操作,或者当前的等待事件等。通常这部分信息是调优过程中的关键 信息,不过,一旦连接断开。会话信息就会被同时从V$SESSION及其它相关视图中清除, 也就是说,用户执行完操作走人,而你(DBA),如果不能在当前逮到他,过了这点,就不知 道它曾经做过什么了。
10g 版本中,ORACLE 又新增加了一个视图(其它是若干,不过咱们还是以session 为引 子说):V$ACTIVE_SESSION_HISTORY,看名字就知道,就是活动会话的历史记录.这下,即使用户操作完成后,断开了连接也不怕,因为其会话的情况已经被记录了下来,这项特性 就是 ASH了,全称与视图名相同,正是:ACTIVESESSIONHISTORY。 ASH 每秒钟收集一次当前处于非空闲等待事件的、活动状态的、session 的信息,并保 存在 V$ACTIVE_SESSION_HISTORY视图中,我们(应该以及必须)知道,动态性能视图其 实上是 ORACLE 自行构造的一堆存在于 SGA 内存区的虚表,就是说,ASH 的数据是保存在内存里的,实际上,ORACLE分配给 ASH 的空间并不是无限大(更何况 ORACLE 自身管 理的内存空间也不是无限大),查看 ASH可供使用的内存空间,可以通过如下SQL:
SQL> select pool,name,bytes/1024/1024 Mb From v$sgastat where name like 'ASH%';POOL NAME MB ------------ -------------------------- ---------- shared pool ASH buffers 2SQL>
直白的讲,V$ACTIVE_SESSION_HISTORY中能够记录多少会话信息,一方面取决于 该数据库的 SGA 分配给 ASHbuffers 的大小,另一方面取决于数据库的启动和关闭(重启数 据库时将重构 SGA 内存区)。这两方面的因素制约了 V$ACTIVE_SESSION_HISTORY中能够保存的会话信息的能力,做为DBA,我们肯定是希望 ASH 尽可能多的保留关于会话的信 息,但目前来看单纯依靠V$ACTIVE_SESSION_HISTORY肯定无法实现这点,那怎么办呢? 别担心,ORACLE又提供了 AWR特性,ASH 收集到的会话信息,是做为AWR中快照信息 的一部分,被保存到了硬盘上.
二.关于AWR
- AWR 是 Oracle10g 版本推出的新特性,全称叫AutomaticWorkloadRepository-自动负载信息库
- AWR 是通过对比两次快照(snapshot)收集到的统计信息,来生成报表数据,生成的报表包括多个部分
- AWR 在生成报告时,可以选 择生成 TXT或 HTML两种格式的报告,相对来说,HTML更利于阅读
生成分析报表种类:
- awrrpt.sql: 生成指定快照区间的统计报表;
- awrrpti.sql: 生成指定数据库实例(如:RAC中的某一个实例的awr),并且指定快照区间的统计报表;
- awrsqlrpt.sql:生成指定快照区间,指定 SQL语句(实际指定的是该语句的SQLID) 的统计报表;
- awrsqrpi.sql:生成指定数据库实例,指定快照区间的指定 SQL语句的统计报表;
- awrddrpt.sql:指定两个不同的时间周期,生成这两个周期的统计对比报表;
- awrddrpi.sql:指定数据库实例,并指定两个的不同时间周期,生成这两个周期的统 计对比报表
提示:要想让 AWR 收集到准确的统计信息,从而生成可靠的 性能分析报告,必须将初始化参数STATISTICS_LEVEL的值设置为 TYPICAL或 ALL。
2.1生成标准统计报表
SQL> @$ORACLE_HOME/rdbms/admin/awrrpt.sqlCurrent Instance ~~~~~~~~~~~~~~~~DB Id DB Name Inst Num Instance ----------- ------------ -------- ------------864496616 RACDB 1 racdb1Specify the Report Type ~~~~~~~~~~~~~~~~~~~~~~~ Would you like an HTML report, or a plain text report? Enter 'html' for an HTML report, or 'text' for plain text Defaults to 'html' Enter value for report_type: html --生成awr报告文件类型 Type Specified: htmlInstances in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~DB Id Inst Num DB Name Instance Host ------------ -------- ------------ ------------ ------------864496616 2 RACDB racdb2 node2 * 864496616 1 RACDB racdb1 node1Using 864496616 for database Id Using 1 for instance numberSpecify the number of days of snapshots to choose from ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entering the number of days (n) will result in the most recent (n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots.Enter value for num_days: 7 --此处需指定要读取多少天内的快照信息! Listing the last 7 days of Completed SnapshotsSnap Instance DB Name Snap Id Snap Started Level ------------ ------------ --------- ------------------ ----- racdb1 RACDB 1 21 Dec 2014 09:12 1 --快照的id 及生成时间2 21 Dec 2014 10:00 13 21 Dec 2014 11:00 14 21 Dec 2014 12:00 15 21 Dec 2014 13:00 16 21 Dec 2014 14:00 17 21 Dec 2014 15:00 18 21 Dec 2014 16:00 19 21 Dec 2014 17:00 110 21 Dec 2014 18:00 111 21 Dec 2014 19:00 1Specify the Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter value for begin_snap: 6 --根据想要搜集信息的时间段,选择起始快照id Begin Snapshot Id specified: 6Enter value for end_snap: 10 End Snapshot Id specified: 10 Specify the Report Name ~~~~~~~~~~~~~~~~~~~~~~~ The default report file name is awrrpt_1_6_10.html. To use this name, press <return> to continue, otherwise enter an alternative.Enter value for report_name: /home/oracle/awrrpt_1_6_10.html --生成awr报告文件名称 Using the report name /home/oracle/awrrpt_1_6_10.html
2.2 生成指定数据库实例的统计报表
这项统计报表一般是针对多实例数据库,上面使用的脚本是生成数据库级别的统计报 表,对于多实例的数据库,有时候DBA 可能希望看到某个实例的表现,那么本脚本就能派 上用场了。
SQL> @$ORACLE_HOME/rdbms/admin/awrrpti.sql Specify the Report Type ~~~~~~~~~~~~~~~~~~~~~~~ Would you like an HTML report, or a plain text report? Enter 'html' for an HTML report, or 'text' for plain text Defaults to 'html' Enter value for report_type: htmlType Specified: htmlInstances in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~DB Id Inst Num DB Name Instance Host ------------ -------- ------------ ------------ ------------864496616 2 RACDB racdb2 node2 * 864496616 1 RACDB racdb1 node1Enter value for dbid: 864496616 Using 864496616 for database Id Enter value for inst_num: 2 Using 2 for instance numberSpecify the number of days of snapshots to choose from ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entering the number of days (n) will result in the most recent (n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots.Enter value for num_days: 7 Listing the last 7 days of Completed SnapshotsSnap Instance DB Name Snap Id Snap Started Level ------------ ------------ --------- ------------------ ----- racdb2 RACDB 1 21 Dec 2014 09:11 12 21 Dec 2014 09:55 13 21 Dec 2014 10:51 111 21 Dec 2014 18:58 1Specify the Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter value for begin_snap: 1 Begin Snapshot Id specified: 1Enter value for end_snap: 3 End Snapshot Id specified: 3Specify the Report Name ~~~~~~~~~~~~~~~~~~~~~~~ The default report file name is awrrpt_2_1_3.html. To use this name, press <return> to continue, otherwise enter an alternative.Enter value for report_name: /home/oracle/awrrpt_2_1_3.html
2.3 生成不同时间段时的统计对比报表
在AWR中, 直接就提供了对不同时间段时,数据库的性能统计做差异对比的功能
SQL> @$ORACLE_HOME/rdbms/admin/awrddrpt.sqlCurrent Instance ~~~~~~~~~~~~~~~~DB Id DB Id DB Name Inst Num Inst Num Instance ----------- ----------- ------------ -------- -------- ------------864496616 864496616 RACDB 1 1 racdb1Specify the Report Type ~~~~~~~~~~~~~~~~~~~~~~~ Would you like an HTML report, or a plain text report? Enter 'html' for an HTML report, or 'text' for plain text Defaults to 'html' Enter value for report_type: htmlType Specified: htmlInstances in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~DB Id Inst Num DB Name Instance Host ------------ -------- ------------ ------------ ------------864496616 2 RACDB racdb2 node2 * 864496616 1 RACDB racdb1 node1Database Id and Instance Number for the First Pair of Snapshots ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Using 864496616 for Database Id for the first pair of snapshots Using 1 for Instance Number for the first pair of snapshotsSpecify the number of days of snapshots to choose from ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entering the number of days (n) will result in the most recent (n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots.Enter value for num_days: 7Listing the last 7 days of Completed SnapshotsSnap Instance DB Name Snap Id Snap Started Level ------------ ------------ --------- ------------------ ----- racdb1 RACDB 1 21 Dec 2014 09:12 12 21 Dec 2014 10:00 13 21 Dec 2014 11:00 14 21 Dec 2014 12:00 15 21 Dec 2014 13:00 16 21 Dec 2014 14:00 17 21 Dec 2014 15:00 18 21 Dec 2014 16:00 19 21 Dec 2014 17:00 110 21 Dec 2014 18:00 111 21 Dec 2014 19:00 1Specify the First Pair of Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter value for begin_snap: 1 First Begin Snapshot Id specified: 1Enter value for end_snap: 3 First End Snapshot Id specified: 3Instances in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~DB Id Inst Num DB Name Instance Host ------------ -------- ------------ ------------ ------------864496616 2 RACDB racdb2 node2 * 864496616 1 RACDB racdb1 node1Database Id and Instance Number for the Second Pair of Snapshots ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Using 864496616 for Database Id for the second pair of snapshots Using 1 for Instance Number for the second pair of snapshotsSpecify the number of days of snapshots to choose from ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Entering the number of days (n) will result in the most recent (n) days of snapshots being listed. Pressing <return> without specifying a number lists all completed snapshots.Enter value for num_days2: 7Listing the last 7 days of Completed SnapshotsSnap Instance DB Name Snap Id Snap Started Level ------------ ------------ --------- ------------------ ----- racdb1 RACDB 1 21 Dec 2014 09:12 12 21 Dec 2014 10:00 13 21 Dec 2014 11:00 14 21 Dec 2014 12:00 15 21 Dec 2014 13:00 16 21 Dec 2014 14:00 17 21 Dec 2014 15:00 18 21 Dec 2014 16:00 19 21 Dec 2014 17:00 110 21 Dec 2014 18:00 111 21 Dec 2014 19:00 1Specify the Second Pair of Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter value for begin_snap2: 8 Second Begin Snapshot Id specified: 8Enter value for end_snap2: 11 Second End Snapshot Id specified: 11Specify the Report Name ~~~~~~~~~~~~~~~~~~~~~~~ The default report file name is awrdiff_1_1_1_8.html To use this name, press <return> to continue, otherwise enter an alternative.Enter value for report_name: /home/oracle/awrdiff_1_1_1_8.html
三.几个相关概念---快照
3.1 Snapshots(快照)
前面操作报表生成时,snap 这个关键字已经出现过黑多黑多次了,想必你对它充满了疑惑,这个东西是哪尬来的咋来的谁让它来的呢?事实上,Snap是 Snapshot的简写,这正是 AWR 在自动性方面的体现,虽然你没有创建,但是AWR自动帮你创建了(当然也可以手 动创建snapshot),并且是定时(每小时)创建,定期清除(保留最近 7 天)。 Snapshots 是一组某个时间点时历史数据的集合,这些数据就可被 ADDM(Automatic DatabaseDiagnosticMonitor)用来做性能对比。默认情况下,AWR 能够自动以每小时一次的 频率 生成 Snapshots 性能数据, 并保留 7 天,如果需要的话 ,DBA 可以通过 DBMS_WORKLOAD_REPOSITORY过程手动创建、删除或修改 snapshots。
3.2 手动创建Snapshots
- 通过 DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT 过程,例如:
- SQL>execdbms_workload_repository.create_snapshot();
- 可以通过 DBA_HIST_SNAPSHOT 视图查看刚刚创建的 Snapshots信息。
3.3 手动删除Snapshots
删除 Snapshots 是使用DBMS_WORKLOAD_REPOSITORY 包的另一个过程 : DROP_SNAPSHOT_RANGE,该过程在执行时可以通过指定 snap_id 的范围的方式一次删除多个 Snapshots,例如:
--查看删除前 SQL>select count(0) from dba_hist_snapshot where snap_id between 7509 and 7518;--删除 SQL>begin 2 dbms_workload_repository.drop_snapshot_range( 3 low_snap_id=>7509, 4 high_snap_id=>7518,5 dbid=>3812548755); 6 end; 7 /--查看删除后 SQL>select count(0) from dba_hist_snapshot where snap_id between 7509 and 7518;--当snapshots 被删除的话,与其关联的ASH 记录也会级联删除。
3.4 修改Snapshots
DBA 可以调整包括快照收集频率、快照保存时间、以及捕获的SQL数量三个方面的设置.分别对应 MODIFY_SNAPSHOT_SETTINGS的三个参数:
- Retention:设置快照保存的时间,单位是分钟。可设置的值最小为1 天,最大为100 年。设置该参数值为0 的话,就表示永久保留收集的快照信息。
- Interval:设置快照收集的频率,以分钟为单位。可设置的值最小为10 分钟,最大 为 1 年。如果设置该参数值为0,就表示禁用 AWR特性。
- Topnsql:指定收集的比较占用资源的SQL数量,可设置的值最小为30,最大不超 过 100000000。
通过 DBA_HIST_WR_CONTROL 视图查看当前快照收集的相关设置:
SQL> select*from dba_hist_wr_control;
四.几个相关概念---基线
4.1 Baselines(基线)
Baseline,直译的话叫做基线,顾名思义的方式理解,就是用于比较的基本线。因为 Baseline 中包含指定时间点时的性能数据,因此就可以用来与其它时间点时的状态数据做对比,以分析性能问题。
创建 Baseline 时,Snapshots是做为其中的一个组成部分存在,因此一般来说当 AWR 自动维护快照时,如果定义过 baseline,与 baseline 相关的快照不会被删除,即使是过期的快照,这样就相当于手动保留了一份统计数据的历史信息,DBA 可以在适当的时间将其与 现有的快照进行对比,以生成相关的统计报表。
4.2 创建Baseline
用户可以通过 DBMS_WORKLOAD_REPOSITORY包中的相关过程,手动的创建或删除 Baseline。
创建 Baseline 使用CREATE_BASELINE过程,执行该过程时分别指定开始和结果的snap_id,然后为该 baseline 定义一个名称即可,例如:
SQL>BEGIN 2 DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE(start_snap_id => 7550, 3 end_snap_id =>7660, 4 baseline_name=>'am_baseline'); 5 END; 6 /
--查看
SQL>select dbid,baseline_name,start_snap_id,end_snap_id from dba_hist_baseline;
4.3 删除Baseline
删除 Baseline 使用 DROP_BASELINE 过程,删除时可以通过 cascade 参数选择是否将其关联的 Snapshots 级别进行删除,例如:
SQL>BEGIN 2 DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE(baseline_name => 'am_baseline', 3 cascade =>true); 4 END; 5 /SQL>select * from dba_hist_baseline;SQL>select * from dba_hist_snapshot where snap_id between 7550 and 7660;
如上例中所示,删除时指定了cascade 参数值为 true,对应的 snap也被级联删除了。
----整理自君三四笔记
转载于:https://www.cnblogs.com/polestar/p/4206409.html
ORACLE AWR 和 ASH相关推荐
- 学用ORACLE AWR和ASH特性(4)-生成指定SQL的统计报表
2.3 生成指定SQL语句的统计报表 这项统计专门用来分析某条指定的SQL语句,通过awrsqrpt.sql脚本,awr能够生成指定sql(曾经执行过的SQL)的执行计划,消耗的资源等等信息,有助于 ...
- oracle awr与ash性能报告深入解析,Oracle AWR 与 ASH 性能报告深入解析
<Oracle AWR 与 ASH 性能报告深入解析> 一 数据库版本 LEO1@LEO1> select * from v$version; BANNER ---------- ...
- Oracle AWR ASH
AWR基础知识 1.自动工作负荷仓库 Oracle收集了大量与性能和动作相关的统计信息.这些信息在内存中累加,并且有规律地写入磁盘(也就是写入构成AWR的表).最终,这些信息会过期并被重写. 1.1. ...
- Oracle 11G常见性能诊断报告(AWR/ADDM/ASH)收集
Docker安装Oracle_11g数据库并配置: https://blog.csdn.net/qq_44895681/article/details/113975822 前言: 在生产环境中,当运 ...
- Oracle Awr
About Oracle AWR Oracle AWR is a powerful monitoring utility bundle with Oracle Database from 10g. O ...
- mysql awr flush_Oracle ASH内存强制Flush日志解决一例
Oracle ASH(Active Session History)是作为细粒度的AWR报告,经常在我们进行性能调优过程中被应用到.和所有的监控手段一样,A Oracle ASH(Active Ses ...
- oracle 删除awr报告,学习笔记:Oracle awr入门 深入了解AWR报告
天萃荷净 深入了解AWR报告,ASH与AWR报告的官方说明,数据库进程和性能视图获取 1.AWR与ASH概念 1.ASH 若是一个普通的会话(我是指没有大量地耗费资源),则对于性能调整来说无足轻重.但 ...
- Oracle AWR报告详细分析
Oracle AWR报告详细分析 (文档 ID 1523048.1) AWR 是 Oracle 10g 版本 推出的新特性, 全称叫Automatic Workload Repository-自动 ...
- Oracle AWR 报告中 No data exists for this section of the report 说明
在AWR中,如果有部分选项是:Nodata exists for this section of the report.那么属正常现象. 如: 那么现在看一个有数据的AWR: 在下面的这个图中就显示了 ...
最新文章
- 使用Log4j进行日志操作(牛小浩)不错的
- CentOS ping name or service not known问题解决
- swap 将硬盘变内存
- EF 表联合查询 join
- AI基础:特征工程-数字特征处理
- idea 分支管理插件_Git的分支管理常用命令
- 6本书,读懂2022年最火的边缘计算
- access 图片存储的格式_Ceph对象存储RGW架构及安装实战
- centos7 二进制安装mysql,Centos7 二进制安装mysql5.7
- 幼儿园编程机器人课程介绍
- 计算机快速扫描技术的优点是,与传统扫描仪比较起来高拍仪的优点有哪些?
- mysql自增长id用完了,怎么办?
- iPhone电池健康度是什么
- 西门子精彩屏+精简屏+精智屏设置屏保功能的具体方法和步骤
- kettle读取hbase
- 计算机网络第七版(谢希仁)学习目录
- 春天,盐城北大青鸟学子收获成长的季节
- 万豪国际集团旗下24家餐厅入围2022黑珍珠餐厅指南
- ACPI AML debug and override ACPI tables using initrd
- 网络爬虫的 “ 黑洞 ”
热门文章
- WordPress在nginx下的URL重写规则
- MM的静态寻址和动态寻址
- 三百元月薪的小资生活
- U3D 编辑器中sceneview下相机操作相关
- 英伟达第二季度营收增长24%
- voxel 与 pixel
- *.zip、*.tar、*.tar.gz、*.tar.bz2、*.tar.xz、*.jar、*.7z
- 走过2011---年终总结
- ImageView和onTouchListener实现,点击查看图片细节
- HD 1003 Max Sum (最大字段和问题)