最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Oracle數(shù)據(jù)庫AWR報(bào)告的生成步驟與分析方法

 更新時(shí)間:2026年04月10日 09:26:41   作者:晴天¥  
本文介紹了在Oracle數(shù)據(jù)庫中生成AWR報(bào)告的基本步驟和方法,以及分析AWR報(bào)告的五步法:1 看整體負(fù)載;2 查看等待事件;3 了解SQL統(tǒng)計(jì);4 調(diào)查時(shí)間模型;5 分析操作系統(tǒng)和內(nèi)存,需要的朋友可以參考下

Oracle中要想生成 AWR(Automatic Workload Repository)報(bào)告,最常用的方法是通過 Oracle 自帶的命令行腳本。AWR 報(bào)告是分析數(shù)據(jù)庫性能、定位瓶頸的利器,生成步驟并不復(fù)雜,主要分為確認(rèn)權(quán)限、執(zhí)行腳本選擇范圍三步。

一、登錄數(shù)據(jù)庫

首先,你需要以具有足夠權(quán)限的數(shù)據(jù)庫管理員賬號(hào)登錄到數(shù)據(jù)庫所在的服務(wù)器,并連接到數(shù)據(jù)庫。

打開終端,輸入以下命令登錄到數(shù)據(jù)庫服務(wù)器,并使用 sqlplus 工具以 sysdba(系統(tǒng)管理員)身份連接:

# 切換到 oracle 用戶 (通常為 oracle)
su - oracle
# 以 sysdba 身份登錄
sqlplus / as sysdba

二、執(zhí)行 AWR 報(bào)告生成腳本

登錄成功后,執(zhí)行 Oracle 內(nèi)置的報(bào)告生成腳本 awrrpt.sql 。這個(gè)腳本會(huì)引導(dǎo)你一步步完成報(bào)告的生成。

SQL> @?/rdbms/admin/awrrpt.sql

命令解釋@表示執(zhí)行一個(gè) SQL 腳本,? 是 $ORACLE_HOME 路徑的簡寫。因此,這條命令會(huì)完整地定位到該腳本并執(zhí)行它。

三、選擇報(bào)告類型與時(shí)間范圍

腳本執(zhí)行后,系統(tǒng)會(huì)提示你進(jìn)行幾個(gè)簡單的選擇,按需輸入即可

3.1.選擇報(bào)告格式

Enter value for report_type: html
        1.html:生成HTML格式,圖形化界面,推薦選擇
        2.text:生成純文本格式。

3.2.選擇時(shí)間范圍(最關(guān)鍵的一步)

AWR 基于快照來記錄性能數(shù)據(jù)。你需要選擇開始快照結(jié)束快照的 ID,報(bào)告將展示這兩個(gè)時(shí)間點(diǎn)之間的性能情況。

系統(tǒng)會(huì)列出最近可用的快照及其對(duì)應(yīng)的時(shí)間,例如:

Snap     Instance     Snap Started
-------- ------------ -----------------------
   123    ORCL        09 Apr 2026 10:00
   124    ORCL        09 Apr 2026 11:00
   125    ORCL        09 Apr 2026 12:00

指定開始時(shí)間:輸入你分析時(shí)間段的起始快照 ID,例如 124

指定結(jié)束時(shí)間:輸入結(jié)束快照 ID,例如 125

注意:AWR 默認(rèn)每小時(shí)自動(dòng)生成一次快照。如果你的數(shù)據(jù)庫是新安裝的,可能需要等待一段時(shí)間才能有足夠的數(shù)據(jù)來生成有意義的報(bào)告

3.3.指定AWR報(bào)告名稱

Enter value for report_name: awr_report_20260409.html

整體示例:

[oracle@rac01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Apr 9 14:41:40 2026
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle.  All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> @?/rdbms/admin/awrrpt.sql
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
old   1: select 'Type Specified: ',lower(nvl('&&report_type','html')) report_type from dual
new   1: select 'Type Specified: ',lower(nvl('html','html')) report_type from dual
Type Specified:  html
old   1: select '&&report_type' report_type_def from dual
new   1: select 'html' report_type_def from dual
old   1: select '&&view_loc' view_loc_def from dual
new   1: select 'AWR_PDB' view_loc_def from dual
Current Instance
~~~~~~~~~~~~~~~~
DB Id          DB Name        Inst Num       Instance       Container Name
-------------- -------------- -------------- -------------- --------------
 1747225139     ORCL                        1 orcl           orcl
Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  DB Id      Inst Num   DB Name      Instance     Host
------------ ---------- ---------    ----------   ------
* 1747225139     1      ORCL         orcl         rac01.exampl
Using 1747225139 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.
Enter value for num_days: 1
Listing the last day's Completed Snapshots
Instance     DB Name      Snap Id       Snap Started    Snap Level
------------ ------------ ---------- ------------------ ----------
orcl         ORCL                57  09 Apr 2026 12:56    1
                                 58  09 Apr 2026 14:00    1
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 57
Begin Snapshot Id specified: 57
Enter value for end_snap: 58
End   Snapshot Id specified: 58
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is awrrpt_1_57_58.html.  To use this name,
press <return> to continue, otherwise enter an alternative.
Enter value for report_name: awr_report_20260409.html
Using the report name awr_report_20260409.html
<html lang="en"><head><title>AWR Report for DB: ORCL, Inst: orcl, Snaps: 57-58</title>
............
............
............
End of Report
</body></html>
Report written to awr_report_20260409.html
SQL>

四、獲取報(bào)告文件

完成上述選擇后,腳本會(huì)自動(dòng)生成報(bào)告并保存在你當(dāng)前登錄的目錄下。

你可以在當(dāng)前 sqlplus 所在的路徑下找到生成的報(bào)告文件(例如 awr_report_20260409.html),使用 ls 命令確認(rèn)后,通過遠(yuǎn)程工具將其下載到本地,用瀏覽器打開即可查看。

五、分析AWR性能報(bào)告

5.1.AWR 報(bào)告分析入門:五步法

分析一份有實(shí)際負(fù)載的 AWR 報(bào)告,通常遵循以下五個(gè)核心步驟。你可以把這個(gè)方法套用到未來的任何報(bào)告分析中。

Elapsed:消耗

parse:解析

第一步:看整體負(fù)載 —— “數(shù)據(jù)庫忙不忙?”

  • 核心指標(biāo)DB Time
  • 位置:報(bào)告開頭的 Snapshot 信息表和 Load Profile 部分。

分析方法:

DB Time 是數(shù)據(jù)庫處理用戶請求花費(fèi)的總時(shí)間。將它除以 Elapsed Time(快照時(shí)長),可以算出平均活動(dòng)會(huì)話數(shù)。

  • 平均活動(dòng)會(huì)話 = DB Time / Elapsed Time
  • 例如:DB Time = 100分鐘,Elapsed Time = 10分鐘,則平均有 10 個(gè)會(huì)話在并發(fā)工作。

在我的AWR報(bào)告中分析:DB Time = 0,則平均活動(dòng)會(huì)話 = 0。結(jié)論是數(shù)據(jù)庫處于完全空閑狀態(tài)。

第二步:看等待事件 —— “瓶頸在哪里?”

  • 核心部分Top 10 Foreground Events by Total Wait Time
  • 位置:Main Report -> Wait Events Statistics -> Top 10 Foregroud Events...

  • 分析方法:這里列出了消耗數(shù)據(jù)庫時(shí)間最多的“等待”。通過分析等待事件類型,可以快速定位問題。
    • CPU:DB CPU 排在首位且占比高(例如 > 90%),說明系統(tǒng)在高效計(jì)算,而非等待資源。
    • I/O 相關(guān): db file sequential / scattered read,說明磁盤 I/O 可能是瓶頸。
    • 并發(fā)相關(guān):如 buffer busy waits ,說明存在熱點(diǎn)數(shù)據(jù)塊爭用。
    • 網(wǎng)絡(luò)/配置相關(guān):如 log file sync,說明日志寫入可能存在延遲。
    • 在我的AWR報(bào)告分析中:只有 DB CPU 和 ADR block file read 等少數(shù)幾個(gè)事件,且等待時(shí)間(Wait Time)為 0,說明沒有有意義的等待事件。

第三步:看 SQL 統(tǒng)計(jì) —— “是哪些 SQL 在消耗資源?”

  • 核心部分SQL Statistics
  • 位置:Main Report -> SQL Statistics -> 重點(diǎn)關(guān)注SQL ordered by Elapsed Time和SQL ordered by Cpu Time

  • 分析方法:這個(gè)區(qū)域會(huì)列出消耗資源最多的 SQL 語句。
    • 重點(diǎn)關(guān)注 Elapsed Time (s)、CPU Time (s)Executions(執(zhí)行次數(shù))、Buffer Gets(邏輯讀)。
    • 查找“昂貴”的 SQL:單次執(zhí)行耗時(shí)很長,或執(zhí)行次數(shù)非常多的 SQL。
    • 可以記錄下SQL Id,然后去數(shù)據(jù)庫里用 DBMS_SQLTUNE 包或查看執(zhí)行計(jì)劃進(jìn)行優(yōu)化。
  • 報(bào)告分析中:此處有數(shù)據(jù),但 Elapsed Time 都遠(yuǎn)小于 1 秒,%Total 的百分比巨大是由于總 DB Time 為 0 導(dǎo)致的異常。沒有需要優(yōu)化的 SQL

第四步:看時(shí)間模型 —— “時(shí)間都花在哪兒了?”

  • 核心部分:Time Model Statistics
  • 位置:Main Report -> Wait Events Statistics -> Time Model Statisstics

  • 分析方法:這里展示了數(shù)據(jù)庫時(shí)間花在了前臺(tái)(DB Time)還是后臺(tái)(background time),以及具體花費(fèi)在解析 SQL、硬解析等環(huán)節(jié)的時(shí)間比例。
    • 重點(diǎn)關(guān)注 parse time elapsed 占總 DB Time 的比例,如果過高(例如 >10%),說明存在解析問題。
    • hard parse elapsed time過高,說明可能存在未使用綁定變量導(dǎo)致的游標(biāo)緩存失效問題。

第五步:看操作系統(tǒng)和內(nèi)存 —— “硬件資源夠不夠?”

  • 核心部分Host CPU 和 Memory Statistics
  • 位置:Main Report -> Report Summary 和 Memory Statistics。

分析方法:

  • CPU:查看 Load Average (系統(tǒng)平均負(fù)載)是否超過了邏輯 CPU 總數(shù)。你的服務(wù)器有 2 個(gè) CPU,Load Average 僅為 0.3 左右,非常低。
  • 內(nèi)存:查看 Memory Statistics 中 %Host Mem used for SGA + PGA,以及是否存在大量換頁(報(bào)告中未顯示,但可從操作系統(tǒng)層面查看)。
  • 報(bào)告分析:CPU 和內(nèi)存資源都非常充足。

以上就是Oracle數(shù)據(jù)庫AWR報(bào)告的生成步驟與分析方法的詳細(xì)內(nèi)容,更多關(guān)于Oracle AWR報(bào)告生成與分析的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論

双辽市| 平山县| 中江县| 昌黎县| 泉州市| 清流县| 通榆县| 南康市| 阳春市| 九寨沟县| 任丘市| 岳西县| 来安县| 绍兴市| 澄江县| 永善县| 枝江市| 珲春市| 故城县| 惠水县| 贺州市| 宁乡县| 平山县| 赫章县| 织金县| 依安县| 温泉县| 商水县| 肃宁县| 红原县| 阿荣旗| 德保县| 汉沽区| 施甸县| 双鸭山市| 大连市| 丘北县| 峡江县| 元朗区| 建德市| 墨江|