1.登录主机切换到oracle用户
ssh root@192.168.220.128 su - oracle
2.以sysdba身份登录数据库
sqlplus / as sysdba
3.执行@?/rdbms/admin/awrrpt.sql生成awr报告
SQL>@?/rdbms/admin/awrrpt.sql
①首先是要求填写要生成的报告格式,支持html和text,html是默认值可直接回车
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:
②接下来要求输入要列出Snap ID的天数,一般最大保存了一个月的快照。依自己的需要的时间段输入要列出最近几天的快照。
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:
③接下来要输入awr报告启和止的Snap ID,依自己要的时间段输入Snap ID即可
Snap Instance DB Name Snap Id Snap Started Level ------------ ------------ --------- ------------------ ----- lsdb lsdb 15277 28 Nov 2017 00:00 1 15278 28 Nov 2017 01:00 1 15279 28 Nov 2017 02:00 1 15280 28 Nov 2017 03:00 1 15281 28 Nov 2017 04:00 1 15282 28 Nov 2017 05:00 1 15283 28 Nov 2017 06:00 1 15284 28 Nov 2017 07:00 1 15285 28 Nov 2017 08:00 1 15286 28 Nov 2017 09:00 1 15287 28 Nov 2017 10:00 1 Specify the Begin and End Snapshot Ids ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enter value for begin_snap:
④最后要求输入报告名称,默认已有awrrpt_1_${START_SNAPID}_${END_SNAPID}的名称
The default report file name is awrrpt_1_15286_15287.html. To use this name, press <return> to continue, otherwise enter an alternative. Enter value for report_name:
4.说明
有些教程中在第三步生成报告时不是使用@?/rdbms/admin/awrrpt.sql而是直接使用@awrrpt.sql,那是因为其所在的主机当前目录已经是$ORACLE_HOME/rdbms/admin/
在Oracle中:@等同start(类似mysql中的source)后边需要接要执行的脚本的路径,?等同$ORACLE_HOME,只要理解就不会被各种有差异的写法所迷惑。
参考: