首页 > 开发 > 综合 > 正文

实用的数据库检查程序(2)

2024-07-21 02:08:34
字体:
来源:转载
供稿:网友

最大的网站源码资源下载站,


ttitle off

 

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt + 3.0 log switch in the last day                                         +

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt

 

ttitle left "*** database: "xdbname", how offen the log switch(as of : "xdate" ) ***" skip 1

 

column archive_name format a40

column "time" format a25

 

select to_char(to_date(time,'mm/dd/rr hh24:mi:ss'),'dd-mon-rrrr hh24:mi:ss') "time",

     archive_name

from v$log_history

where to_date(time,'mm/dd/rr hh24:mi:ss') > sysdate - 1

order by to_date(time,'mm/dd/rr hh24:mi:ss') desc ;

 

prompt

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt 3.0 invesigation

prompt standard:

prompt during periods of high activity , log switches are occurring every 20 minutes

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt

ttitle off

 

prompt

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt + 3.1 log buffer  - redo log space requests : the value                  +

prompt + should be relative small prompt server is waiting for                  +

prompt + disk space to be allocate for redo log entries                         +

prompt + space is created by performing a log switch                            +

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt

 

ttitle left "*** log buffers - redo log space requests ***" skip 1

select substr(name,1,25) "log buffers",

    substr(value,1,15) "value (near 0?)"

from v$sysstat

where name = 'redo log space requests'

/

 

prompt

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt 3.1 investigation

prompt if the value is not near 0 , increase log buffer.

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt

ttitle off

 

prompt

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt + 3.2 log buffer - log buffer space                                      +

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt

ttitle left "*** log buffers - log buffer space waits***" skip 1

select sid , event , seconds_in_wait , state

from v$session_wait

where event = 'log buffer space'

/

 

prompt

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt 3.2 invesigation

prompt there should be no log buffer space waits

prompt making the log buffer bigger if it is small

prompt moving the log files to faster disks such as striped disks

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt

ttitle off

 

prompt

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt + 3.3 log buffer - redo buffer allocation retries                        +

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt

 

ttitle left "*** log buffers - redo buffer allocation retries ***" skip 1

column name print

select name , value

from v$sysstat

where name in ('redo buffer allocation retries','redo entries')

/

 

prompt

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt 3.3 investigation

prompt redo buffer allocation retries should be near 0

prompt the number should be less than 1% of redo entries

prompt increase the size of the redo log buffer (log buffer)

prompt improve the checkpointing or archiving process

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt

ttitle off

 

prompt

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt + 3.4 log buffer - log file switch completion                            +

prompt + identify the log file switch waits because of log switches             +

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt

 

ttitle left "*** log buffers - log file swith completion***" skip 1

select event , total_waits,time_waited,average_wait

from v$system_event

where event like 'log file switch completion%'

/

prompt

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt 3.4 investigation

prompt increase the size of the redo log files

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt

ttitle off

 

prompt

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt + 3.5 log buffer - checkpoint incomplete                                 +

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt

 

ttitle left "*** log buffers - checkpoint incompletion***" skip 1

select event , total_waits,time_waited,average_wait

from v$system_event

where event like 'log file switch (check%'

or event like 'log file switch (arch%'

/

prompt

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt 3.5 investigation

prompt check the frequence of check points and set the appropriate values

prompt for log_checkpoint_interval and log_checkpoint_timeout

prompt check the size and number of redo log groups

prompt confirm that the archive device is not full

prompt add redo log groups

prompt increase the number of buffers to archive and reducing the size of buffers by setting

prompt log_archive_buffers and log_archive_buffer_size

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt

ttitle off

 

prompt

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt + 4.0 share pool size - gets and misses (library cache)                  +

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt

 

column "executions" format 9,999,999,990

column "cache misses executing" format 9,999,999,990

column "data dictionary gets" format 9,999,999,999

column "get misses" format 9,999,999,999

column "% ratio" format 999.99

 

ttitle left skip 1 -

left "*** shared pool size (execution misses) ***" skip 1

 

select sum(pins) "executions",

       sum(reloads) "cache misses executing",

       (sum(reloads)/sum(pins)*100) "% ratio"

from v$librarycache

/

 

prompt

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt 4.0 investigation

prompt if % ratio is above 1% , increase share_pool_size.

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt

ttitle off

 

prompt

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt + 4.1 share pool size - gets and misses (data dictionary)                +

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt

 

ttitle left "*************** shared pool size (dictionary gets) ***********" skip 1

select sum(gets) "data dictionary gets",

       sum(getmisses) "get misses",

       100*(sum(getmisses)/sum(gets)) "ratio"

from v$rowcache

/

 

prompt

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt 4.1 investigation

prompt if % ratio is above 12% , increase shared_pool_size.

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt

ttitle off

 

prompt

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt + 5.0 check which sql is the most cost sql                               +

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt

ttitle off

 

ttitle left "*** v$sql check ***" skip 1

column sql_text format a50

select sql_text,executions,rows_processed,buffer_gets/100,disk_reads/100

from v$sql v,(select sum(buffer_gets) tot_gets from v$sql) s

where buffer_gets > tot_gets * 0.1

order by buffer_gets desc

/

 

prompt

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt 5.0 invesigation

prompt selected sql is the most cost sql (>10% of total gets)

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt

ttitle off

 

prompt

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt + 6.0 how much cpu is used for each session                              +

prompt ++++++++++++++++++++++++++++++++++ item ++++++++++++++++++++++++++++++++++

prompt

ttitle left "*** cpu usage ***" skip 1

column username format a10

column machine format a15

column osuser format a15

column terminal format a15

column program format a20

select s.sid,v.serial#,v.username,v.osuser,v.machine,v.terminal,v.program,s.value "cpu used"

from v$sesstat s,v$statname n , v$session v

where s.statistic#=n.statistic# and n.name='cpu used by this session'

and s.sid = v.sid

/

 

prompt

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt 6.0 invesigation

prompt

prompt <<<<<<<<<<<<<<<<<<< note: >>>>>>>>>>>>>>>>>>>>>>

prompt
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表