在一次生成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报告生成过程出现多个实例记录分析的更多相关文章

  1. Oracle AWR报告指标全解析-11011552

    1-5 Top 5 Timed EventsWaits : 该等待事件发生的次数, 对于DB CPU此项不可用Times : 该等待事件消耗的总计时间,单位为秒, 对于DB CPU 而言是前台进程所消 ...

  2. Oracle AWR 报告详解

    转自:http://blog.csdn.net/laoshangxyc/article/details/8615187 持续更新中... Oracle awr报告详解 DB Name DB Id In ...

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

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

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

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

  5. ORACLE AWR报告生成步骤

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

  6. Oracle AWR报告提取方法

    本文旨在用来指导项目人员自行提取Oracle数据库的AWR报告. 1.当前连接实例的AWR报告提取:@?/rdbms/admin/awrrpt 2.RAC的其他实例AWR报告提取:@?/rdbms/a ...

  7. Oracle AWR报告生成和性能分析

    目录 一.AWE报告生成步骤 1.1 工具选择 1.2 自动创建快照 1.3 手工创建快照 1.4 生成AWR报告 二.AWR报告分析 2.1 AWR之DB Time 2.2 AWR之load_pro ...

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

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

  9. Oracle Awr报告_awr报告解读_基础简要信息

    导出 关于awr报告的导出,上一篇博客已经进行过讲述了.博客链接地址:https://www.cnblogs.com/liyasong/p/oracle_report1.html  这里就不再赘述. ...

随机推荐

  1. MVP 2015社区大讲堂之:在ASP.NET应用中执行后台任务

    昨天下午,在微软的MVP 2015社区大讲堂上给大家分享了一个题目:在ASP.NET应用中执行后台任务.这是一点都不高大上,并且还有点土气的技术分享.不过我相信很多人都遇到过这样的问题. 虽然是一个很 ...

  2. EL表达式错误attribute items does not accept any expressions

    解决方法是将 <%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%> 改成 <% ...

  3. 阿里社招B2B

    岗位描述:1. 按USE CASE进行业务需求分析和软件概要设计2. 进行软件详细设计和编码实现,确保性能.质量和安全3. 维护和升级现有软件产品,快速定位并修复现有软件缺陷岗位要求:1. 精通Web ...

  4. C++之虚函数的作用和使用方法

    在同一类中是不能定义两个名字相同.参数个数和类型都相同的函数的,否则就是“重复定义”.但是在类的继承层次结构中,在不同的层次中可以出现名字相同.参数个数和类型都相同而功能不同的函数.例如在例12.1( ...

  5. RSuite 一个基于 React.js 的 Web 组件库

    RSuite http://rsuite.github.io RSuite 是一个基于 React.js 开发的 Web 组件库,参考 Bootstrap 设计,提供其中常用组件,支持响应式布局. 我 ...

  6. 更改SAP的字段翻译

    TC:SE63在SAP用户选择屏幕中,用鼠标选定一个栏位后按F1键,可以看到SAP对其具体解释,通常这种解释文本分为两部分,一部分为标题,一部分为正文.比如:  有时,SAP的翻译让人感觉很别扭,对于 ...

  7. Oracle12C相关

    1.jar包安装到MVN本地库 mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.1 ...

  8. vbs操作excel

    航天金税系统升级,导出的Excel文件格式与原来有的差异,老的数据导入程序识别不了该文件,对比了新老文件后,发现新文件在专票和普票的“份数”行前增加了一行,同时增加了“单据号”列,通过脚本 把这些删除 ...

  9. ubuntu 安装 swoole 和mac 安装swoole 扩展

    ubuntu php 安装swoole 比较容易 1. 从git下载源码 2. 下载pcre http://sourceforge.net/projects/pcre/files/pcre/8.36/ ...

  10. Textview在Listview中实现跑马灯效果

    textview添加属性:   android:singleLine="true" 表示单行显示   android:ellipsize="marquee" 设 ...