Linux 服务器生成 Oracle AWR 报告

179 篇文章 18 订阅

在这里插入图片描述

AWR介绍

AWR(Automatic Workload Repository 自动工作负载库)是Oracle提供的一个性能检测的工具,可以自动采集Oracle运行中的负载信息,并生成与性能相关的统计数据。我们可以根据这些统计数据进行问题的分析。

Oracle启动后,后台会有个进程去每小时捕获一次系统统计信息(生成数据库的“快照”),并将数据存储在它的存储库中,默认情况下在存储库中维持7天的数据量。可通过DBA_HIST_SNAPSHOT视图查看存储在AWR存储库中的数据。信息捕获来源为V$active_Session_History视图,该视图可以展示最近活动会话的历史记录。
  
 为启用AWR,可将STATISTICS_LEVEL初始参数设置为TYPICAL或ALL。如果设置STATISTICS_LEVEL为BASIC,则可生成AWR数据的手动快照,但这些快照不像由AWR自动执行的快照那样全面。将STATISTICS_LEVEL设置为ALL可将定时的OS统计信息和计划执行统计信息添加到用TYPICAL设置手机的那些信息中。

AWR报告生成

oracle 可以将8天的awr快照数据进行储存,我们可以将oracle中的任何两个时间点(输入日期后,会返回相应的时段内,快照对应的时间)生成该段时间内的awr报告。具体生成方式有多种,一般需要sys权限。

生成AWR报告的操作步骤如下

# su - oracle //切换至oracle用户

$ echo $ORACLE_SID //查看当前 SID
test

$ sqlplus / as sysdba //登陆sys用户
SQL*Plus: Release 12.1.0.2.0 Production on Thu Apr 1 18:23:27 2021

Copyright © 1982, 2014, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> @?/rdbms/admin/awrrpt.sql //执行脚本

Current Instance
~~~~~~~~~~~~~~~~

DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
921468942 TEST 1 test

Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
AWR reports can be generated in the following formats. Please enter the
name of the format at the prompt. Default value is ‘html’.

‘html’ HTML format (default)
‘text’ Text format
‘active-html’ Includes Performance Hub active report

Enter value for report_type: html //输入导出脚本的类型(HTML或ext),不输入默认是HTML

Type Specified: html

Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

DB Id Inst Num DB Name Instance Host
------------ -------- ------------ ------------ ------------
* 921468942 1 TEST test testdb

Using 921468942 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 without
specifying a number lists all completed snapshots.

Enter value for num_days: 1 //输入返回快照的天数,这里输入1表示返回一天的记录

Listing the last day’s Completed Snapshots

Snap
Instance DB Name Snap Id Snap Started Level
------------ ------------ --------- ------------------ -----
test        TEST          136 01 Apr 2021 00:00 1
                                 137 01 Apr 2021 01:00 1
                                 138 01 Apr 2021 02:00 1
                                 139 01 Apr 2021 03:00 1
                                 140 01 Apr 2021 04:00 1
                                 141 01 Apr 2021 05:00 1
                                 142 01 Apr 2021 06:00 1
                                 143 01 Apr 2021 07:00 1
                                 144 01 Apr 2021 08:00 1
                                 145 01 Apr 2021 09:00 1
                                 146 01 Apr 2021 10:00 1
                                 147 01 Apr 2021 11:00 1
                                 148 01 Apr 2021 12:00 1
                                 149 01 Apr 2021 13:00 1
                                 150 01 Apr 2021 14:00 1
                                 151 01 Apr 2021 15:00 1
                                 152 01 Apr 2021 16:00 1
                                 153 01 Apr 2021 17:00 1
                                 154 01 Apr 2021 18:00 1

Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap:143 //输入生成报告的起始Snap Id,根据实际需要的时间段选择
Begin Snapshot Id specified: 143

Enter value for end_snap: 146 //输入生成报告的结束Snap Id,根据实际需要的时间段选择
End Snapshot Id specified: 146

Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_143_146.html. To use this name,
press to continue, otherwise enter an alternative.

Enter value for report_name: //输入AWR报告名称,此处可直接回车使用默认名称
Using the report name awrrpt_1_143_146.html


此处省略长长的滚屏信息

End of Report

Report written to awrrpt_1_143_146.html

在这里插入图片描述

到此,已成功生成AWR报告,根据填写的信息,报告生成的是7:00--10:00的信息,报告的名称为awrrpt_1_143_146.html
 
AWR默认保存在/home/oracle路径下。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值