在出现性能问题的时候,HS_DBA通常都需要你生成,出现性能问题时间段的AWR或者ASH报告,所以还是需要客户维护人员平常学会收集
AWR ASH报告收集也是比较简单的
一下为实例:
1 AWR 报告的收集
$ sqlplus / as sysdba(首先在操作上以ORACLE用户登录,并且以SYS登录数据库)
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Dec 24 14:57:53 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> @$ORACLE_HOME/rdbms/admin/awrrpt.sql;(执行这个SQL就可以开始AWR报告收集)
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
3704746844 HS08 1 HS081
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: (首先会提示你输入生成报告类型,默认为HTML,所以回车就OK)
Type Specified: html
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
3704746844 2 HS08 HS082 hp102
* 3704746844 1 HS08 HS081 hp101
Using 3704746844 for database Id
Using 1 for instance number
Specify 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: 1 (输入快照查看的间隔,一般一天的就OK,实际根据HS DBA的要求来做,)
Listing the last day's Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
HS081 HS08 158 24 Dec 2008 00:00 1
159 24 Dec 2008 01:00 1
160 24 Dec 2008 02:00 1
161 24 Dec 2008 03:00 1
162 24 Dec 2008 04:00 1
163 24 Dec 2008 05:00 1
164 24 Dec 2008 06:00 1
165 24 Dec 2008 07:00 1
166 24 Dec 2008 08:00 1
167 24 Dec 2008 09:00 1
168 24 Dec 2008 10:00 1
169 24 Dec 2008 11:00 1
170 24 Dec 2008 11:34 1
171 24 Dec 2008 11:39 1
172 24 Dec 2008 13:00 1
173 24 Dec 2008 14:00 1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 167 (首先输入开始的快照ID,此处为167)
Begin Snapshot Id specified: 167
Enter value for end_snap: 169
End Snapshot Id specified: 169 (输入快照结束ID,可以根据要求的时间确定,此处为169)
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_167_169.html. To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name: (输入报告的名字,默认的就可以,例如:awrrpt_1_167_169.html. 实例1 快照167-169的AWR报告
所以此处回车就OK,报告生成在当前目录下)
因为恒生的系统一般都是RAC,所以需要在各个节点下的AWR报告,如果你愿意登录各个节点,可以使用一下SQL
@?/rdbms/admin/awrrpti.sql ,和上边的区别就在这于,输入报告类型后的部分
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
3704746844 2 HS08 HS082 hp102
* 3704746844 1 HS08 HS081 hp101
Enter value for dbid: 3704746844 (会要求你输入数据库的DBID)
Using 3704746844 for database Id
Enter value for inst_num: 1 (输入数据库实例NUM,一般就是2节点,所以一般就是输入1 或者2)剩下的部分没啥区别
Using 1 for instance number
2 ASH报告的生成
$ sqlplus / as sysdba (首先SYS用户登录数据库)
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Dec 24 15:14:21 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> @$ORACLE_HOME/rdbms/admin/ashrpt.sql; (执行这个脚本开始ASH报告生成)
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
3704746844 HS08 2 HS082
Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
Enter 'html' for an HTML report, or 'text' for plain text
Defaults to 'html'
Enter value for report_type: (默认HTML,回车即可)
Type Specified: html
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
3704746844 1 HS08 HS081 hp101
* 3704746844 2 HS08 HS082 hp102
Defaults to current database
Using database id: 3704746844
Defaults to current instance
Using instance number: 2
ASH Samples in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Oldest ASH sample available: 17-Dec-08 11:06:09 [ 10329 mins in the past]
Latest ASH sample available: 24-Dec-08 15:14:23 [ 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: 08/12/24 15:10 (输入开始的时间,格式为: 年/月/日 小时/分钟/秒)
Report begin time specified: 08/12/24 15:10
Enter duration in minutes starting from begin time:
Defaults to SYSDATE - begin_time
Press Enter to analyze till current time
Enter value for duration: 08/12/24 15:12 (输入结束的时间 ,格式同上,根据问题发生的时间段生成就好了)
Report duration specified: 08/12/24 15:12
declare
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 12
Using 12-Aug-24 15:10:00 as report begin time
Using 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:
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is ashrpt_2_.html. To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name: (报告的名字,回车就好了)
因为恒生的系统一般都是RAC,所以需要在各个节点下的AWR报告,如果你愿意登录各个节点,可以使用一下SQL
@?/rdbms/admin/ashrpti.sql 与上边的不同也就是需要输入DBID和实例NUMBER,明白提示的意思就好了)
另外需要注意 AWR ASH报告两个快照间,或者时间之间,不能有数据库重启的操作,如果有会有报错)
常见性能报告收集方法(AWR,ASH)
最新推荐文章于 2024-04-25 15:59:02 发布