Oracle AWR报告生成和性能分析
目录
一、AWE报告生成步骤对于SQL调优,局部SQL,我们可以直接使用执行计划等直接调优,而对于整个系统来说?这时候就可以用Oracle系统自带的报告对系统进行整体分析了,Oracle提供好几种性能分析的报告,比如AWR、ASH、ADDM等等 AWR全称Automatic Workload Repository,自动负载信息库,是Oracle 10g版本后推出的一种性能收集和分析工具,提供了一个时间段内整个系统的报表数据。通过AWR报告,可以分析指定的时间段内数据库系统的性能。 1.1 工具选择对于Oracle数据库可以使用sqlplus或者plsql developer客户端软件 sqlplus / as sysdba 查看用户 show parameter db_name 用登录之后才可以使用 1.2 自动创建快照开始压测后执行 exec DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT (); 可以通过dba_hist_wr_control查看当前的配置情况,当前awr为每1小时做一次数据快照,保留时间为8天。 select * from dba_hist_wr_control; 修改配置,每隔30分钟收集一次,保存1天 execute dbms_workload_repository.modify_snapshot_settings(interval=>30,retention=>14000); 关闭AWR自动收集 SQL>exec dbms_workload_repository.modify_snapshot_settings (interval=>0,retention=>24*60); 注:10g默认是自动开启awr信息收集的,会对系统有一定的影响(很小);如果要关闭awr信息收集,只需设置interval参数为0即可。但interval设0后,AWR报告无法生成。 1.3 手工创建快照除了自动创建快照,也可以手工创建快照 select dbms_workload_repository.create_snapshot() from dual; 1.4 生成AWR报告在sqlplus或者plsql使用命令,${ORACLE_HOME}是Oracle的安装路径 @/${ORACLE_HOME}/.../RDBMS/ADMIN/awrrpt.sql 例如我的命令为: @D:/oracle/product/11.1.0/db_1/RDBMS/ADMIN/awrrpt.sql sqlplus登录的可以使用 @?/rdbms/admin/awrrpt/awrrpt.sql @?/rdbms/admin/awrrpt; 本实例AWR包括: 执行命令之后,会提示你输入一些参数
例如我实验时候,日志打印的快照id范围为:6727 ~6745 Listing the last day‘s Completed Snapshots INST_NAME DB_NAME SNAP_ID SNAPDAT LV ------------ ------------ -------- ------------------ -- orcl ORCL 6727 17 4月 2019 00:00 1 orcl ORCL 6728 17 4月 2019 01:00 1 orcl ORCL 6729 17 4月 2019 02:00 1 orcl ORCL 6730 17 4月 2019 03:00 1 orcl ORCL 6731 17 4月 2019 04:00 1 orcl ORCL 6732 17 4月 2019 05:00 1 orcl ORCL 6733 17 4月 2019 06:00 1 orcl ORCL 6734 17 4月 2019 07:00 1 orcl ORCL 6735 17 4月 2019 08:00 1 orcl ORCL 6736 17 4月 2019 09:00 1 orcl ORCL 6737 17 4月 2019 10:00 1 orcl ORCL 6738 17 4月 2019 11:00 1 orcl ORCL 6739 17 4月 2019 12:00 1 orcl ORCL 6740 17 4月 2019 13:00 1 orcl ORCL 6741 17 4月 2019 14:00 1 orcl ORCL 6742 17 4月 2019 14:13 1 orcl ORCL 6743 17 4月 2019 14:15 1 orcl OANET 6744 17 4月 2019 14:16 1 orcl OANET 6745 17 4月 2019 14:40 1 所以我随意填写:6743
SQL> @D:/oracle/product/11.1.0/db_1/RDBMS/ADMIN/awrrpt.sql Current Instance ~~~~~~~~~~~~~~~~ DBID DB_NAME INST_ INST_NAME ---------- ------------ ----- ------------ 4279242421 ORCL 1 orcl rpt_options --------- 0 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‘ Type Specified: html Cannot SET TRIMSPOOL Cannot SET UNDERLINE Instances in this Workload Repository schema ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DBBID INSTT DBB_NAME INSTT_NAME HOST ------------ ----- ------------ ------------ ------------ * 4279242421 1 ORCL ORCL zwdb Using 4279242421 for database Id Using 1 for instance number dbid --------- 4279242421 inst_num --------- 1 inst_num --------- 1 dbid --------- 4279242421 max_snap_time --------- 17/04/2019 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 day‘s Completed Snapshots INST_NAME DB_NAME SNAP_ID SNAPDAT LV ------------ ------------ -------- ------------------ -- orcl ORCL 6727 17 4月 2019 00:00 1 orcl ORCL 6728 17 4月 2019 01:00 1 orcl ORCL 6729 17 4月 2019 02:00 1 orcl ORCL 6730 17 4月 2019 03:00 1 orcl ORCL 6731 17 4月 2019 04:00 1 orcl ORCL 6732 17 4月 2019 05:00 1 orcl ORCL 6733 17 4月 2019 06:00 1 orcl ORCL 6734 17 4月 2019 07:00 1 orcl ORCL 6735 17 4月 2019 08:00 1 orcl ORCL 6736 17 4月 2019 09:00 1 orcl ORCL 6737 17 4月 2019 10:00 1 orcl ORCL 6738 17 4月 2019 11:00 1 orcl ORCL 6739 17 4月 2019 12:00 1 orcl ORCL 6740 17 4月 2019 13:00 1 orcl ORCL 6741 17 4月 2019 14:00 1 orcl ORCL 6742 17 4月 2019 14:13 1 orcl ORCL 6743 17 4月 2019 14:15 1 orcl OANET 6744 17 4月 2019 14:16 1 orcl OANET 6745 17 4月 2019 14:40 1 dbid --------- 4279242421 inst_num --------- 1 max_snap_time --------- 17/04/2019 Specify the Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Begin Snapshot Id specified: 6743 End Snapshot Id specified: 6745 bid --------- 6743 eid --------- 6745 inst_num --------- 1 dbid --------- 4279242421 bid --------- 6743 eid --------- 6745 Cannot SET TRIMSPOOL Cannot SET UNDERLINE Specify the Report Name ~~~~~~~~~~~~~~~~~~~~~~~ The default report file name is awrrpt_1_6743_6745.html. To use this name,press <return> to continue,otherwise enter an alternative. Using the report name awr.html Started spooling to D:Program FilesPLSQL Developer 8.0.3.1510awr.html 二、AWR报告分析2.1 AWR之DB TimeDB Time主要用来判断当前系统有没有相关瓶颈,是否较为频繁访问系统导致等待时间很长?然后要怎么看?一般来说,Elapsed时间乘以CPU个数如果大于DB Time,就是正常的,系统压力不大,反之就说明压力较大,例子如图,24.93*8很明显大于0.49,所以说明系统压力很小 2.2 AWR之load_profileload_profile指标主要用来显示当前系统的一些指示性能的总体参数,这里介绍一些Redo_size,用来显示平均每秒的日志尺寸和平均每个事务的日志尺寸,有时候可以结合Transactions这个每秒事务数,分析当前事务的繁忙程度 如图,平均每秒的事务数Transactions非常小,说明系统压力非常小,一般来说Transactions不超过200都是正常的,或者200左右都是正常的,超过1000就是非常繁忙了,再看看平均每秒的日志尺寸是4位数的,平均每个事务的日志尺寸是5位数的,说明了系统访问不是很频繁,而单个业务是比较复杂的,如果反过来,平均每秒日志尺寸比平均每秒事务日志尺寸大很多,说明系统访问很频繁,而业务比较简单,不需要响应很久 2.3 AWR之efficiency percentagesefficiency percentages是一些命中率指标。Buffer Hint、Library Hint等表示SGA(System global area)的命中率;Soft Parse指标表示共享池的软解析率,如果小于90%,就说明存在未绑定变量的情况 2.4 AWR之top 10 eventsTop 10 Foreground Events by Total Wait Time,等待事件是衡量数据库优化情况的重要指标,通过观察Event和%DB time两列就可以直观看出当前数据库的主要等待事件 SQL Statistics从几个维度列举了系统执行比较慢的SQL,可以点击,然后拿SQL去调优,调优SQL可以用执行计划看看 对于AWR的性能指标还有很多,本博客是看了《收获,不止SQL优化》一书的笔记,这里只简单介绍一些比较重要的指标 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 关于PostgreSQL数据库中的information_schema
- ruby-on-rails – Rails控制器命名空间
- ruby-on-rails – Rails管理员修改列表/显示视图
- ruby-on-rails – Ruby on Rails表单页面缓存,包
- Flex:使弹出的窗口使用Canvas可以拖拽
- C17中是否使用“std :: is_invocable”替换“std
- c# – 依赖注入 – 当你有很多依赖关系时该怎么办
- 正则表达式 – 使用sed在文件之前将文件内容插入
- Flex:JavaScript写AIR程序>> 面向JavaScript开发
- c# – Swagger API没有刷新文档