手工生成AWR报告方法记录

时间:2024.5.2

手工生成AWR报告方法记录 2011-06-22 13:49:46

分类: Linux

AWR(Automatic Workload Repository)报告是我们进行日常数据库性能评定、问题SQL发现的重要手段。熟练掌握AWR报告,是做好开发、运维DBA工作的重要基本功。

AWR报告的原理是基于Oracle数据库的定时镜像功能。默认情况下,Oracle数据库后台进程会以一定间隔(一小时)收集系统当前状态镜像,并且保存在数据库中。生成AWR报告时,只需要指定进行分析的时间段(开始镜像编号和结束镜像编号),就可以生成该时间段的性能分析情况。AWR镜像保存在数据库中的时间为一个月左右。

目前Oracle10g之后,AWR报告取代了原先的Statspack报告成为一个主流性能分析报告。通常可以从OEM(Oracle Enterprise Manager Console)平台上生成查看AWR报告。在OEM中,使用图形化方法更加容易。本篇中介绍使用手工脚本方式生成AWR的方法,脱离OEM的限制。

1、 运行脚本

首先,准备一个目录作为AWR生成报告的路径。

[oracle@bspdev /]$ ls -l | grep test

drwxr-xr-x. 2 oracle oinstall 4096 Jun 21 13:01 test

[oracle@bspdev /]$ cd test

启动sqlplus等开发工具,调用生成脚本。程序脚本一般保存在$ORACLE_HOME下的rdbms/admin中,名称为awrrpt.sql。

[oracle@bspdev test]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Tue Jun 21 13:04:44 2011

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

SQL> conn / as sysdba

Connected.

--调用脚本,生成文件

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

之后进入报告参数输入模块。

2、输入报告参数

之后,要持续输入一系列的报告参数。

? 输入生成报告类型,目前AWR提供txt和html两种格式。需要确认生成格

式,默认是html格式。

Current Instance

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

DB Id DB Name Inst Num Instance

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

4143510747 ORA11G 1 ora11g

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'

? 报告涉及天数范围

启动报告后,会显示生成实例的名称等基本信息。

默认情况下,AWR会将镜像信息保留一个月。手工生成的时候,需要确认生成AWR报告的时间范围。一般情况下,特别是生产环境下,我们通常设置1-7天也就够用了。

Instances in this Workload Repository schema

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

DB Id Inst Num DB Name Instance Host ------------ -------- ------------ ------------ ------------

* 4143510747 1

ORA11G ora11g bspdev.local

domain

Using 4143510747 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: 3

? 输入开始和结束的snapshot编号

输入天数信息后,AWR生成代码会将天数范围内的snapshot镜像点列出,供输入选择。

Listing the last 3 days of Completed Snapshots

Snap

Instance DB Name Snap Id Snap

Started Level

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

ora11g ORA11G 1789 20 Jun 2011

13:01 1

1790 20 Jun 2011 14:00 1

1791 20 Jun 2011 15:00 1

1792 20 Jun 2011 16:00 1

(篇幅原因,有省略……)

1811 21 Jun 2011 11:00 1

1812 21 Jun 2011 12:00 1

1813 21 Jun 2011 13:00 1

Specify the Begin and End Snapshot Ids

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

之后,我们需要根据列出的时间范围,输入开始和结束的snap编号。

Specify the Begin and End Snapshot Ids

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

Enter value for begin_snap: 1796

Begin Snapshot Id specified: 1796

Enter value for end_snap: 1813

? 确定报告名称

最后就是确定生成报告的名称。一般采用默认的名称就可以了。

Specify the Report Name

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

The default report file name is awrrpt_1_1796_1813.html. To use this name, press <return> to continue, otherwise enter an alternative.

Enter value for report_name:

之后输出内容很多,此处不加以累述。最后提示报告生成成功。

Report written to awrrpt_1_1796_1813.html

于是,指定目录上可以看到相应的报告文件。

[oracle@bspdev test]$ ls -l

total 508

-rw-r--r--. 1 oracle oinstall 515262 Jun 21 13:10 awrrpt_1_1796_1813.html

3、说明两个问题

首先,此处生成的html格式的报表。如果要求生成txt格式,就在生成过程中选择text格式报表。

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: text

Type Specified: text

End of Report

Report written to awrrpt_1_1789_1800.txt

[oracle@bspdev test]$ ls -l

total 692

-rw-r--r--. 1 oracle oinstall 180601 Jun 21 13:27 awrrpt_1_1789_1800.txt -rw-r--r--. 1 oracle oinstall 515262 Jun 21 13:10 awrrpt_1_1796_1813.html

第二个就是调用脚本的方式问题。调用时使用的sqlplus客户端可以在Oracle服务器本机上(远程登录),也可以在客户端机器本机上。笔者建议是在客户端本机上进行生成,这样可以避免报告文件来回拷贝的工作。但是最好要保证客户端版本与服务器版本相匹配。

4、结论

手工生成AWR报告,可以避免受到OEM的限制约束,而且灵活度高。本篇记录,权当备忘。


第二篇:AWR生成方法汇总


AWR分析报告提取操作方法

oracle遇到性能问题时,性能分析的一个思路就是导出AWR分析报告,通过报告分析定位问题根源,以下是如何生成分析报告的步骤,AWR分析报告文件类型分为txt和html两种,习惯使用html。

准备工作:现在我们使用的都是11GR2的数据库,安装完成后什么都不需要任何修改。 操作说明:其中红色的部分为需要输入的内容。

Windows平台

C:\>sqlplus/nolg

C:\>sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on 星期三 9月 12 13:56:09 2012

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

SQL> conn sys/zlsoft@demo as sysdba

已连接。

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

Current Instance

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

DB Id DB Name Inst Num Instance

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

1270982830 DEMO 1 demo

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 的值: html

Type Specified: html

Instances in this Workload Repository schema

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

DB Id Inst Num DB Name Instance Host

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

1270982830 1 ORCL orcl USER01

* 1270982830 1 DEMO demo QW_TEST_SEVE

R

Using 1270982830 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.

输入 num_days 的值: 2

Listing the last 2 days of Completed Snapshots

Snap Instance DB Name Snap Id Snap Started Level ------------ ------------ --------- ------------------ -----

demo DEMO 12859 11 9月 2012 00:00 1 12860 11 9月 2012 01:00 1 12861 11 9月 2012 02:00 1 12862 11 9月 2012 03:00 1 12863 11 9月 2012 04:00 1 12864 11 9月 2012 05:00 1 12865 11 9月 2012 06:00 1 12866 11 9月 2012 07:00 1 12867 11 9月 2012 08:00 1 12868 11 9月 2012 09:00 1 12869 11 9月 2012 10:00 1 12870 11 9月 2012 11:00 1 12871 11 9月 2012 12:00 1 12872 11 9月 2012 13:00 1 12873 11 9月 2012 14:00 1 12874 11 9月 2012 15:00 1 12875 11 9月 2012 16:00 1 12876 11 9月 2012 17:00 1 12877 11 9月 2012 18:00 1 12878 11 9月 2012 19:00 1 12879 11 9月 2012 20:00 1 12880 11 9月 2012 21:00 1 12881 11 9月 2012 22:00 1 12882 11 9月 2012 23:00 1 12883 12 9月 2012 00:00 1 12884 12 9月 2012 01:00 1 12885 12 9月 2012 02:00 1 12886 12 9月 2012 03:00 1

12887 12 9月 2012 04:00 1

12888 12 9月 2012 05:00 1

12889 12 9月 2012 06:00 1

12890 12 9月 2012 07:00 1

12891 12 9月 2012 08:00 1

12892 12 9月 2012 09:00 1

12893 12 9月 2012 10:00 1

12894 12 9月 2012 11:00 1

12895 12 9月 2012 12:00 1

12896 12 9月 2012 13:00 1

Specify the Begin and End Snapshot Ids

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

输入 begin_snap 的值: 12884

Begin Snapshot Id specified: 12884

输入 end_snap 的值: 12895

End Snapshot Id specified: 12895

Specify the Report Name

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

The default report file name is awrrpt_1_12884_12895.html. To use this name, press<return> to continue, otherwise enter an alternative.

输入 report_name 的值: test.html

Using the report name test.html

另外一种方法

1:登陆对应的数据库服务器

2:找到oracle磁盘空间(d:oracle\product\10.2.0\db_1\RDBMS\Admin) 3:执行cmd-cd d:回车

4: cd d:oracle\product\10.2.0\db_1\RDBMS\Admin 回车

5:sqlplus 用户名/密码@服务连接名(例:sqlplus carmot_esz_1/carmot@igrp) 6:执行@awrrpt.sql 回车

解释:

第一步输入类型: html

第二步输入天数:天数自定义(如1,代表当天,如果2,代表今天和昨天。。。) 第三步输入开始值与结束值:(你可以看到上面列出的数据,snap值) 这个值输入开始,与结束

第四步输入导出表的名称:名称自定义回车

第五步,由程序自动导完。

linux下的操作

[root@linux5 /]# su – oracle:注意用户的选择

[oracle@linux5 ~]$ export ORACLE_SID=orcl:环境变量[oracle@linux5 ~]$export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"字符集,可选

[oracle@linux5 admin]$ sqlplus /nolog

SQL>conn sys/XXX@ORCL as sysdba

已连接.

SQL>@?/rdbms/admin/awrrpt.sql Current Instance

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

DB Id DB Name Inst Num Instance

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

1260101618 ORCL 1 orcl

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 “选择报告输出的文件类型”

Type Specified:html

Instances in this Workload Repository schema

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DB Id Inst Num DB Name Instance Host

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

* 1260101618 1 ORCL orcl linux5

Using 1260101618 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: 3 “报告输出的时间范围选择”

Listing the last 3 days of Completed Snapshots

Snap

Instance DB Name Snap Id Snap Started Level

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

orcl ORCL 1 13 Oct 2010 23:00 1

2 14 Oct 2010 00:00 1

3 14 Oct 2010 01:00 1

4 14 Oct 2010 02:00 1

5 14 Oct 2010 03:00 1

6 14 Oct 2010 04:00 1 7 14 Oct 2010 05:00 1

8 14 Oct 2010 06:00 1

9 14 Oct 2010 07:00 1

Specify the Begin and End Snapshot Ids

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

“选择获取报告的快照范围”

Enter value for begin_snap: 2

Begin Snapshot Id specified: 2

Enter value for end_snap: 9

End Snapshot Id specified: 9

Specify the Report Name

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

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

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

“输出分析报告文件”

Enter value for report_name: /opt/awrrpt.html

简单方法(远程登录)

在使用linux的环境下,当我们对linux不是很熟悉的情况下就可以用调用脚本的方式解决问题。使用在安装sqlplus客户端的WINDOWS机器上远程登录Oracle服务器,运行在在客户端机器本机上。建议是在客户端本机上进行生成,这样报告文件可以在客户端机器上生成AWR报告。但是最好要保证客户端版本与服务器版本相匹配。

操作方法就是和Windows下的操作一样(略)。

更多相关推荐:
用两种方法生成awr报告

u01apporacleproduct1120dbhome1rdbmsadminawrrptsql脚本生成awr报告在SQL环境执行SQLgtu01apporacleproduct1120dbhome1rdbm...

生成报告模板

溃坝风险分析软件报告一数据时间20xx0711130020xx0711190020xx0712010020xx0712070020xx0712130020xx0712190020xx0713010020xx07...

ANSYS HTML报告生成器

liusjANSYSHTML报告生成器ANSYS专利技术即基于WEB技术的报告生成技术为分析工程师带来了很大的方便这在ANSYS的DesignSpace和Professional中得到了很好的体现从ANSYS5...

ORACLE AWR报告生成步骤

ORACLEAWR报告生成步骤以PLSQL中命令窗口为例1sqlplus或plsql的commod窗口命令窗口运行命令Doracleproduct1020db1RDBMSADMINawrrptsql然后在弹出的...

ASH报告生成详解

1参看AWR报告生成详解doc2切换用户rootxlserver10suoracle注意后面有空格oracle为用户名3oraclexlserver10pwd4oraclexlserver10cdoptorac...

OracleAWR报告生成

oracle遇到性能问题时性能分析的一个思路就是导出AWR分析报告通过报告分析定位问题根源以下是oracle10g如何生成分析报告的步骤oracle10gAWR分析报告文件类型分为txt和html两种本人习惯使...

如何生成生成课题引文报告

无论是进行科研立项还是开题报告您常常需要从宏观上把握国内外某一研究领域或专题的总体研究趋势如何快速获取这些信息呢您可以通过生成课题引文报告或分析论文出版年的方式有效获得1访问WebofScience数据库检索论...

计算机图形学 实验一直线生成算法报告

实验一直线生成算法一实验目的及要求1学习C语言的基本绘图方法2实习直线基本生成算法3了解光栅图形显示器的工作原理和特点4掌握课本所介绍的图形算法的原理和实现5基于光栅图形显示器在c环境中使用基本图形生成算法画根...

最小生成树实验报告

北京理工大学软件学院一实验目的1通过上机程序进一步加深对最小生成树的理解2掌握Kruskal算法3学会用程序解决离散数学中的问题4增强我们编写程序的能力二实验内容求带权无向联通平面图的最小生成树三实验环境我的实...

生涯计划书自动生成报告

o一旦全身心地投入一项工作时你往往发挥出冲刺式的干劲全神贯注全力以赴你仰赖人事和思想信仰一般能够忠实履行自己的义务但是对意义不大的日常事务你做起来可能有些困难生活中的你o信奉理想至上o穿衣风格你喜欢塑造个性的形...

最小生成树数据结构实验报告

摘要最小生成树是数据结构中图的一种重要应用在图中对于n个顶点的连通网可以建立许多不同的生成树最小生成树就是在所有生成树中总的权值最小的生成树本课程设计是以邻接矩阵作为图的存储结构分别采用Prim和Kruskal...

自动化生产线的安装调试结业报告运输站部分

自动化生产线安装与调试报告课程名称实训班级小组成员指导教师完成日期目录一绪论1二亚龙YL335B试验台的基本组成和工作原理2三相应站的整体介绍631主站的动作顺序和作用632供料站的动作顺序和作用733加工站的...

生成报告(36篇)