AWR生成步骤

这篇博客详细介绍了如何在命令行中通过SQL脚本生成AWR(Automatic Workload Repository)报告,包括不同类型的AWR报告如awrrpt.sql、awrrpti.sql等,以及具体的生成步骤,包括选择报表类型、实例、快照区间和报告名称。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

AWR  是通过对比两次快照(snapshot)收集到的统计信息,来生成报表数据,生成的报表包括多个部分,这点与Statspack生成的报告非常类似。不过AWR在生成报告时,可以选择生成TXT或HTML两种格式的报告,相对来说,HTML更利于阅读,而TXT的适用性更广(即使在不能使用浏览器的机器上也能看)。

  操作过Statspack的朋友都还记的,生成报告使用$ORACLE_HOME/rdbms/admin/spreport.sql脚本,到了AWR这片,操作步骤基本上相同,不过生成报告的脚本多了很多选择,包括:

  • awrrpt.sql :生成指定快照区间的统计报表;
  • awrrpti.sql :生成指定数据库实例,并且指定快照区间的统计报表;
  • awrsqlrpt.sql :生成指定快照区间,指定SQL语句(实际指定的是该语句的SQLID)的统计报表;
  • awrsqrpi.sql :生成指定数据库实例,指定快照区间的指定SQL语句的统计报表;
  • awrddrpt.sql :指定两个不同的时间周期,生成这两个周期的统计对比报表;
  • awrddrpi.sql :指定数据库实例,并指定两个的不同时间周期,生成这两个周期的统计对比报表;

报表的生成流程如下:

(1)进入命令行,切换到自己的工作目录:

Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>d:

D:\>

说明:此处切换目录是为了设定生成报表文件的存放位置。

(2)使用sqlplus命令行工具登录连接数据库

Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options

D:\>sqlplus /nolog

SQL*Plus: Release 10.1.0.2.0 - Production on 星期四 5月 20 16:48:19 2010

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

SQL> conn studydb/studydb@studydb

Connected.
SQL>

(3)运行生成报表SQL文件:@D:\oracle\product\10.1.0\Db_1\RDBMS\ADMIN\awrrpt.sql

SQL> @D:\oracle\product\10.1.0\Db_1\RDBMS\ADMIN\awrrpt.sql

Current Instance
~~~~~~~~~~~~~~~~

   DB Id    DB Name      Inst Num Instance
----------- ------------ -------- ------------
 2514848645 STUDYDB             1 studydb


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
------------ -------- ------------ ------------ ------------
* 2514848645        1 STUDYDB      studydb      MIN

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

 

Listing the last 3 days of Completed Snapshots

                                                        Snap
Instance     DB Name        Snap Id    Snap Started    Level
------------ ------------ --------- ------------------ -----
studydb      STUDYDB            271 19 5月  2014 14:15     1

                                272 19 5月  2014 15:00     1
                                273 19 5月  2014 16:00     1
                                274 19 5月  2014 17:00     1
                                275 19 5月  2014 18:00     1

                                276 20 5月  2014 09:03     1
                                277 20 5月  2014 10:00     1
                                278 20 5月  2014 11:00     1

                                279 20 5月  2014 14:09     1
                                280 20 5月  2014 15:00     1
                                281 20 5月  2014 16:01     1

 

Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 279
Begin Snapshot Id specified: 279

Enter value for end_snap: 281
End   Snapshot Id specified: 281

 

Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_279_281.html.  To use this name,
press <return> to continue, otherwise enter an alternative.

Enter value for report_name:  //输入生成的文件名称默认值为:awrrpt_1_279_281.html

.........................//生成过程省略

End of Report
</BODY></HTML>
Report written to awrrpt_1_279_281.html
SQL>

(4)报表生成完成

### 解决 IntelliJ IDEA 中 `@Autowired` 注解导致的红色波浪线错误 在使用 Spring 框架时,如果遇到 `@Autowired` 注解下的依赖注入对象显示为红色波浪线错误或者黄色警告的情况,通常是由以下几个原因引起的: #### 1. **Spring 插件未启用** 如果 Spring 支持插件未被激活,则可能导致 IDE 无法识别 `@Autowired` 或其他 Spring 特定的功能。可以通过以下方式解决问题: - 打开设置菜单:`File -> Settings -> Plugins`。 - 确认已安装并启用了名为 “Spring Framework Support” 的官方插件[^1]。 #### 2. **项目配置文件缺失或不正确** Spring 需要通过 XML 文件、Java Config 类或其他形式来定义 Bean 定义。如果没有正确加载这些配置文件,可能会导致 `@Autowired` 报错。 - 确保项目的 `applicationContext.xml` 或者基于 Java 的配置类(带有 `@Configuration` 和 `@Bean` 注解)已被正确定义和引入。 - 对于 Spring Boot 项目,确认是否存在 `spring.factories` 文件以及是否包含了必要的组件扫描路径[^3]。 #### 3. **模块依赖关系问题** 当前模块可能缺少对 Spring Core 或 Context 组件库的有效引用。这可能是由于 Maven/Gradle 构建工具中的依赖项声明不足造成的。 - 检查 `pom.xml` (Maven) 或 `build.gradle` (Gradle),确保包含如下核心依赖之一: ```xml <!-- For Maven --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> ``` ```gradle // For Gradle implementation 'org.springframework:spring-context:${springVersion}' ``` - 更新项目依赖树以应用更改:右键点击项目根目录 -> `Maven -> Reload Project` 或运行命令 `./gradlew build --refresh-dependencies`。 #### 4. **IDE 缓存损坏** Intellij IDEA 的缓存机制有时会因各种因素而失效,从而引发误报错误。清除缓存可以有效缓解此类情况。 - 使用快捷组合键 `Ctrl + Alt + Shift + S` 进入项目结构对话框;也可以尝试执行操作序列:`File -> Invalidate Caches / Restart... -> Invalidate and Restart`. #### 5. **启动异常影响正常解析** 若之前存在类似 `com.intellij.diagnostic.PluginException` 的严重初始化失败日志记录,则表明某些关键服务未能成功加载,进而干扰到后续功能表现[^2]。建议重新下载最新稳定版本的 IDEA 并按照标准流程完成初次部署工作。 ```java // 示例代码片段展示如何正确运用 @Autowired 注解实现自动装配 @Service public class StudentService { private final Repository repository; public StudentService(@Qualifier("specificRepository") Repository repo){ this.repository = repo; } } @Component class SpecificComponent{ @Autowired private transient StudentService studentService; // 此处应无任何编译期告警现象发生 } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值