一、AWE报告生成步骤

对于SQL调优,局部SQL,我们可以直接使用执行计划等直接调优,而对于整个系统来说?这时候就可以用Oracle系统自带的报告对系统进行整体分析了,Oracle提供好几种性能分析的报告,比如AWR、ASH、ADDM等等

这篇博客主要介绍AWR

AWR全称Automatic Workload Repository,自动负载信息库,是Oracle 10g版本后推出的一种性能收集和分析工具,提供了一个时间段内整个系统的报表数据。通过AWR报告,可以分析指定的时间段内数据库系统的性能。

1.1 工具选择

对于Oracle数据库可以使用sqlplus或者plsql developer客户端软件

sqlplus 使用

可以使用sqlplus工具登录

进入数据库

  1. sqlplus / as sysdba

查看用户

  1. show parameter db_name

用登录之后才可以使用

plsql developer使用

plsql developer也可以使用,登录之后,选择文件(File)->新建(New)->命令窗口(Command Window)

1.2 自动创建快照

开始压测后执行

  1. exec DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();

可以通过dba_hist_wr_control查看当前的配置情况,当前awr为每1小时做一次数据快照,保留时间为8天。

  1. select * from dba_hist_wr_control;



修改配置,每隔30分钟收集一次,保存1天

  1. execute dbms_workload_repository.modify_snapshot_settings(interval=>30,retention=>14000);

关闭AWR自动收集

  1. SQL>exec dbms_workload_repository.modify_snapshot_settings (interval=>0,retention=>24*60);

注:10g默认是自动开启awr信息收集的,会对系统有一定的影响(很小);如果要关闭awr信息收集,只需设置interval参数为0即可。但interval设0后,AWR报告无法生成。

1.3 手工创建快照

除了自动创建快照,也可以手工创建快照

  1. select dbms_workload_repository.create_snapshot() from dual;

1.4 生成AWR报告

在sqlplus或者plsql使用命令,${ORACLE_HOME}是Oracle的安装路径

  1. @/${ORACLE_HOME}/.../RDBMS/ADMIN/awrrpt.sql

例如我的命令为:

  1. @D:/oracle/product/11.1.0/db_1/RDBMS/ADMIN/awrrpt.sql

sqlplus登录的可以使用

  1. @?/rdbms/admin/awrrpt/awrrpt.sql

@?/rdbms/admin/awrrpt; 本实例AWR包括:

@?/rdbms/admin/awrrpti; RAC中选择实例号

@?/rdbms/admin/awrddrpt; AWR 比对报告

@?/RDBMS/admin/awrgrpt; RAC全局AWR报告

执行命令之后,会提示你输入一些参数

  • (1) Enter value of report_type

    意思是生成报告的格式有两种,html和txt,这里选择html
  • (2) Enter value of num_days

    收集几天的报告信息,数字,可以输入1
  • (3) Enter value of begin_snap

    输入开始快照id,要根据日志打印的快照id范围来填

例如我实验时候,日志打印的快照id范围为:6727 ~6745


  1. Listing the last day's Completed Snapshots
  2. INST_NAME DB_NAME SNAP_ID SNAPDAT LV
  3. ------------ ------------ -------- ------------------ --
  4. orcl ORCL 6727 17 4月 2019 00:00 1
  5. orcl ORCL 6728 17 4月 2019 01:00 1
  6. orcl ORCL 6729 17 4月 2019 02:00 1
  7. orcl ORCL 6730 17 4月 2019 03:00 1
  8. orcl ORCL 6731 17 4月 2019 04:00 1
  9. orcl ORCL 6732 17 4月 2019 05:00 1
  10. orcl ORCL 6733 17 4月 2019 06:00 1
  11. orcl ORCL 6734 17 4月 2019 07:00 1
  12. orcl ORCL 6735 17 4月 2019 08:00 1
  13. orcl ORCL 6736 17 4月 2019 09:00 1
  14. orcl ORCL 6737 17 4月 2019 10:00 1
  15. orcl ORCL 6738 17 4月 2019 11:00 1
  16. orcl ORCL 6739 17 4月 2019 12:00 1
  17. orcl ORCL 6740 17 4月 2019 13:00 1
  18. orcl ORCL 6741 17 4月 2019 14:00 1
  19. orcl ORCL 6742 17 4月 2019 14:13 1
  20. orcl ORCL 6743 17 4月 2019 14:15 1
  21. orcl OANET 6744 17 4月 2019 14:16 1
  22. orcl OANET 6745 17 4月 2019 14:40 1

所以我随意填写:6743

  • (4) Enter value of end_snap

    输入结束快照id,要根据日志打印的快照id范围来填,所以我随意填写:6745
  1. SQL> @D:/oracle/product/11.1.0/db_1/RDBMS/ADMIN/awrrpt.sql
  2. Current Instance
  3. ~~~~~~~~~~~~~~~~
  4. DBID DB_NAME INST_ INST_NAME
  5. ---------- ------------ ----- ------------
  6. 4279242421 ORCL 1 orcl
  7. rpt_options
  8. ---------
  9. 0
  10. Specify the Report Type
  11. ~~~~~~~~~~~~~~~~~~~~~~~
  12. Would you like an HTML report, or a plain text report?
  13. Enter 'html' for an HTML report, or 'text' for plain text
  14. Defaults to 'html'
  15. Type Specified: html
  16. Cannot SET TRIMSPOOL
  17. Cannot SET UNDERLINE
  18. Instances in this Workload Repository schema
  19. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  20. DBBID INSTT DBB_NAME INSTT_NAME HOST
  21. ------------ ----- ------------ ------------ ------------
  22. * 4279242421 1 ORCL ORCL zwdb
  23. Using 4279242421 for database Id
  24. Using 1 for instance number
  25. dbid
  26. ---------
  27. 4279242421
  28. inst_num
  29. ---------
  30. 1
  31. inst_num
  32. ---------
  33. 1
  34. dbid
  35. ---------
  36. 4279242421
  37. max_snap_time
  38. ---------
  39. 17/04/2019
  40. Specify the number of days of snapshots to choose from
  41. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  42. Entering the number of days (n) will result in the most recent
  43. (n) days of snapshots being listed. Pressing <return> without
  44. specifying a number lists all completed snapshots.
  45. Listing the last day's Completed Snapshots
  46. INST_NAME DB_NAME SNAP_ID SNAPDAT LV
  47. ------------ ------------ -------- ------------------ --
  48. orcl ORCL 6727 17 4月 2019 00:00 1
  49. orcl ORCL 6728 17 4月 2019 01:00 1
  50. orcl ORCL 6729 17 4月 2019 02:00 1
  51. orcl ORCL 6730 17 4月 2019 03:00 1
  52. orcl ORCL 6731 17 4月 2019 04:00 1
  53. orcl ORCL 6732 17 4月 2019 05:00 1
  54. orcl ORCL 6733 17 4月 2019 06:00 1
  55. orcl ORCL 6734 17 4月 2019 07:00 1
  56. orcl ORCL 6735 17 4月 2019 08:00 1
  57. orcl ORCL 6736 17 4月 2019 09:00 1
  58. orcl ORCL 6737 17 4月 2019 10:00 1
  59. orcl ORCL 6738 17 4月 2019 11:00 1
  60. orcl ORCL 6739 17 4月 2019 12:00 1
  61. orcl ORCL 6740 17 4月 2019 13:00 1
  62. orcl ORCL 6741 17 4月 2019 14:00 1
  63. orcl ORCL 6742 17 4月 2019 14:13 1
  64. orcl ORCL 6743 17 4月 2019 14:15 1
  65. orcl OANET 6744 17 4月 2019 14:16 1
  66. orcl OANET 6745 17 4月 2019 14:40 1
  67. dbid
  68. ---------
  69. 4279242421
  70. inst_num
  71. ---------
  72. 1
  73. max_snap_time
  74. ---------
  75. 17/04/2019
  76. Specify the Begin and End Snapshot Ids
  77. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  78. Begin Snapshot Id specified: 6743
  79. End Snapshot Id specified: 6745
  80. bid
  81. ---------
  82. 6743
  83. eid
  84. ---------
  85. 6745
  86. inst_num
  87. ---------
  88. 1
  89. dbid
  90. ---------
  91. 4279242421
  92. bid
  93. ---------
  94. 6743
  95. eid
  96. ---------
  97. 6745
  98. Cannot SET TRIMSPOOL
  99. Cannot SET UNDERLINE
  100. Specify the Report Name
  101. ~~~~~~~~~~~~~~~~~~~~~~~
  102. The default report file name is awrrpt_1_6743_6745.html. To use this name,
  103. press <return> to continue, otherwise enter an alternative.
  104. Using the report name awr.html
  105. Started spooling to D:\Program Files\PLSQL Developer 8.0.3.1510\awr.html

二、AWR报告分析

2.1 AWR之DB Time

DB Time主要用来判断当前系统有没有相关瓶颈,是否较为频繁访问系统导致等待时间很长?然后要怎么看?一般来说,Elapsed时间乘以CPU个数如果大于DB Time,就是正常的,系统压力不大,反之就说明压力较大,例子如图,24.93*8很明显大于0.49,所以说明系统压力很小

2.2 AWR之load_profile

load_profile指标主要用来显示当前系统的一些指示性能的总体参数,这里介绍一些Redo_size,用来显示平均每秒的日志尺寸和平均每个事务的日志尺寸,有时候可以结合Transactions这个每秒事务数,分析当前事务的繁忙程度

如图,平均每秒的事务数Transactions非常小,说明系统压力非常小,一般来说Transactions不超过200都是正常的,或者200左右都是正常的,超过1000就是非常繁忙了,再看看平均每秒的日志尺寸是4位数的,平均每个事务的日志尺寸是5位数的,说明了系统访问不是很频繁,而单个业务是比较复杂的,如果反过来,平均每秒日志尺寸比平均每秒事务日志尺寸大很多,说明系统访问很频繁,而业务比较简单,不需要响应很久

2.3 AWR之efficiency percentages

efficiency percentages是一些命中率指标。Buffer Hint、Library Hint等表示SGA(System global area)的命中率;Soft Parse指标表示共享池的软解析率,如果小于90%,就说明存在未绑定变量的情况

2.4 AWR之top 10 events

Top 10 Foreground Events by Total Wait Time,等待事件是衡量数据库优化情况的重要指标,通过观察Event和%DB time两列就可以直观看出当前数据库的主要等待事件

如图可以看出系统面试的主要是CPU被占用太多了和锁等待

### 2.5 AWR之SQL Statistics

SQL Statistics从几个维度列举了系统执行比较慢的SQL,可以点击,然后拿SQL去调优,调优SQL可以用执行计划看看

对于AWR的性能指标还有很多,本博客是看了《收获,不止SQL优化》一书的笔记,这里只简单介绍一些比较重要的指标

Oracle AWR报告生成和性能分析的更多相关文章

  1. Oracle AWRDD报告生成和性能分析

    我写的SQL调优专栏:https://blog.csdn.net/u014427391/article/category/8679315 对于局部的,比如某个页面列表sql,我们可以使用Oracle的 ...

  2. Oracle ADDM报告生成和性能分析

    我写的SQL调优专栏:https://blog.csdn.net/u014427391/article/category/8679315 对于局部的,比如某个页面列表sql,我们可以使用Oracle的 ...

  3. Oracle AWRSQRPT报告生成和性能分析

    我写的SQL调优专栏:https://blog.csdn.net/u014427391/article/category/8679315 对于局部的,比如某个页面列表sql,我们可以使用Oracle的 ...

  4. Oracle ASH报告生成和性能分析

    我写的SQL调优专栏:https://blog.csdn.net/u014427391/article/category/8679315 对于局部的,比如某个页面列表sql,我们可以使用Oracle的 ...

  5. ORACLE AWR报告生成步骤

    ORACLE AWR报告生成步骤 (以PL/SQL中命令窗口为例) 1.sqlplus或plsql的commod窗口(命令窗口)运行命令 @D:\oracle\product\10.2.0\db_1\ ...

  6. [转]oracle awr报告生成和分析

    转自:http://blog.csdn.net/cuker919/article/details/8767328 最近由于数据库cpu占用非常高,导致VCS常常自动切换,引起很多问题. 最近学习一下数 ...

  7. Oracle awr报告生成操作步骤

    1.登录主机切换到oracle用户 ssh root@192.168.220.128 su - oracle 2.以sysdba身份登录数据库 sqlplus / as sysdba 3.执行@?/r ...

  8. 快速熟悉 Oracle AWR 报告解读

    目录 AWR报告简介 AWR报告结构 基本信息 Report Summary Main Report RAC statistics Wait Event Statistics 参考资料 本文面向没有太 ...

  9. (原创)如何在性能测试中自动生成并获取Oracle AWR报告

    版权声明:本文为原创文章,转载请先联系并标明出处 由于日常使用最多的数据库为Oracle,因此,最近又打起了Oracle的AWR报告的主意. 过去我们执行测试,都是执行开始和结束分别手动建立一个快照, ...

随机推荐

  1. github代码搜索技巧

    github是一个非常丰富的资源,但是面对这丰富的资源很多人不知到怎么使用,更谈不上怎么贡献给他,我们需要使用github就要学习使用他的方法,学会了使用的方法,接受了他的这种观点我们才会慢慢的给他贡 ...

  2. Android 实现个性的ViewPager切换动画 实战PageTransformer(兼容Android3.0以下)

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/40411921,本文出自:[张鸿洋的博客] 1.概述 之前写过一篇博文:Andro ...

  3. JVM学习记录-垃圾收集器

    先回顾一下上一篇介绍的JVM中常见几种垃圾收集算法: 标记-清除算法(Mark-Sweep). 复制算法(Copying). 标记整理算法(Mark-Compact). 分代收集算法(Generati ...

  4. python抓取数据构建词云

    1.词云图 词云图,也叫文字云,是对文本中出现频率较高的"关键词"予以视觉化的展现,词云图过滤掉大量的低频低质的文本信息,使得浏览者只要一眼扫过文本就可领略文本的主旨. 先看几个词 ...

  5. disk.go

    package disk import "syscall" //空间使用结构体 type DiskStatus struct {     Size uint64     Used ...

  6. fileWriter.go

    package blog4go import ( "fmt" "path" "strings" ) // NewFileWriter ini ...

  7. 连续查询(Continuous Queries)

    当数据超过保存策略里指定的时间之后,就会被删除.如果我们不想完全删除掉,比如做一个数据统计采样:把原先每秒的数据,存为每小时的数据,让数据占用的空间大大减少(以降低精度为代价). 这就需要Influx ...

  8. 基于 Maven 的多模块 Java ( Spring ) 项目构建

    索引: 开源Spring解决方案--lm.solution 参看代码 GitHub: solution/pom.xml pojo/pom.xml mapper/pom.xml common/pom.x ...

  9. 用Service+Broadcast解决倒计时过程中Activity被销毁的问题

    主要思想是这样的:将倒计时CountDownTimer放在Service里面进行,每过一秒就一条发广播,在主Activity里注册广播,收到广播后更新UI. 一.写一个类CodeTimerServic ...

  10. Maven安装教程详解

    一.准备工作 1.确定电脑上已经成功安装jdk7.0以上版本                 2.win10操作系统                 3.maven安装包            下载地 ...