千家信息网

如何手工生成AWR运行期对比报告

发表于:2025-02-04 作者:千家信息网编辑
千家信息网最后更新 2025年02月04日,这篇文章将为大家详细讲解有关如何手工生成AWR运行期对比报告,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。AWR(Automatic Workload
千家信息网最后更新 2025年02月04日如何手工生成AWR运行期对比报告

这篇文章将为大家详细讲解有关如何手工生成AWR运行期对比报告,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

AWR(Automatic Workload Repository)报告是Oracle 10g之后推出的重要性能诊断工具。AWR是作为Statspack报告的一种有力延伸。借助AWR,我们可以方便的对Oracle数据库的特定工作时间段进行性能分析评价,最终达到发现瓶颈调优的目标。

作为DBA,手工生成AWR报告是工作基本功之一。笔者在之前的《手工生成AWR报告记录》(http://space.itpub.net/17203031/viewspace-700471)中,就已经详细介绍过如何在sqlplus工具下生成AWR报告。

1、从AWR到AWR Compare Period Report

AWR是一个产品体系,根据定时收集的系统运行数据,我们其实可以做的更多。在现在主流的运维管理和调优过程中,基线baseline的概念是一直贯穿始终。系统运行负载Baseline、关键SQL执行计划Baseline等等,反复出现。总之,所谓的Baseline,简单的说就是一套运行负载指标或者执行计划指标。当你认为系统出现问题的时候,可以将Baseline作为标准进行对比,发现问题所在。进一步的,可以将Baseline作为应急手段,强制使用应对生产(SQL Profile、SPM)。

我们一般的调优过程中,也的确需要这样的小工具。比如:业务高峰期和低谷期,数据库各方面指标有什么样显著的差异?进行调优之后,系统性能指标有何种方式变化?这种时候,生成两份AWR,看着对比的确是一种方法。但是,Oracle已经为我们提供出AWR Compare Period Report来方便实现这样的功能。

从原理上,AWR Compare Period Report不难理解。Oracle将各个时间snap的性能数据保存在SYSAUX表空间的一系列数据字典表中,只要经过合理的组织,compare report不是一件困难的事情。

2、手工生成报告

本文是一篇记录文章,依然采用手工sqlplus的方法生成报告。

ü 登录sqlplus,运行脚本

使用sqlplus,登录入指定系统。

D:\>sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on 星期一 3月 5 09:02:42 2012

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

SQL>(登录过程略……

--调用脚本

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

注意:在sqlplus中,?表示$ORACLE_HOME路径。指定的awrddrpt.sql脚本,也是确实在客户端本地SQL执行脚本。如果使用如PL/SQL Developer等开发工具,请指定直接路径。

ü 输入基本报告类型

首先同AWR报告一样, Compare Period Report也存在TEXT和HTML两种格式支持。在创建过程中,我们需要进行选定。

Current Instance

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

DB Id DB Id DB Name Inst Num Inst Num Instance

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

2351142467 2351142467 NBSTEST 1 1 NBSTEST

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'

输入 report_type 的值:

Type Specified: html

ü 输入第一对比时间段项目

既然要做到对比,首先需要指定一个对比时间范围。这个过程同一般AWR报告相同,过程不予累述。

Instances in this Workload Repository schema

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

DB Id Inst Num DB Name Instance Host

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

* 2351142467 1 NBSTEST NBSTEST P550_05_LC

Database Id and Instance Number for the First Pair of Snapshots

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

Using 2351142467 for Database Id for the first pair of snapshots

Using 1 for Instance Number for the first pair of snapshots

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 without

specifying a number lists all completed snapshots.

--输入对比时间范围

输入 num_days 的值: 3

之后,Oracle会列出三天范围的snap信息。

Listing the last 3 days of Completed Snapshots

Snap

Instance DB Name Snap Id Snap Started Level

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

NBSTEST NBSTEST 10251 03 3月 2012 00:00 1

10252 03 3月 2012 01:00 1

(篇幅原因,省略部分……

10305 05 3月 2012 06:00 1

Snap

Instance DB Name Snap Id Snap Started Level

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

NBSTEST NBSTEST 10306 05 3月 2012 07:00 1

10307 05 3月 2012 08:00 1

10308 05 3月 2012 09:00 1

Specify the First Pair of Begin and End Snapshot Ids

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

输入 begin_snap 的值:

--指定时间片

Specify the First Pair of Begin and End Snapshot Ids

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

输入 begin_snap 的值: 10296

First Begin Snapshot Id specified: 10296

输入 end_snap 的值: 10298

设定了开始和结束时间snap,作为第一个时间。

ü 输入第二对比时间段项目

第二报告时间snap信息基本相同,不予累述。

Instances in this Workload Repository schema

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

DB Id Inst Num DB Name Instance Host

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

* 2351142467 1 NBSTEST NBSTEST P550_05_LC

Database Id and Instance Number for the Second Pair of Snapshots

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

Using 2351142467 for Database Id for the second pair of snapshots

Using 1 for Instance Number for the second pair of snapshots

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 without

specifying a number lists all completed snapshots.

输入 num_days2 的值:

输入 num_days2 的值: 1

Listing the last day's Completed Snapshots

Snap

Instance DB Name Snap Id Snap Started Level

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

NBSTEST NBSTEST 10299 05 3月 2012 00:00 1

(篇幅原因,省略……

10306 05 3月 2012 07:00 1

10307 05 3月 2012 08:00 1

10308 05 3月 2012 09:00 1

Specify the Second Pair of Begin and End Snapshot Ids

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

输入 begin_snap2 的值:

--输入时间片

Specify the Second Pair of Begin and End Snapshot Ids

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

输入 begin_snap2 的值: 10306

Second Begin Snapshot Id specified: 10306

输入 end_snap2 的值: 10308

ü 指定生成报告名称,生成报告

Specify the Report Name

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

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

press to continue, otherwise enter an alternative.

输入 report_name 的值: --使用默认名称,保持为空

Using the report name awrdiff_1_10296_1_10306.html


Back to Top

Report written to awrdiff_1_10296_1_10306.html

在目录上,我们就可以发现我们生成的报告文件。

3、报告内容粗览

AWR报告不同,Compare Period Report强调对比。在所有的项目中,均以第一个和第二个进行对比,并且列出差异值。这对于我们进行负载对比等操作,有很多好处。

可以方便的让我们进行性能对比和调优前后对比。

4、结论

AWR报告以及其衍生产品,是我们进行性能调优、问题发现的重要工具武器。用好这些工具,是我们完成工作、履行责任和前进的重要前提。AWR Compare Period Report在进行基线对比和调优效果对比时,是非常方便的工具。

关于如何手工生成AWR运行期对比报告就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

0