------- ---------- ------------------- ----------
1 2629872507 2014-02-07 10:51:30 5
注意:我们此处采用了Oracle的默认配置。snapshot方法镜像,我们有很多的选择余地。这些内容留待我们之后讨论。此处目标是创建出一个snapshot。
如果观察perfstat用户下的数据表,我们会发现很多以stats$作为前缀的数据表。这些表中保存的数据就是以snapshot为引领的性能数据。
同AWR一样,生成statspack报告最少要有两个snapshot形成,而且snapshot中间不允许关机启动动作。
SQL> exec statspack.SNAP;
PL/SQL procedure successfully completed
SQL> select snap_id, dbid, to_char(snap_time, 'yyyy-mm-dd hh24:mi:ss') snap_time, snap_level from stats$snapshot;
SNAP_ID DBID SNAP_TIME SNAP_LEVEL
------- ---------- ------------------- ----------
1 2629872507 2014-02-07 10:51:30 5
2 2629872507 2014-02-07 11:05:00 5
在创建出两个报告的情况下,我们就可以生成报告了。注意:Statspack和AWR报告在生成过程中,有细微差别。Statspack是调用客户端脚本,而AWR核心程序在服务器端的程序包里面。所以,强烈推荐使用服务器端进行报告生成动作。
SQL> conn perfstat/perfstat@ora9i
已连接。
SQL>
SQL> @ /rdbms/admin/spreport //生成脚本
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
2629872507 ORA9I 1 ora9i
Instances in this Statspack schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
----------- -------- ------------ ------------ ------------
2629872507 1 ORA9I ora9i ACCA-8535F03
015
Using 2629872507 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
specifying a number lists all completed snapshots.
Snap
Instance DB Name Snap Id Snap Started Level Comment
------------ ------------ --------- ----------------- ----- -------------------
ora9i ORA9I 1 07 2月 2014 10:5 5
1
2 07 2月 2014 11:0 5
5
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
输入 begin_snap 的值: 1
Begin Snapshot Id specified: 1
输入 end_snap 的值: 2
End Snapshot Id specified: 2
Specify the Report Name
~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is sp_1_2. To use this name,
press
输入 report_name 的值:
Using the report name sp_1_2
篇幅原因,脚本部分内容省略。同AWR报告生成相同,statspack报告需要交互方式提供三个数据:起始终值snapshot编号、生成报告名称。区别于AWR的html和text双格式报告,statspack支持text格式报告。
最后生成报告片段如下:
STATSPACK report for
DB Name DB Id Instance Inst Num Release Cluster Host
------------ ----------- ------------ -------- ----------- ------- ------------
ORA9I 2629872507 ora9i 1 9.2.0.1.0 NO ACCA-8535F03
015
Snap Id Snap Time Sessions Curs/Sess Comment
------- ------------------ -------- --------- -------------------
Begin Snap: 1 07-2月 -14 10:51:30 10 4.5
End Snap: 2 07-2月 -14 11:05:00 10 6.4
Elapsed: 13.50 (mins)
报告生成,其中包括我们比较熟悉的Top n系列诊断内容。
了解了statspack基本功能之后,我们还要进行探索。相对于AWR,Statspack在采样控制上灵活性是比较高的。不同的设置可以有不同的诊断层次级别。下篇中我们进行详细的讨论。