抓取awr、语句级awr、ashrpt

exec dbms_workload_repository.create_snapshot();--调用MMON进程立即收集快照

生成AWR报告
@?/rdbms/admin/awrrpt.sql;

9.4.2  SQL语句级AWR报告分析

上面提到还有一个awrsqrpt.sql,它不是为整个实例生成报告,而是为某个特定SQL生成报告,这在优化某些特定SQL时可以隔离掉其他干扰因素,更易量化。如下:

SQL> @awrsqrpt.sql

Current Instance

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

DB Id    DB Name     Inst Num Instance

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

83642957 ORA11G               1 ora11g

…此处快照开始和结束ID选择省去…

Specify the SQL Id

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

Enter value for SQL_id: 8rmfvr1sw2wgn       #SQL_ID需要先从V$SQL.sql_ID获取

SQL ID specified:  8rmfvr1sw2wgn

Specify the Report Name

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

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

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

Enter value for report_name:

Using the report name awrsqlrpt_1_2327_2354.html

执行完成后,当前目录下会生成awrsqlrpt_1_2327_2354.html这个文件。

9.4.5  ASH分析

和AWR一样,ASH也是实时收集,并定期保存到V$动态性能视图中,用户可以通过查询动态视图或者ASH报告进行分析。Oracle会每秒对所有活跃会话(是指正在使用CPU或者等待非空闲事件的会话)进行一次采样,记录其当前等待的事件,该信息被存储SGA的ASH Buffer中,默认大小为32M,对应性能试图是V$ACTIVE_SESSION_HISTORY,并定期刷新到磁盘中,对应性能试图是DBA_HIST_ACTIVE_SESS_HISTORY。ASH中收集的信息包括会话当前正在执行的SQL以及执行计划,访问的对象信息比如对象号、文件号、块号,等待事件及其参数及其他信息。类似于AWR报告,一般通过ashrpt.sql或ashrpti.sql生成ASH报告,ashrpt生成的是整个实例的活动会话报告,ashrpti则是交互式的允许用户指定各种例如比如特定会话、特定SQL、特定模块等,和AWR不同,实例范围的ASH报告用的并不是很多,所以我们以ashrpti.sql生成特定会话的ASH为例。其生成如下:

[oracle@hs-test-10-20-30-14 ~]$ cd /u01/app/Oracle/product/11.2.0/dbhome_1/rdbms/admin/

[oracle@hs-test-10-20-30-14 admin]$ sqlplus "/as sysdba"

SQL> @ashrpti

…此处省区非必要信息…

ASH Samples in this Workload Repository schema

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

Oldest ASH sample available:  24-Oct-18 09:00:06   [  14629 mins in the past]

Latest ASH sample available:  03-Nov-18 12:48:12   [      1 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

Enter value for begin_time:

Report begin time specified:

Enter duration in minutes starting from begin time:

Defaults to SYSDATE - begin_time

Press Enter to analyze till current time

Enter value for duration:

Report duration specified:

Using 03-Nov-18 12:33:55 as report begin time

Using 03-Nov-18 12:48:58 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:

Enter value for slot_width: 10

Slot Width specified: 10

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:

Enter value for target_session_id: 1144

SESSION report target specified: 1144

Summary of All User Input

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

Format             : HTML

DB Id                : 83642957

Inst num       : 1

Begin time     : 03-Nov-18 12:33:55

End time       : 03-Nov-18 12:48:58

Slot width     : 10 seconds

Report targets : 1

Report name    : ashrpt_1_1103_1248.html

上一篇:linux ssh 安装、安全设置


下一篇:打包制作 ANE