AWR (Automatic Workload Repository) 是自動負載信息庫的英文縮寫,AWR報告是Oracle 10g以后版本提供的一種性能收集和分析工具,能提供一個時間段內整個系統資源使用情況的報告,通過報告可以了解一個系統的整個運行情況。
生成AWR報告
-
切換用戶
使用oralce用戶登陸操作系統,如果不知道oracle用戶密碼,可從root用戶
su - oracle
:server01:root:/>whoami root server01:root:/>su - oracle server01:oracle:/home/oracle>whoami oracle server01:oracle:/home/oracle>
-
sqlplus連接數據庫
在oracle用戶下執行
sqlplus / as sysdba
命令,連接到oracle數據庫:server01:oracle:/home/oracle>sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Thu Dec 12 00:01:02 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL>
-
導出當前實例的AWR報告
在sqlplus中執行
@?/rdbms/admin/awrrpt.sql
:SQL> @?/rdbms/admin/awrrpt.sql Current Instance ~~~~~~~~~~~~~~~~ DB Id DB Name Inst Num Instance ----------- ------------ -------- ------------ 919662622 DEVDB 1 devdb Specify the Report Type ~~~~~~~~~~~~~~~~~~~~~~~
-
輸入導出報告的格式
在執行@?/rdbms/admin/awrrpt.sql命令后,會提示輸入導出報告的格式,默認格式為html,如果想導出html格式,直接Enter即可:
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:
-
輸入導出天數
根據需要,輸入導出的報告的具體天數,即當前時間N天之內的所有信息:
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:
-
輸入要導出的snap的開始ID
在輸入要導出的天數之后,oracle會列出所有滿足預期天數的snap的信息,根據需要,輸入snap的開始ID:
Listing the last 2 days of Completed Snapshots Instance DB Name Snap Id Snap Started Snap Level ------------ --------- --------- ------------------ ----- devdb DEVDB 3151 11 Dec 2019 00:00 1 3152 11 Dec 2019 01:00 1 3153 11 Dec 2019 02:00 1 3154 11 Dec 2019 03:00 1 3155 11 Dec 2019 04:00 1 3156 11 Dec 2019 05:00 1 3157 11 Dec 2019 06:00 1 3158 11 Dec 2019 07:00 1 3159 11 Dec 2019 08:00 1 3160 11 Dec 2019 09:00 1 3161 11 Dec 2019 10:00 1 3162 11 Dec 2019 11:00 1 3163 11 Dec 2019 12:00 1 3164 11 Dec 2019 13:00 1 3165 11 Dec 2019 14:00 1 3166 11 Dec 2019 15:00 1 3167 11 Dec 2019 16:00 1 3168 11 Dec 2019 17:00 1 3169 11 Dec 2019 18:00 1 3170 11 Dec 2019 19:00 1 3171 11 Dec 2019 20:00 1 3172 11 Dec 2019 21:00 1 3173 11 Dec 2019 22:00 1 3174 11 Dec 2019 23:00 1 3175 12 Dec 2019 00:00 1 Specify the Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter value for begin_snap:
-
輸入要導出的snap的截止ID
輸入開始ID之后,會提示輸入截止ID,根據需要輸入截止ID:
Enter value for end_snap:
-
設置導出的報告名稱
導出報告時,如果需要設置導出的報告名稱,可根據提示進行修改:
Specify the Report Name ~~~~~~~~~~~~~~~~~~~~~~~ The default report file name is awrrpt_1_3151_3175.html. To use this name, press <return> to continue, otherwise enter an alternative. Enter value for report_name:
-
查看報告
輸入報告名稱之后並敲擊回車之后,oracle會自動生成AWR報告,可退出sqlplus進行查看:SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options server01:oracle:/home/oracle>ls -lrt total 12544 drwxr-xr-x 4 root system 256 Jul 02 1972 app -rw-r--r-- 1 oracle dba 25178 Jul 02 1972 db.rsp -rw-r--r-- 1 oracle dba 8 Jul 03 1972 #UNTITLED# -rw-r----- 1 oracle dba 4950061 Jul 06 1972 core -rw-r----- 1 oracle dba 289692 Jul 29 22:31 install2019-07-29_22-17-53.log drwxr-xr-x 2 oracle dba 256 Aug 01 00:40 scripts -rw-r--r-- 1 oracle dba 594527 Dec 11 22:37 test.html -rw-r--r-- 1 oracle dba 545490 Dec 12 00:51 awr.html
本文僅供日常學習交流使用,如有錯誤之處,歡迎指正。