ORACLE AWR报告生成过程出现多个实例记录分析
在一次生成AWR报告中,发现在“Instances in this Workload Repository schema”部分,出现了多个实例记录信息(host敏感信息被用host1,host2,host3替换)。具体信息如下截图所示:
SQL> @?/rdbms/admin/awrrpt
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
3990839260 SCM2 1 SCM2
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
------------ -------- ------------ ------------ ------------
3990839260 1 SCM2 SCM2 host1
* 3990839260 1 SCM2 SCM2 host2
3990839260 1 SCM2 SCM2 host3
Using 3990839260 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.
其实这几个hostname对于我来说,非常熟悉,一个是数据库迁移前的hostname,一个是hostname修改前的名称,一个是hostname修改后的名称。那么为什么出现这个情况呢?我们先从$ORACLE_HOME/rdbms/admin/awrrpt.sql脚本开始,看看这些记录是怎么获取的。
[oracle@MyOracle admin]$ more awrrpt.sql
Rem $Header: awrrpt.sql 24-oct-2003.12:04:53 pbelknap Exp $
Rem
Rem awrrpt.sql
Rem
Rem Copyright (c) 1999, 2003, Oracle Corporation. All rights reserved.
Rem
Rem NAME
Rem awrrpt.sql
Rem
Rem DESCRIPTION
Rem This script defaults the dbid and instance number to that of the
Rem current instance connected-to, then calls awrrpti.sql to produce
Rem the Workload Repository report.
Rem
Rem NOTES
Rem Run as select_catalog privileges.
Rem This report is based on the Statspack report.
Rem
Rem If you want to use this script in an non-interactive fashion,
Rem see the 'customer-customizable report settings' section in
Rem awrrpti.sql
Rem
Rem MODIFIED (MM/DD/YY)
Rem pbelknap 10/24/03 - swrfrpt to awrrpt
Rem pbelknap 10/14/03 - moving params to rpti
Rem pbelknap 10/02/03 - adding non-interactive mode cmnts
Rem mlfeng 09/10/03 - heading on
Rem aime 04/25/03 - aime_going_to_main
Rem mlfeng 01/27/03 - mlfeng_swrf_reporting
Rem mlfeng 01/13/03 - Update comments
Rem mlfeng 07/08/02 - swrf flushing
Rem mlfeng 06/12/02 - Created
Rem
--
-- Get the current database/instance information - this will be used
-- later in the report along with bid, eid to lookup snapshots
set echo off heading on underline on;
column inst_num heading "Inst Num" new_value inst_num format 99999;
column inst_name heading "Instance" new_value inst_name format a12;
column db_name heading "DB Name" new_value db_name format a12;
column dbid heading "DB Id" new_value dbid format 9999999999 just c;
prompt
prompt Current Instance
prompt ~~~~~~~~~~~~~~~~
select d.dbid dbid
, d.name db_name
, i.instance_number inst_num
, i.instance_name inst_name
from v$database d,
v$instance i;
@@awrrpti
undefine num_days;
undefine report_type;
undefine report_name;
undefine begin_snap;
undefine end_snap;
--
-- End of file
如上所示,其实awrrpt.sql里面没有多少料,主要功能还是在awrrpti.sql中实现的。在awrrpti.sql里面,看到通过下面部分信息,定位到AWR里面的信息来源于awrinput.sql
检查awrinput.sql脚本,发现AWR那段数据来自于下面SQL语句
--
-- Request the DB Id and Instance Number, if they are not specified
column instt_num heading "Inst Num" format 99999;
column instt_name heading "Instance" format a12;
column dbb_name heading "DB Name" format a12;
column dbbid heading "DB Id" format a12 just c;
column host heading "Host" format a12;
prompt
prompt
prompt Instances in this Workload Repository schema
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
select distinct
(case when cd.dbid = wr.dbid and
cd.name = wr.db_name and
ci.instance_number = wr.instance_number and
ci.instance_name = wr.instance_name and
ci.host_name = wr.host_name
then '* '
else ' '
end) || wr.dbid dbbid
, wr.instance_number instt_num
, wr.db_name dbb_name
, wr.instance_name instt_name
, wr.host_name host
from dba_hist_database_instance wr, v$database cd, v$instance ci;
prompt
prompt Using &&dbid for database Id
prompt Using &&inst_num for instance number
最后发现原因是:视图dba_hist_database_instance里面存放的历史记录,记录了host的变化,所以上面SQL,出现了三条记录。
dba_hist_database_instance视图脚本
select dbid, instance_number, startup_time, parallel, version,
db_name, instance_name, host_name, last_ash_sample_id
from WRM$_DATABASE_INSTANCE
使用下面脚本找到对应的记录,然后删除那些历史数据就可以了。但是手工删除这个表的数据是否会有问题呢? 也在测试环境测试了一下,没有任何问题,和同事讨论了一下,觉得这个数据的删除,不会出现什么问题。
SQL> SELECT HOST_NAME, MAX(STARTUP_TIME) FROM dba_hist_database_instance
2 GROUP BY HOST_NAME;
SQL> DELETE FROM dba_hist_database_instance WHERE STARTUP_TIME <=TO_DATE('2016-05-05 00:00:00', 'YYYY-MM-DD HH24:MI:SS');
COMMIT;
266 rows deleted.
SQL>COMMIT;
ORACLE AWR报告生成过程出现多个实例记录分析的更多相关文章
- Oracle AWR报告指标全解析-11011552
1-5 Top 5 Timed EventsWaits : 该等待事件发生的次数, 对于DB CPU此项不可用Times : 该等待事件消耗的总计时间,单位为秒, 对于DB CPU 而言是前台进程所消 ...
- Oracle AWR 报告详解
转自:http://blog.csdn.net/laoshangxyc/article/details/8615187 持续更新中... Oracle awr报告详解 DB Name DB Id In ...
- (原创)如何在性能测试中自动生成并获取Oracle AWR报告
版权声明:本文为原创文章,转载请先联系并标明出处 由于日常使用最多的数据库为Oracle,因此,最近又打起了Oracle的AWR报告的主意. 过去我们执行测试,都是执行开始和结束分别手动建立一个快照, ...
- 快速熟悉 Oracle AWR 报告解读
目录 AWR报告简介 AWR报告结构 基本信息 Report Summary Main Report RAC statistics Wait Event Statistics 参考资料 本文面向没有太 ...
- ORACLE AWR报告生成步骤
ORACLE AWR报告生成步骤 (以PL/SQL中命令窗口为例) 1.sqlplus或plsql的commod窗口(命令窗口)运行命令 @D:\oracle\product\10.2.0\db_1\ ...
- Oracle AWR报告提取方法
本文旨在用来指导项目人员自行提取Oracle数据库的AWR报告. 1.当前连接实例的AWR报告提取:@?/rdbms/admin/awrrpt 2.RAC的其他实例AWR报告提取:@?/rdbms/a ...
- Oracle AWR报告生成和性能分析
目录 一.AWE报告生成步骤 1.1 工具选择 1.2 自动创建快照 1.3 手工创建快照 1.4 生成AWR报告 二.AWR报告分析 2.1 AWR之DB Time 2.2 AWR之load_pro ...
- [转]oracle awr报告生成和分析
转自:http://blog.csdn.net/cuker919/article/details/8767328 最近由于数据库cpu占用非常高,导致VCS常常自动切换,引起很多问题. 最近学习一下数 ...
- Oracle Awr报告_awr报告解读_基础简要信息
导出 关于awr报告的导出,上一篇博客已经进行过讲述了.博客链接地址:https://www.cnblogs.com/liyasong/p/oracle_report1.html 这里就不再赘述. ...
随机推荐
- redis sentinel 集群配置-主从切换
1.配置redis master,redis slave(配置具体操作见上文http://www.cnblogs.com/wangchaozhi/p/5140469.html). redis mast ...
- 使用MiniProfiler跟踪MVC + EF + Bootstrap 2 权限管理系统的性能消耗
安装MiniProfiler 在MVC + EF + Bootstrap 2 权限管理系统入门级(附源码)文章中下载了它的源码,调试模式下打开一个页面都要再2.5秒以上,所以使用MiniProfile ...
- 纯灌水Linus主义
卖桃君重新整理了Linus的相关故事,在此摘选对自己有触动的内容. 关于生命的意义,李纳斯的解释是,有三件事具有生命的意义.它们是你生活当中所有事情的动机.第一是生存,第二是社会秩序,第三是娱乐.生活 ...
- python 函数小实例
1.判断一个数字是否为素数: import math # -----------------判断一个数是否是素数------------------ def sushu(a): i=1 for i i ...
- Remodal – 支持 Hash 追踪的响应式模态窗口
Remodal 是一个扁平化,响应式,轻量而且容易定制的模态窗口插件,支持使用声明状态和 Hash 跟踪.您可以轻松地定义为模态弹窗定义背景景容器(如模糊效果).支持所有现代的浏览器. 您可能感兴趣的 ...
- Web 前沿——HTML5 Form Data 对象的使用
XMLHttpRequest Level 2 添加了一个新的接口——FormData.利用 FormData 对象,我们可以通过 JavaScript 用一些键值对来模拟一系列表单控件,我们还可以使用 ...
- 实例之JavaScript
使用JavaScript实现5秒倒计时 <html> <head> <meta charset="utf-8"> <title>&l ...
- 【web前端面试题整理06】成都第一弹,邂逅聚美优品
前言 上周四回了成都,休息了一下下,工作问题还是需要解决的,于是今天去面试了一下,现在面试回来了,我感觉还是可以整理一下心得. 这个面试题整理系列是为了以后前端方面的兄弟面试时候可以得到一点点帮助,因 ...
- Flex Viewer
一.Flex Viewer简介 Flex Viewer是ESRI公司推出的可以高效开发基于WEB的地理信息应用系统的一种完全免费的应用程序框架.业务人员使用该框架可以无需任何额外的编程就能够通过简单配 ...
- SharePoint 2013 列表关于大数据的测试
本文主要介绍SharePoint列表库的效率问题,一直以来以为阙值5k,超过会线性下降,需要分文件夹存放:或许这是之前版本的描述,但是2013版本通过测试,真心不是这么一回事儿. 下面,简单介绍下自己 ...



