怎么手工生成ASH报告

发布时间:2021-11-04 09:54:54 作者:柒染
来源:亿速云 阅读:121

这期内容当中小编将会给大家带来有关怎么手工生成ASH报告,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

 

我们之前探讨过AWR报告的手工方法(http://space.itpub.net/17203031/viewspace-700471),借助AWR报告的定时snapshot功能,我们可以有选择性的选取时间段系统数据进行分析,最后获取综合诊断情况。除了AWR报告,Oracle10g版本中还推出了ASHADDM两个工具,用于进行系统细粒度分析和自动化专家优化方案。其中,ASHActive Session History)是一种比AWR更加细粒度分析系统会话、发现前端应用梗塞之处的工具。

 

对于Oracle数据库而言,大部分的请求都是以会话session的方式出现。一般情况下,单一会话对系统性能的影响是很小的,特别是OLTP系统。如果由于会话的原因引起系统性能,其中重要表现大都是前端应用无响应、无有效连接,同时系统表现出会话执行SQL或者等待事件的信息。同时,特定的Server Process存在高消耗的情况。

 

在会话引起性能问题或者高消耗发生的时候,我们可以通过v$sessionv$session_wait等视图定位到是哪个会话的那个SQL语句引发的问题,及时进行处理。但是实际中引起一直阻塞的会话是比较少见的,一旦会话结束或者解除终止,信息就会从v$sessionv$session_wait中被剔除掉。这个时候如果需要进行性能观察就需要使用ASHActive Session History)报表了。

 

ASHOracle 10g中推出的一系列性能监控报表的一个。ASH原理同AWR有相似之处,都是采用性能镜像收集的原理。只是ASH收集的频率更高,大约每秒进行一次收集,这样可以尽可能保存住高消耗会话的信息。其次就是收集范围上ASH不会如同AWR那样的广范围收集,主要集中在会话、关键SQLTop活动方面。与AWR默认大约保存一个月有所不同的是,ASH保存的时段比较短,为几天到几周的范围。不过对于临时性性能分析或者关键业务时段分析而言已经够用了。

 

 

Oracle10g后,可以使用OEM的可视化工具生成ASH或者查看关键Top信息。但是当系统没有OEM可以使用或者根本没有安装OEM的时候,手工生成ASH报告就是不错的方式。本篇介绍如何手工生成ASH报告,权当记录。

 

 

1、  准备环境,调用执行脚本

 

AWR手工生成的文章中,笔者选择了在Oracle服务器Linux端生成报告文件,之后再使用FTP工具进行下载到本地。本次使用客户端的脚本进行生成,为了保证一致性,尽可能使用与服务器相同的客户端脚本。

 

在命令行工具中定位到适当的目录下,之后启动Sqlplus工具。

 

 

SQL*Plus: Release 10.2.0.1.0 - Production on 星期六 7 16 21:23:06 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

 

SQL> conn sys/oracle@orcl as sysdba;

已连接。

SQL>

 

SQL> select dbid, name,log_mode from v$database;

 

      DBID NAME      LOG_MODE

---------- --------- ------------

1192098220 ORCL      NOARCHIVELOG

 

 

之后调用生成脚本ashrpt.sql。如果是使用Sqlplus工具,可以直接使用?来代指Oracle本地的$ORACLE_HOME目录。

 

 

SQL> @?/rdbms/admin/ashrpt.sql

 

 

如果是使用PL/SQL Developer等工具,就需要直接指定目录位置,?代指符的作用就不存在了。

 

调用脚本之后,就需要输入连带的参数信息。

 

2、  输入相关参数

 

ü        输入报告类型

 

AWR一样,ASH提供txthtml两种格式的报表选择。

 

 

SQL> @?/rdbms/admin/ashrpt.sql

 

Current Instance

~~~~~~~~~~~~~~~~

 

   DB Id    DB Name      Inst Num Instance

----------- ------------ -------- ------------

 1192098220 ORCL                1 orcl

 

Specify the Report Type

~~~~~~~~~~~~~~~~~~~~~~~

Enter 'html' for an HTML report, or 'text' for plain text

Defaults to 'html'

输入 report_type 的值:

 

 

脚本第一步要求输入生成报告的类型,默认为html。如果希望生成txt格式,就输入text

 

ü        输入分析时段信息

 

ASH是一个时段分析报告,需要用户输入进行分析的时间范围开始点。

 

 

Type Specified:  html

 

Instances in this Workload Repository schema

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   DB Id     Inst Num DB Name      Instance     Host

------------ -------- ------------ ------------ ------------

* 1192098220        1 ORCL         orcl         WWW-0E6111DF

                                                F74

 

Defaults to current database

Using database id: 1192098220

Defaults to current instance

Using instance number: 1

 

ASH Samples in this Workload Repository schema

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Oldest ASH sample available:  13-7 -11 19:32:48  [   4435 mins in the past]

Latest ASH sample available:  16-7 -11 21:25:54  [      2 mins in the past]

 

Specify the timeframe. to generate the ASH report

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enter begin time for report:

 

--    Valid input formats:

--      To specify absolute begin time:

--        [MM/DD[/YY]] HH24:MI[:SS]

--        Examples: 02/23/03 14:30:15

--                  02/23 14:30:15

--                  14:30:15

--                  14:30

--      To specify relative begin time: (start with '-' sign)

--        -[HH24:]MI

--        Examples: -1:15  (SYSDATE - 1 Hr 15 Mins)

--                  -25    (SYSDATE - 25 Mins)

 

Defaults to -15 mins

输入 begin_time 的值:

 

 

由于ASH分析的粒度到秒一级别,所以输入的时间段度是以秒的细粒度。Begin_time输入的时间粒度有两种方式,根据脚本中提示的内容。一种是绝对开始时间(absolute begin time),包括年月日时分秒,适当省略一部分信息意味着使用当前对应的信息。另一种是相对开始时间(relative begin time),使用“-”号开头,表示当前时间之前多久。

 

 

输入 begin_time 的值:  21:15:00

Report begin time specified: 21:15:00

 

 

此处我们希望分析21:15:00开始的五分钟信息情况。

 

输入了开始时间,可以定义分析持续时间duration值。

 

//输入以分钟计数的持续时间

Enter duration in minutes starting from begin time:

Defaults to SYSDATE - begin_time

Press Enter to analyze till current time

输入 duration 的值:

 

输入 duration 的值:  5

Report duration specified:   5

 

 

ü        其他相关指定参数

 

ASH报告中分析包括的内容很多,有时候我们可能希望分析的更加有针对性。比如特定的SQL语句分析,特定的会话信息分析等。

 

 

Using 16-7 -11 21:15:00 as report begin time

Using 16-7 -11 21:20:00 as report end time

 

Specify Slot Width (using ashrpti.sql) for 'Activity Over Time' section

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- Explanation:

--   In the 'Activity Over Time' section of the ASH report,

--   the analysis period is divided into smaller slots

--   and top wait events are reported in each of those slots.

 

-- Default:

--   The analysis period will be automatically split upto 10 slots

--   complying to a minimum slot width of

--     1 minute,  if the source is V$ACTIVE_SESSION_HISTORY or

--     5 minutes, if the source is DBA_HIST_ACTIVE_SESS_HISTORY.

 

Specify Slot Width in seconds to use in the 'Activity Over Time' section:

Defaults to a value as explained above:

Slot Width specified:

 

Specify Report Targets (using ashrpti.sql) to generate the ASH report

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- Explanation:

--   ASH Report can accept "Report Targets",

--   like a particular SQL statement, or a particular SESSION,

--   to generate the report on. If one or more report targets are

--   specified, then the data used to generate the report will only be

--   the ASH samples that pertain to ALL the specified report targets.

 

-- Default:

--   If none of the report targets are specified,

--   then the target defaults to all activity in the database instance.

 

Specify SESSION_ID (eg: from V$SESSION.SID) report target:

Defaults to NULL:

SESSION report target specified:

 

Specify SQL_ID (eg: from V$SQL.SQL_ID) report target:

Defaults to NULL: (% and _ wildcards allowed)

SQL report target specified:

 

Specify WATI_CLASS name (eg: from V$EVENT_NAME.WAIT_CLASS) report target:

[Enter 'CPU' to investigate CPU usage]

Defaults to NULL: (% and _ wildcards allowed)

WAIT_CLASS report target specified:

 

Specify SERVICE_HASH (eg: from V$ACTIVE_SERVICES.NAME_HASH) report target:

Defaults to NULL:

SERVICE report target specified:

 

Specify MODULE name (eg: from V$SESSION.MODULE) report target:

Defaults to NULL: (% and _ wildcards allowed)

MODULE report target specified:

 

Specify ACTION name (eg: from V$SESSION.ACTION) report target:

Defaults to NULL: (% and _ wildcards allowed)

ACTION report target specified:

 

Specify CLIENT_ID (eg: from V$SESSION.CLIENT_IDENTIFIER) report target:

Defaults to NULL: (% and _ wildcards allowed)

CLIENT_ID report target specified:

通过指定一系列的参数变量可以来指定希望分析的会话信息。

 

如果没有指定,ASH会生成所有模块的分析信息。

 

ü        文件名指定

 

最后是指定生成的文件名称信息。

 

 

Specify the Report Name

~~~~~~~~~~~~~~~~~~~~~~~

The default report file name is ashrpt_1_0716_2120.html.  To use this name,

press <return> to continue, otherwise enter an alternative.

输入 report_name 的值:

 

 

一般使用默认值就可以了。最后会将文件生成提示结束。

 

</TABLE><P>

<BR><A class='awr' HREF='#top'>Back to Top</A><P>

<P>

End of Report

</BODY></HTML>

Report written to ashrpt_1_0716_2120.html

SQL>

3、查看报告

 

在调用目录上,就可以找到我们生成的ASH文件。

ASH Report For ORCL/orcl

DB Name         DB Id    Instance     Inst Num Release     RAC Host

------------ ----------- ------------ -------- ----------- --- ------------

ORCL          1192098220 orcl                1 10.2.0.1.0  NO  WWW-0E6111DF

 

CPUs           SGA Size       Buffer Cache        Shared Pool    ASH Buffer Size

---- ------------------ ------------------ ------------------ ------------------

   2        584M (100%)       408M (69.9%)       149M (25.6%)        4.0M (0.7%)

 

          Analysis Begin Time:  16-7 -11 21:15:00

            Analysis End Time:  16-7 -11 21:20:00

                 Elapsed Time:         5.0 (mins)

                 Sample Count:           5

 

4、结论

ASHAWRADDMOracle推进的性能优化自动化的重要步骤阶段。借助这些工具,DBA可以更好的了解分析系统性能,发现瓶颈所在,更好的维护系统正常运转。

上述就是小编为大家分享的怎么手工生成ASH报告了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. 手动生成AWR报告
  2. cucumber 生成html的报告:

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

ash

上一篇:Oracle数据泵常用命令有哪些

下一篇:怎么解决12cRAC打季度补丁时遇到ORA-12547: TNS:lost contact错误

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》