|
本帖最后由 jiawang 于 2023-7-19 12:45 编辑
和ash相关的视图
·v$session代表数据库活动的开始,是为源起;
·v$session_wait视图用以实时记录活动session的等待情况,是当前信息;
·v$session_wait_history是对v$session_wait的简单增强,记录活动session的最近10次等待;
·v$active_session_history是ASH的核心,用以记录当前数据库活动session的历史等待信息,每秒采样1次v$session_wait,这部分内容记录在内存中,期望值是记录1个小时的内容;
·wrh$_active_session_history是v$active_session_history在AWR的存储池,v$active_session_history中记录的信息会被定期(每小时1次)地刷新到负载库中,并缺省保留一个星期用于分析;
·dba_hist_active_sess_history视图是wrh$_active_session_history视图和其他几个视图的联合展现,我们通常通过这个视图进行历史数据的访问。
为了获得最近一段时间的数据库的状态信息,我们可以生成ash报告,或查看v$active_session_history
--查看非空闲等待
select * from v$session where wait_class<>'Idle';
select * from v$session_wait where wait_class<>'Idle';
--查看ash信息
select * from v$active_session_history;
--生成ash报告
运行$ORACLE_HOME/rdbms/admin/ashrpt.sql
测试:
[oracle@strong ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 19 12:41:27 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> @?/rdbms/admin/ashrpt.sql
Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
Enter 'html' for an HTML report, or 'text' for plain text
Defaults to 'html'
Enter value for report_type:
old 2: lower( (case when '&&report_type' IS NULL
new 2: lower( (case when '' IS NULL
old 3: then '&&default_report_type'
new 3: then 'html'
old 4: when '&&report_type' <> 'text'
new 4: when '' <> 'text'
old 6: else '&&report_type' end) ) report_type
new 6: else '' end) ) report_type
Type Specified: html
old 1: select '&&report_type' report_type_def from dual
new 1: select 'html' report_type_def from dual
old 1: select '&&view_loc' view_loc_def from dual
new 1: select 'AWR_PDB' view_loc_def from dual
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
1575005578 ORCL 1 orcl
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ ---------- --------- ---------- ------
* 1575005578 1 ORCL orcl strong
Defaults to current database
Using database id: 1575005578
Enter instance numbers. Enter 'ALL' for all instances in a
RAC cluster or explicitly specify list of instances (e.g., 1,2,3).
Defaults to current instance.
Using instance number(s): 1
ASH Samples in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Oldest ASH sample available: 08-May-23 17:33:41 [ ###### mins in the past]
Latest ASH sample available: 19-Jul-23 12:41:15 [ 0 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: -30
Report begin time specified: -30
Enter duration in minutes starting from begin time:
Defaults to SYSDATE - begin_time
Press Enter to analyze till current time
Enter value for duration: 30
Using 19-Jul-23 12:11:42 as report begin time
Using 19-Jul-23 12:41:42 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 AWR_(PDB/ROOT)_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 WAIT_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:
Specify PLSQL_ENTRY name (eg: "SYS.DBMS_LOB.*") report target:
Defaults to NULL: (% and _ wildcards allowed)
PLSQL_ENTRY report target specified:
Specify CONTAINER name (eg: NAME from V$PDBS) report target:
Defaults to NULL: (% and _ wildcards allowed)
CONTAINER report target specified:
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is ashrpt_1_0719_1241.html. To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name:
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is ashrpt_1_0719_1241.html. To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name:
Using the report name ashrpt_1_0719_1241.html
Summary of All User Input
-------------------------
Format : HTML
DB Id : 1575005578
Inst num : 1
Begin time : 19-Jul-23 12:11:42
End time : 19-Jul-23 12:41:42
Slot width : Default
Report targets : 0
Report name : ashrpt_1_0719_1241.html
.....
.....
.....
End of Report
</body></html>
Report written to ashrpt_1_0719_1241.html
验证
[oracle@strong ~]$ ll
total 36
-rw-r--r-- 1 oracle dba 33341 Jul 19 12:43 ashrpt_1_0719_1241.html
|
|