oracle10g 性能调优之AWR篇(一)
来源:互联网 发布:数据库数据冗余 编辑:程序博客网 时间:2024/05/02 11:34
当数据库发生了性能问题时,如何去定位?作为一个DBA,持续的收集相关统计数据对于性能分析来说十分重要。oracle10g引入了自动工作量存储(Automatic Workload Repository AWR)技术,它不仅能收集统计数据,还能从统计数据中分析出度量数据。
数据库的性能分析,大致可以分为两个层面,会话级和系统级。
1)会话级,如果我们能够确定某个会话存在性能问题(也可能是某个用户向你提出一个操作缓慢的申请报告),我们就针对这个确定的会话做分析,最常见的是10046事件和sql_trace
2)实例级,但我们无法确定哪个会话性能时候,可以通过v$sysstat,v$system_events;查询整个性能情况,可能要查询很多方面的信息,sql、io、等待事件等等。
10g之前statspack工具是首选,10g里面,oracle提供了一个新的工具AWR。
1、查看和修改awr报告策略
来了解一下AWR是如何设计的,并了解一下它的构造。基本上来说,AWR应该是一个Oracle用来收集性能相关统计数据并从中得出性能度量数据来追踪潜在问题的内置工具。和statspack不一样,AWR的快照信息是由一个新的后台进程MMON及其线程来每隔一个小时自动收集的。为了节省空间,这些收集的数据会在7天后自动清除。快照收集的频率和保留时间都是可以被用户修改的。
可以通过以下脚本查看当前的设置:
SNAP_INTERVAL RETENTION
--------------- ------------------
+00000 01:00:00.0 +00007 00:00:00.0
这个结果表明当前的快照是每隔一个小时收集一次,并且会被保留7天。要改变这个设置,比如需要设置成每隔半小时收集一次,并且只保留8天,可以使用以下语句(参数的单位都是分):
SQL> desc dbms_workload_repository.modify_snapshot_settings ;
Parameter Type Mode Default?
--------- -------- ---- --------
RETENTION NUMBER IN Y
INTERVAL NUMBER IN Y
TOPNSQL NUMBER IN Y
DBID NUMBER IN Y
RETENTION NUMBER IN Y
INTERVAL NUMBER IN Y
TOPNSQL VARCHAR2 IN
DBID NUMBER IN Y
SQL> begin
2 dbms_workload_repository.modify_snapshot_settings (
3 interval => 30, --每隔30分钟,单位(分钟)
4 retention => 8*24*60 --保存天数为8天,单位(分钟)
5 );
6 end;
7 /
PL/SQL procedure successfully completed
2、现在,让我们手动生成awr报告
生成awr报告只要调动awrrpt.sql就可以了,
[oracle@SHOW-100-12 ~]$ sqlplus / as sysdba @/oracle/ora10g/product/db/rdbms/admin/awrrpt.sql
SQL*Plus: Release 10.2.0.4.0 - Production on Wed Dec 7 14:16:45 2011
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
2434995197 JSCN 1 jscn
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 --这里选择html格式,这样我们看起来比较方便。
Type Specified: html
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
* 2434995197 1 JSCN jscn SHOW-100-12
Using 2434995197 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: 10 --这里我们填的是十天,但是由于之情最多保存7天,让我们看一下,只有7天的数据。
Listing the last 10 days of Completed Snapshots
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
jscn JSCN 777 30 Nov 2011 08:00 1
778 30 Nov 2011 09:00 1
779 30 Nov 2011 10:00 1
780 30 Nov 2011 11:00 1
781 30 Nov 2011 12:00 1
...........................
928 06 Dec 2011 15:00 1
--这里有断点,说明这个时段数据库重启过,如果数据库重启过,横跨这个时段是不能分析的,不信,我们试试看。
929 06 Dec 2011 16:00 1
930 06 Dec 2011 17:00 1
931 06 Dec 2011 18:00 1
932 06 Dec 2011 19:00 1
933 06 Dec 2011 20:00 1
934 06 Dec 2011 21:00 1
935 06 Dec 2011 22:00 1
936 06 Dec 2011 23:00 1
937 07 Dec 2011 00:00 1
938 07 Dec 2011 01:00 1
939 07 Dec 2011 02:00 1
940 07 Dec 2011 03:00 1
941 07 Dec 2011 04:00 1
Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
jscn JSCN 942 07 Dec 2011 05:00 1
943 07 Dec 2011 06:00 1
944 07 Dec 2011 07:00 1
945 07 Dec 2011 08:00 1
946 07 Dec 2011 09:00 1
947 07 Dec 2011 10:00 1
948 07 Dec 2011 11:00 1
949 07 Dec 2011 12:00 1
950 07 Dec 2011 13:00 1
951 07 Dec 2011 14:00 1
试试看横跨断点是否能生成报告。
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 928
Begin Snapshot Id specified: 928
Enter value for end_snap: 929
End Snapshot Id specified: 929
declare
*
ERROR at line 1:
ORA-20200: The instance was shutdown between snapshots 928 and 929
ORA-06512: at line 42
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@SHOW-100-12 ~]$
看看报错了吧,现象还是能明显的。
让我们再试一次,这次重复的代码就不写出来了。
[oracle@SHOW-100-12 ~]$ sqlplus / as sysdba @/oracle/ora10g/product/db/rdbms/admin/awrrpt.sql
Enter value for report_type: html --还是选择html格式
Enter value for num_days: 10 --还是选择10天
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 929
Begin Snapshot Id specified: 929
Enter value for end_snap: 951
End Snapshot Id specified: 951
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_929_951.html. To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name: --名称我们默认就可以了
.........................
End of Report
</BODY></HTML>
Report written to awrrpt_1_929_951.html
SQL>
报告生成了。
下篇,我们让我们来分析awr报告
- oracle10g 性能调优之AWR篇(一)
- oracle10g 性能调优之AWR篇(二)
- Oracle性能调优 AWR分析一例
- Oracle10g的AWR性能优化工具介绍
- Oracle10g的AWR性能优化工具介绍
- Oracle10g下生成AWR性能报告步骤
- 【性能调优】Oracle AWR
- oracle性能调优之--Oracle 10g AWR 配置
- AWR之初体验-AWR报告分析(一)
- ORACLE10G性能调优学习
- 管理 AWR(一)
- 【性能调优】Oracle AWR报告指标全解析
- 【性能调优】Oracle AWR报告指标全解析
- 【性能调优】Oracle AWR报告指标全解析
- 数据库性能分析工具之AWR
- 【性能优化】 之AWR 报告分析
- AWR 报告分析(一)
- AWR报告分析(一)
- (25)CreateSolidBrush函数 .
- 深入浅出redis事件框架
- Vmware与主机间共享文件
- 异常与所缺失的jar包
- 如何在AppFuse项目中配置Oracle数据库
- oracle10g 性能调优之AWR篇(一)
- 理解Android的手势识别
- Hibernate环境搭建
- linux下使用DNW下载镜像-TQ2440
- Mantis一些应用技巧
- iis实现伪静态
- C#将泛型转换成JSON字符串
- 嘿嘿敢让保定学生挂科的看看后果
- 营养补充