ORACLE配置STATSPACK步骤
配置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> @C:/oracle/ora92/rdbms/admin/spcreate.sql;
输入 perfstat_password 的值: perfstat
输入default_tablespace的值: perfstat
输入temporary_tablespace 的值: temp
NOTE:
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;
2.查看文件夹会产生三个文件
C:/oracle/ora92/bin
spcpkg.lis
spctab.lis
spcusr.lis
3.手动执行STATSPACK收集统计信息
SQL> show user
USER为"PERFSTAT"
SQL> execute statspack.snap;
4.生成STATSPACK调整报告
SQL> @C:/oracle/ora92/rdbms/admin/spreport.sql;
DB Id DB Name Inst Num Instance
----------- ------------ -------- ------------
Instances in this Statspack schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DB Id Inst Num DB Name Instance Host
----------- -------- ------------ ------------ ------------
357371480 1 COLM colm STEVENHUANG3
Using 357371480 for database Id
Instance DB Name Id Snap Started Level Comment
------------ ------------ ----- ----------------- ----- ----------------------
colm COLM 1 11 10月 2006 21:5 5
Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
C:/oracle/ora92/bin/report1.txt
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
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:
------------------------------------------------------------------------------
------------------------------------------------------------------------------
The next scheduled run for this job is:
----------------------------------------------------------------
spauto.sql中主要调用dbms_job.submit,默认每小时收集1次(1/24)
select instance_number into :instno from v$instance;
SQL>select job,log_user,priv_user,last_date,next_date,interval from user_jobs; --先查看当前自动收集的jobs
SQL> execute dbms_job.remove('1'); --移除任务1
SQL>select max(snap_id) from stats$snapshot;
SQL> @C:/oracle/ora92/rdbms/admin/sptrunc.sql;
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>
Entered - starting truncate operation