使用Oracle Statpack的具體步驟

mengzhaoliang發表於2008-12-12

環境:
作業系統:AIX5.3(64位)
Oracle版本:Oracle10.2.1.0.1(64位)
使用Statpack的具體步驟


      Oracle Statspack是用來診斷Oracle資料庫效能的強有力的工具。透過Statspack我們可以很容易的確定Oracle資料庫的瓶頸所在,記錄資料庫效能狀態,也可以使遠端技術支援人員迅速瞭解資料庫執行狀況。

 

 

1、telnet到遠端的資料庫伺服器
CMD>telnet   遠端資料庫的IP

2、切換到資料庫的使用者
DQXXDBS01:/> su  -  oraoms


3、用超級使用者進入資料庫
$ sqlplus   "/as   sysdba"

4、檢視引數,是否可以用job(可以用job進行自動的收集Statpack Report的資料)
SQL> show   parameter   job_queue_processes

NAME                                 TYPE        VALUE
------------------------------------ ----------- ----------
job_queue_processes                  integer     10

5、該引數可以收集作業系統的資訊
SQL> show   parameter   timed_statistics

NAME                                 TYPE        VALUE
------------------------------------ ----------- --------
timed_statistics                     boolean     TRUE

6、為了建立表空間,表空間的資料檔案放在哪比較好
SQL> select   file_name   from   dba_data_files;

FILE_NAME
------------------------------------------------------
/oracle/oms/oradata/sysdata/system01.dbf
/oracle/oms/oradata/undo/undotbs01.dbf
/oracle/oms/oradata/sysdata/sysaux01.dbf
/oracle/oms/oradata/sysdata/users01.dbf
/oracle/oms/oradata/sysdata/RMAN_data000.dbf
/oracle/oms/oradata/pub/Pub_Norm_data000.dbf
......


21 rows selected.

7、檢視哪個目錄的空間比較大,確定perfstat表空間的資料檔案的位置
$ df   -g
Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on

/dev/gpelv        64.00     33.99   47%        6     1% /oracle/oms/oradata/gpe
/dev/jbpmlv        5.00      2.46   51%        5     1% /oracle/oms/oradata/jbpm
/dev/loglv       175.00    144.97   18%        6     1% /oracle/oms/oradata/log
/dev/undolv       30.00     29.53    2%        7     1% /oracle/oms/oradata/undo
/dev/wpslv        10.00      2.48   76%        5     1% /oracle/oms/oradata/wps
/dev/redolv        1.00      0.41   59%        8     1% /oracle/oms/redolog
......

8、建立表空間:
SQL> create   tablespace   perfstat
  2  datafile   '/oracle/oms/oradata/temp/perfstat.dbf'
  3  size   500M;


Tablespace created.

9、建立Statspack需要的指令碼
SQL> @/oracle/oms/102_64/rdbms/admin/spcreate.sql
Choose the PERFSTAT user's password
-----------------------------------
Not specifying a password will result in the installation FAILING

Enter value for perfstat_password: (可以輸入perfstat,便於記憶)

Pressing will result in STATSPACK's recommended default
tablespace (identified by *) being used.

Enter value for default_tablespace: perfstat


Choose the PERFSTAT user's Temporary tablespace.

TABLESPACE_NAME                CONTENTS  DB DEFAULT TEMP TABLESPACE
------------------------------ --------- --------------------------
TEMP                           TEMPORARY *

Pressing will result in the database's default Temporary
tablespace (identified by *) being used.

Enter value for temporary_tablespace: temp

 

10、測試是否成功,生成資料庫的一個快照
SQL> execute   statspack.snap

PL/SQL procedure successfully completed.

11、再生成一個快照
SQL> execute   statspack.snap

PL/SQL procedure successfully completed.

12、取兩個快照之間時間段的Statspack報告
SQL> @/oracle/oms/102_64/rdbms/admin/spreport.sql
Listing all Completed Snapshots

                                                       Snap
Instance     DB Name        Snap Id   Snap Started    Level Comment
------------ ------------ --------- ----------------- ----- ------------------
DQOMS        DQOMS                1 12 Dec 2008 11:53     5
                                  2 12 Dec 2008 11:54     5

 

Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter value for begin_snap: 1
Begin Snapshot Id specified: 1

Enter value for end_snap: 2

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

Enter value for report_name: (輸入要生產檔案的名稱:20081212Statspack)

 


13、用job進行定時產生Statspack的快照,便於收集資料(預設為1小時產生一個快照)
SQL> @/oracle/oms/102_64/rdbms/admin/spauto.sql

PL/SQL procedure successfully completed.


Job number for automated statistics collection for this instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that this job number is needed when modifying or removing
the job:

     JOBNO
----------
        21


Job queue process
~~~~~~~~~~~~~~~~~
Below is the current setting of the job_queue_processes init.ora
parameter - the value for this parameter must be greater
than 0 to use automatic statistics gathering:

NAME_COL_PLUS_SHOW_PARAM
------------------------------------------------------------------------------
TYPE
-----------
VALUE_COL_PLUS_SHOW_PARAM
------------------------------------------------------------------------------
job_queue_processes
integer
10


Next scheduled run
~~~~~~~~~~~~~~~~~~
The next scheduled run for this job is:

       JOB NEXT_DATE    NEXT_SEC
---------- ------------ ----------------
        21 12-DEC-08    12:00:00

 

11、當最好生成需要的Statspack之後,記住移除任務,檢視任務:
SQL> select   job, log_user, priv_user, last_date,next_date, interval from user_jobs;

12、移除生成Statspack快照的任務:
SQL> execute   dbms_job.remove('21')

 

PL/SQL procedure successfully completed


完畢!

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12778571/viewspace-510231/,如需轉載,請註明出處,否則將追究法律責任。

相關文章