zoukankan      html  css  js  c++  java
  • awr 收集时间

    windows 收集 awr 报告,一分钟一个。

    https://www.realdbamagic.com/manually-generating-awr-report/

    One of my customers asked me to check performance on his production database server but could not allow any access to the server itself. He asked if I could generate the AWR reports from his client machine and since it’s not really trivial (or hard) I created this script.

    When we want to generate the AWR report, we usually run the awrrpt.sql script. We don’t need to be on the database server for that – we just need the awrrpt script and the scripts it calls – so any database server installation will do. Once we connect to the database and run the script, it will automatically run the relevant queries and scripts and generate the report.

    Underneath all the scripts there is DBMS package called DBMS_WORKLOAD_REPOSITORY which we can call ourselves. In this case, since I didn’t have the scripts, I had to use it but I can think of other cases where it make sense to use it (for example, for generating multiple reports, or automatically send reports by email).

    There are two ways to generate the report. We can generate a text version or HTML version – and indeed, there are two functions for that: AWRRPT_HTML_TYPE_TABLE and AWRRPT_TEXT_TYPE_TABLE. Those function accept these parameters, so let’s see where we get the data for that:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    FUNCTION AWR_REPORT_HTML RETURNS AWRRPT_HTML_TYPE_TABLE
     Argument Name                  Type                    In/Out Default?
     ------------------------------ ----------------------- ------ --------
     L_DBID                         NUMBER                  IN
     L_INST_NUM                     NUMBER                  IN
     L_BID                          NUMBER                  IN
     L_EID                          NUMBER                  IN
     L_OPTIONS                      NUMBER                  IN     DEFAULT
     
    FUNCTION AWR_REPORT_TEXT RETURNS AWRRPT_TEXT_TYPE_TABLE
     Argument Name                  Type                    In/Out Default?
     ------------------------------ ----------------------- ------ --------
     L_DBID                         NUMBER                  IN
     L_INST_NUM                     NUMBER                  IN
     L_BID                          NUMBER                  IN
     L_EID                          NUMBER                  IN
     L_OPTIONS                      NUMBER                  IN     DEFAULT

    In order to get the DBID, Instance number and a list of snap ids we can use (here, from the last day), we can run this query:

    1
    2
    3
    4
    SELECT DBID, instance_number, snap_id, begin_interval_time, end_interval_time
      FROM dba_hist_snapshot
     where begin_interval_time > sysdate - 1
     ORDER BY snap_id

    In order to generate the report as cleanly as possible we can use this script.

    For HTML output:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    Set heading off
    Set trimspool off
    Set linesize 1500
    Set termout on
    Set feedback off
     
    Spool awr_from_console.htm
    select output from table(dbms_workload_repository.awr_report_html(&dbid, &inst_num, &bid, &eid));
    spool off;

    For TEXT output:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    Set heading off
    Set trimspool off
    Set linesize 80
    Set feedback off
    Set termout on
     
    Spool awr_from_console.txt
    select output from table(dbms_workload_repository.awr_report_text(&dbid, &inst_num, &bid, &eid));
    spool off;

    And the result will be:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    SQL> Set heading off
    SQL> Set trimspool off
    SQL> Set linesize 80
    SQL> Set termout on
    SQL>
    SQL> Spool awr_from_console.txt
    SQL> select output from table(dbms_workload_repository.awr_report_text(&dbid, &inst_num, &bid, &eid));
    Enter value for dbid: 2492639615
    Enter value for inst_num: 1
    Enter value for bid: 953
    Enter value for eid: 954
    old   1: select output from table(dbms_workload_repository.awr_report_text(&dbid, &inst_num, &bid, &eid))
    new   1: select output from table(dbms_workload_repository.awr_report_text(2492639615, 1, 953, 954))
     
    WORKLOAD REPOSITORY report for
     
    DB Name         DB Id    Instance     Inst Num Startup Time    Release     RAC
    ------------ ----------- ------------ -------- --------------- ----------- ---
    GHTEST        2492639615 ghtest              1 15-Dec-16 09:18 11.2.0.4.0  NO
     
    […awr report…]
     
  • 相关阅读:
    MSSQL 跨数据库连接
    powerdesigner逆向工程,从数据库导出PDM
    JS面向对象的程序设计
    数据脚本
    JDK安装与环境变量配置
    sql: 去除数据库表中tab、空格、回车符等特殊字符的解决方法
    用SQL语句获得一个存储过程返回的表
    百度云下载速度慢解决方法
    【WCF全析(一)】--服务协定及消息模式
    【WCF全析(二)】--服务配置部署详解
  • 原文地址:https://www.cnblogs.com/feiyun8616/p/6393945.html
Copyright © 2011-2022 走看看