配置STATSPACK步驟
1.SQL*PLUS中輸入
SQL> connect sys/sys as sysdba;
SQL> alter system set job_queue_processes = 6; --自動執行數據收集時該參數需要大於0
System altered
SQL> alter system set timed_statistics = true;
System altered
--使用statspack收集統計信息時建議將該值設置爲 TRUE,否則收集的統計信息大約只能起到10%的作用
SQL> connect sys/sys as sysdba;
SQL> alter system set job_queue_processes = 6; --自動執行數據收集時該參數需要大於0
System altered
SQL> alter system set timed_statistics = true;
System altered
--使用statspack收集統計信息時建議將該值設置爲 TRUE,否則收集的統計信息大約只能起到10%的作用
SQL> @C:\oracle\ora92\rdbms\admin\spcreate.sql;
輸入 perfstat_password 的值: perfstat
輸入default_tablespace的值: perfstat
輸入temporary_tablespace 的值: temp
輸入 perfstat_password 的值: perfstat
輸入default_tablespace的值: perfstat
輸入temporary_tablespace 的值: temp
NOTE:
SPCPKG complete. Please check spcpkg.lis for any errors.
SPCPKG complete. Please check spcpkg.lis for any errors.
--需要出現上述語句纔算成功,否則請查看.lis文件並執行,進行重建
SQL> @C:\oracle\ora92\rdbms\admin\spdrop.sql
SQL> @C:\oracle\ora92\rdbms\admin\spcreate.sql;
SQL> @C:\oracle\ora92\rdbms\admin\spdrop.sql
SQL> @C:\oracle\ora92\rdbms\admin\spcreate.sql;
2.查看文件夾會產生三個文件
C:\oracle\ora92\bin
spcpkg.lis
spctab.lis
spcusr.lis
C:\oracle\ora92\bin
spcpkg.lis
spctab.lis
spcusr.lis
3.手動執行STATSPACK收集統計信息
SQL> show user
USER爲"PERFSTAT"
SQL> execute statspack.snap;
SQL> show user
USER爲"PERFSTAT"
SQL> execute statspack.snap;
4.生成STATSPACK調整報告
SQL> @C:\oracle\ora92\rdbms\admin\spreport.sql;
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
357371480 COLM 1 colm
Instances in this Statspack schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
----------- -------- ------------ ------------ ------------
357371480 1 COLM colm STEVENHUANG3
Using 357371480 for database Id
Using 1 for instance number
Completed Snapshots
Snap Snap
Instance DB Name Id Snap Started Level Comment
------------ ------------ ----- ----------------- ----- ----------------------
colm COLM 1 11 10月 2006 21:5 5
0
2 11 10月 2006 21:5 5
0
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
輸入 begin_snap 的值: 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 <return> to continue, otherwise enter an alternative.
輸入 report_name 的值: report1.txt
End of Report
SQL> @C:\oracle\ora92\rdbms\admin\spreport.sql;
Current Instance
~~~~~~~~~~~~~~~~
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
357371480 COLM 1 colm
Instances in this Statspack schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
----------- -------- ------------ ------------ ------------
357371480 1 COLM colm STEVENHUANG3
Using 357371480 for database Id
Using 1 for instance number
Completed Snapshots
Snap Snap
Instance DB Name Id Snap Started Level Comment
------------ ------------ ----- ----------------- ----- ----------------------
colm COLM 1 11 10月 2006 21:5 5
0
2 11 10月 2006 21:5 5
0
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
輸入 begin_snap 的值: 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 <return> to continue, otherwise enter an alternative.
輸入 report_name 的值: report1.txt
End of Report
5.查看產生的report1文檔
C:\oracle\ora92\bin\report1.txt
6.自動執行STATSPACK收集統計信息
SQL>@C:\oracle\ora92\rdbms\admin\spauto.sql;
Job number for automated statistics collection for this instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that this job number is needed when modifying or removing
the job:
JOBNO
----------
1
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
6
Next scheduled run
~~~~~~~~~~~~~~~~~~
The next scheduled run for this job is:
JOB NEXT_DATE
---------- ----------
NEXT_SEC
----------------------------------------------------------------
1 11-10月-06
23:00:00
spauto.sql中主要調用dbms_job.submit,默認每小時收集1次(1/24)
variable jobno number;
variable instno number;
begin
select instance_number into :instno from v$instance;
dbms_job.submit(:jobno,'statspack.snap;',trunc(sysdate+1/24,'HH'), 'trunc(SYSDATE+1/24,''HH'')', TRUE, :instno);
commit;
end;
/
可以通過修改這個值設置採集時間
1/24 HH 每小時一次
1/48 MI 每半小時一次
1/144 MI 每十分鐘一次
1/288 MI 每五分鐘一次
7. 移除自動執行STATSPACK收集
SQL>select job,log_user,priv_user,last_date,next_date,interval from user_jobs; --先查看當前自動收集的jobs
SQL> execute dbms_job.remove('1'); --移除任務1
8.刪除統計資料(statspack相關的所有系統表)
SQL>select max(snap_id) from stats$snapshot;
SQL> @C:\oracle\ora92\rdbms\admin\sptrunc.sql;
Warning
~~~~~~~
Running sptrunc.sql removes ALL data from Statspack tables. You may
wish to export the data before continuing.
About to Truncate Statspack Tables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you would like to continue, press <return>
輸入 return 的值:
Entered - starting truncate operation
9.參考資料
http://www.eygle.com/statspack/statspack00.htm
~
http://www.eygle.com/statspack/statspack13.htm
C:\oracle\ora92\bin\report1.txt
6.自動執行STATSPACK收集統計信息
SQL>@C:\oracle\ora92\rdbms\admin\spauto.sql;
Job number for automated statistics collection for this instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Note that this job number is needed when modifying or removing
the job:
JOBNO
----------
1
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
6
Next scheduled run
~~~~~~~~~~~~~~~~~~
The next scheduled run for this job is:
JOB NEXT_DATE
---------- ----------
NEXT_SEC
----------------------------------------------------------------
1 11-10月-06
23:00:00
spauto.sql中主要調用dbms_job.submit,默認每小時收集1次(1/24)
variable jobno number;
variable instno number;
begin
select instance_number into :instno from v$instance;
dbms_job.submit(:jobno,'statspack.snap;',trunc(sysdate+1/24,'HH'), 'trunc(SYSDATE+1/24,''HH'')', TRUE, :instno);
commit;
end;
/
可以通過修改這個值設置採集時間
1/24 HH 每小時一次
1/48 MI 每半小時一次
1/144 MI 每十分鐘一次
1/288 MI 每五分鐘一次
7. 移除自動執行STATSPACK收集
SQL>select job,log_user,priv_user,last_date,next_date,interval from user_jobs; --先查看當前自動收集的jobs
SQL> execute dbms_job.remove('1'); --移除任務1
8.刪除統計資料(statspack相關的所有系統表)
SQL>select max(snap_id) from stats$snapshot;
SQL> @C:\oracle\ora92\rdbms\admin\sptrunc.sql;
Warning
~~~~~~~
Running sptrunc.sql removes ALL data from Statspack tables. You may
wish to export the data before continuing.
About to Truncate Statspack Tables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you would like to continue, press <return>
輸入 return 的值:
Entered - starting truncate operation
9.參考資料
http://www.eygle.com/statspack/statspack00.htm
~
http://www.eygle.com/statspack/statspack13.htm
本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/huanghui22/archive/2006/10/11/1330924.aspx
本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/huanghui22/archive/2006/10/11/1330924.aspx
本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/huanghui22/archive/2006/10/11/1330924.aspx