實用的資料庫檢查程式 (1) (轉)
:namespace prefix = o ns = "urn:schemas--com::office" />
功能:
1. 的基本資訊顯示(建庫時間,等)
2. 資料庫結構資訊-DATABASE MAP(CONTROL FILE, REDO LOG FILE, DATAFILE, ROLLBACK SEGMENT)
3. 資料庫所有狀態資訊
4. 資料庫級的 Block Buffer Hit Ratio
5. SESSION級的DB Block Buffer Hit Ratio
6. 前一天的LOG SWITCH情況
7. REDO LOG 空間需求查詢
8. LOG Buffer 查詢
9. log file switch效能查詢
10. 檢查不完全的CHECKPOINT
11. Library Cache 的 效能查詢
12. Dictionary Cache的 效能查詢
13. 查詢最資源的語句
14. SESSION級的使用度
15. SORT_AREA_SIZE的效能查詢
16. SEQUENCE_CACHE_ENTRIES的效能查詢
17. CHAINED ROW的查詢
18. Rollback Segment Contention 檢查
19. 表空間碎片檢查
20. LATCH contention 檢查
21. TABLESPACE 用量檢查
22. 資料I/O檢查
23. 表和的碎片檢查
24. 表的HWM檢查
使用方法舉例:
目前,作為一個,可以有很多工具來管理,維護和症查資料庫.這只是我平時蒐集的一些指令碼,可以作為DBA隨身攜帶的
在沒有其他視覺化的工具時,它可以用來對資料庫做一些基本的診斷.
1.開啟SQLPLUS , Connect System
2.@a:check_db.sql (a:是本檔案的路徑)
3.完畢,結果儲存在C:LOCAL.TXT
4.LOCAL.TXT 不但有每個資料的說明,同時介紹一些解決相關問題的方法以供參考
Check_db.sql的內容:
SET echo off
spool c:local.txt
ttitle off
break on today
column today noprint new_value xdate
substr(to_char(sysdate,'fmMonth DD, YYYY HH:MI:SS P.M.'),1,35) today
from dual
/
column name noprint new_value xdbname
select name from v$database
/
set heading on
set feedback off
set linesize 250
set pagesize 200
rem ######################################################################################
rem **** CHECK_DB_V2.1: Performance Tuning****
rem ######################################################################################
prompt *******************************************************************************
prompt Database Check Information
prompt *******************************************************************************
ttitle left "DATABASE: "xdbname" (AS OF: "xdate")" sk2
select name , created , log_mode from v$database
/
prompt
prompt *******************************************************************************
ttitle off
prompt
prompt ++++++++++++++++++++++++++++++++++ Item ++++++++++++++++++++++++++++++++++
prompt + 0.0 database map +
prompt ++++++++++++++++++++++++++++++++++ Item ++++++++++++++++++++++++++++++++++
prompt
ttitle left "*** DataBase Map - Control File ***"
column "CONTROL FILE" format A40
select status , name "CONTROL FILE" from v$controlfile
/
ttitle off
ttitle left "*** DataBase Map - RedoLog File ***"
column "Log File" format A40
select f.member "Log File",l.group# ,l.thread# ,l.bytes ,l.status from v$log l, v$logfile f
where l.group# = f.group#
/
ttitle off
ttitle left "*** DataBase Map - Data File ***"
column file_name format A40
select file_name ,tablespace_name,bytes,blocks,status from dba_data_files order by tablespace_name , bytes desc
/
ttitle off
ttitle left "*** DataBase Map - RollBack Seg ***"
SELECT N.NAME "ROLLBACK SEG NAME" , R.EXTENTS , r.rssize , R.OPTSIZE , HWMSIZE ,STATUS
FROM V$ROLLSTAT R,V$rollNAME N
WHERE R.USN = N.USN
/
ttitle off
prompt ++++++++++++++++++++++++++++++++++ Item ++++++++++++++++++++++++++++++++++
prompt + 1.0 database statistic +
prompt ++++++++++++++++++++++++++++++++++ Item ++++++++++++++++++++++++++++++++++
set heading on
set termout on
TTitle left "*** Database: "xdbname", Database Statistic(As of : "xdate" ) ***" skip 1
column "Statistic Name" format A55
column value format 9,999,999,999,999,990
select n.statisti , n.name "Statistic Name", s.value
from v$statname n , v$sysstat s
where n.statistic# = s.statistic#
and value > 0
order by value desc
/
ttitle off
prompt ++++++++++++++++++++++++++++++++++ Item ++++++++++++++++++++++++++++++++++
prompt + 2.0 DB Block Buffer - Hit Ratio (Database Wise) +
prompt ++++++++++++++++++++++++++++++++++ Item ++++++++++++++++++++++++++++++++++
set heading on
set termout on
column "Physical Reads" format 9,999,999,999,999
column "Consistent Gets" format 9,999,999,999,999
column "DB Block Gets" format 9,999,999,999,999
column "Hit Ratio" format 999.99
TTitle left "*** Database: "xdbname", DB Block Buffers Hit Ratio (As of : "xdate" ) ***" skip 1-
left "Percent = ((100*(1-(Physical Reads/(Consistent Gets + DB Block Gets))))" skip 2
select pr.value "Physical Reads",
cg.value "Consistent Gets",
bg.value "DB Block Gets",
round((1-(pr.value/(bg.value+cg.value)))*100,2) "Hit Ratio"
from v$sysstat pr, v$sysstat bg, v$sysstat cg
where pr.name = 'physical reads'
and bg.name = 'db block gets'
and cg.name = 'consistent gets'
/
prompt <<<<<<<<<<<<<<<<<<< NOTE: >>>>>>>>>>>>>>>>>>>>>>
prompt 2.0 Investigation IF Percent is less than 70% , increase DB_BLOCK_BUFFERS
prompt <<<<<<<<<<<<<<<<<<< NOTE: >>>>>>>>>>>>>>>>>>>>>>
Ttitle Off
prompt
prompt
prompt ++++++++++++++++++++++++++++++++++ Item ++++++++++++++++++++++++++++++++++
prompt + 2.1 DB Block Buffer - Hit Ratio (Session Wise) +
prompt ++++++++++++++++++++++++++++++++++ Item ++++++++++++++++++++++++++++++++++
clear breaks
clear computes
break on report
compute sum of Consistent_Gets on report
compute sum of Block_Gets on report
compute sum of Physical_Reads on report
column "Hit Ratio %" format 999.99
column Username format A10
TTitle left "*** Database: "xdbname", Hit Ratio For User Sessions(As of : "xdate" ) ***" skip 1
select Username,
OSUSER,
Consistent_Gets,
Block_Gets,
Physical_Reads,
100*( Consistent_Gets + Block_Gets - Physical_Reads)/
( Consistent_Gets + Block_Gets ) "Hit Ratio %"
from V$SESSION,V$SESS_IO
where V$SESSION.SID = V$SESS_IO.SID
and ( Consistent_Gets + Block_Gets )>0
and username is not null
order by Username,"Hit Ratio %";
prompt
prompt <<<<<<<<<<<<<<<<<<< NOTE: >>>>>>>>>>>>>>>>>>>>>>
prompt 2.0/2.1 Investigation
prompt If you have 20 or more users and batch users cause less than 50%
prompt logical reads within your database , you should aim for a hit ratio
prompt of between 94% ~ 97%.
prompt If you have fewer than 20 users , the sharing of data among users depends
prompt heavily on the application , so you should aim for a hit ratio in the 89%~94%
prompt <<<<<<<<<<<<<<<<<<< NOTE: >>>>>>>>>>>>>>>>>>>>>>
prompt
prompt
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10748419/viewspace-959632/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 實用的資料庫檢查程式(3) (轉)資料庫
- 資料庫健康檢查(轉)資料庫
- 資料庫配置檢查資料庫
- (轉)oracle 資料庫效能健康檢查指令碼Oracle資料庫指令碼
- 實現 .Net 7 下的資料庫定時檢查資料庫
- oracle 資料庫效能健康檢查指令碼[轉帖]Oracle資料庫指令碼
- 資料庫的查詢與檢視資料庫
- 用Python實現資料庫程式設計 (轉)Python資料庫程式設計
- Excel資料庫轉MySQL,實現查詢Excel資料庫MySql
- MySQL資料庫健康檢查--MySQL巡檢MySql資料庫
- oracle資料庫巡檢(二)全面檢查Oracle資料庫
- ORAchk-資料庫健康檢查資料庫
- 資料庫的常規檢查指令碼資料庫指令碼
- 資料庫的檢查步驟指令碼資料庫指令碼
- MSSQL資料庫健康檢查--SQL Server巡檢SQL資料庫Server
- oracle資料庫巡檢(轉)Oracle資料庫
- 資料遷移中的資料庫檢查和建議資料庫
- 用jsp實現資料庫的增刪改查JS資料庫
- 漫談Oracle資料庫健康檢查Oracle資料庫
- Oracle資料庫健康檢查常用SQLOracle資料庫SQL
- 物化檢視實現資料庫倉庫主從複製(1)資料庫
- jmap檢視java程式佔用的資料庫連線數Java資料庫
- 資料庫檢視詳解 (轉)資料庫
- 【轉】檢視Oracle資料庫阻塞Oracle資料庫
- sqlServer的資料庫回縮與表大小檢查。SQLServer資料庫
- oracle檢查資料庫是否有壞塊的命令Oracle資料庫
- 備份後,對資料庫的穩定性檢查資料庫
- 巧用shell生成資料庫檢查指令碼資料庫指令碼
- oracle 資料庫效能健康檢查指令碼Oracle資料庫指令碼
- oracle資料庫健康檢查報告模板Oracle資料庫
- 怎樣檢查資料庫壞塊(DBV)資料庫
- 資料庫日常健康檢查方式方法資料庫
- 檢查資料庫是否啟用了跟蹤資料庫
- 實用程式-從DNS 查IP(轉)DNS
- 實用的檢測解析度的程式程式碼 (轉)
- SQL Server實戰四:查詢資料庫的資料SQLServer資料庫
- 用checkstyle實現svn的程式碼規範性檢查
- 檢查點和oracle資料庫的恢復(一)SCNOracle資料庫