ORACLE10GR2 STATSPACK安装及分析报告生成
1. 建立收集数据所用的tablespace
CREATE TABLESPACE PERFSTAT DATAFILE
'/u02/oradata/dbtest/dbtest/perfstat01.dbf' SIZE 128M AUTOEXTEND ON NEXT 2M MAXSIZE 1024M
LOGGING
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
2. 安装
2.1 cd $ORACLE_HOME/rdbms/admin为了方便运行SQL
2.2 以sysdba身份登录
sqlplus / as sysdba
2.3 运行spcreate安装statspack
@spcreate
在安装过程中会要求输入default tablespace和temporary tablespace并会创建一个名为perfstat的用户
2.4 查看.lis文件确保正确安装
grep ORA_ *.lis
grep err *.lis
若有错误发生可以spdrop删除安装,再次运行spcreate安装
3.修改参数为收集数据做准备
3.1 alter system set job_queue_processes=16 scope=both;
3.2 alter system set timed_statistics=true scope=both;
4.收集数据
4.1 你可以 通过修改spauto.sql来改变数据收集的频率
如:
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 每10分钟一次
1/228 MI 每5分钟一次
4.2 运行spauto开始数据收集
spauto.sql中有如下Rem
SQL> Rem Should be run as the STATSPACK owner, PERFSTAT.
SQL> Rem Requires job_queue_processes init.ora parameter to be
SQL> Rem set to a number >0 before automatic statistics gathering
SQL> Rem will run.
@spauto
5. 生成分析报告
@spreport
6. 删除job
6.1 找出job_id
select job , next_date ,interval from user_jobs;
6.2删除job
exec dbms_job.remove(‘job_id’)
snap_id不连续
select snap_id ,to_char(snap_time ,'yyyy-mm-dd hh24:mi') from stats$snapshot order by 1;
SNAP_ID TO_CHAR(SNAP_TIM
---------- ----------------
951 2008-05-26 15:50
961 2008-05-26 16:20
962 2008-05-26 16:50
971 2008-05-26 17:20
972 2008-05-26 17:50
解决方法
alter sequence stats$snapshot_id nocache;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7419833/viewspace-312645/ ,如需转载,请注明出处,否则将追究法律责任。