|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
对免费版的用户也具有充足的支持服务。在dev.mysql.com上,一个大型的MySQL学习教程强大社区用户和开发者可以讨论所有关于MySQL的事情。这个站点拥有博客、指南、视频、技术交流会、白皮书和论坛等方式的交流。程序|数据|数据库
功效:
1.数据库的基础信息显现(建库工夫,形式等)
2.数据库布局信息-DATABASEMAP(CONTROLFILE,REDOLOGFILE,DATAFILE,ROLLBACKSEGMENT)
3.数据库一切形态信息
4.数据库级的DBBlockBufferHitRatio
5.SESSION级的DBBlockBufferHitRatio
6.前一天的LOGSWITCH情形
7.REDOLOG空间需求查询
8.LOGBuffer功能查询
9.logfileswitch功能查询
10.反省不完整的CHECKPOINT
11.LibraryCache的 功能查询
12.DictionaryCache的 功能查询
13.查找最资本的SQL语句
14.SESSION级的CPU利用度
15.SORT_AREA_SIZE的功能查询
16.SEQUENCE_CACHE_ENTRIES的功能查询
17.CHAINEDROW的查询
18.RollbackSegmentContention反省
19.表空间碎片反省
20.LATCHcontention反省
21.TABLESPACE用量反省
22.数据文件I/O反省
23.表和索引的碎片反省
24.表的HWM反省
利用办法举例:
今朝,作为一个DBA,能够有良多工具来办理,保护和症查数据库.这只是我平常汇集的一些剧本,能够作为DBA随身照顾的小工具程序
在没有其他可视化的工具时,它能够用来对数据库做一些基础的诊断.
1.翻开SQLPLUS,ConnectSystem
2.@a:check_db.sql(a:是本文件的路径)
3.实行终了,了局贮存在C:LOCAL.TXT
4.LOCAL.TXT不仅有每一个数据的申明,同时先容一些办理相干成绩的办法以供参考
Check_db.sql的内容:
SETechooff
spoolc:local.txt
ttitleoff
breakontoday
columntodaynoprintnew_valuexdate
selectsubstr(to_char(sysdate,fmMonthDD,YYYYHH:MI:SSP.M.),1,35)today
fromdual
/
columnnamenoprintnew_valuexdbname
selectnamefromv$database
/
setheadingon
setfeedbackoff
setlinesize250
setpagesize200
rem######################################################################################
rem****CHECK_DB_V2.1:PerformanceTuning****
rem######################################################################################
prompt*******************************************************************************
promptDatabaseCheckInformation
prompt*******************************************************************************
ttitleleft"DATABASE:"xdbname"(ASOF:"xdate")"skip2
selectname,created,log_modefromv$database
/
prompt
prompt*******************************************************************************
ttitleoff
prompt
prompt++++++++++++++++++++++++++++++++++Item++++++++++++++++++++++++++++++++++
prompt+0.0databasemap+
prompt++++++++++++++++++++++++++++++++++Item++++++++++++++++++++++++++++++++++
prompt
ttitleleft"***DataBaseMap-ControlFile***"
column"CONTROLFILE"formatA40
selectstatus,name"CONTROLFILE"fromv$controlfile
/
ttitleoff
ttitleleft"***DataBaseMap-RedoLogFile***"
column"LogFile"formatA40
selectf.member"LogFile",l.group#,l.thread#,l.bytes,l.statusfromv$logl,v$logfilef
wherel.group#=f.group#
/
ttitleoff
ttitleleft"***DataBaseMap-DataFile***"
columnfile_nameformatA40
selectfile_name,tablespace_name,bytes,blocks,statusfromdba_data_filesorderbytablespace_name,bytesdesc
/
ttitleoff
ttitleleft"***DataBaseMap-RollBackSeg***"
SELECTN.NAME"ROLLBACKSEGNAME",R.EXTENTS,r.rssize,R.OPTSIZE,HWMSIZE,STATUS
FROMV$ROLLSTATR,V$rollNAMEN
WHERER.USN=N.USN
/
ttitleoff
prompt++++++++++++++++++++++++++++++++++Item++++++++++++++++++++++++++++++++++
prompt+1.0databasestatistic+
prompt++++++++++++++++++++++++++++++++++Item++++++++++++++++++++++++++++++++++
setheadingon
settermouton
TTitleleft"***Database:"xdbname",DatabaseStatistic(Asof:"xdate")***"skip1
column"StatisticName"formatA55
columnvalueformat9,999,999,999,999,990
selectn.statistic#,n.name"StatisticName",s.value
fromv$statnamen,v$sysstats
wheren.statistic#=s.statistic#
andvalue>0
orderbyvaluedesc
/
ttitleoff
prompt++++++++++++++++++++++++++++++++++Item++++++++++++++++++++++++++++++++++
prompt+2.0DBBlockBuffer-HitRatio(DatabaseWise)+
prompt++++++++++++++++++++++++++++++++++Item++++++++++++++++++++++++++++++++++
setheadingon
settermouton
column"PhysicalReads"format9,999,999,999,999
column"ConsistentGets"format9,999,999,999,999
column"DBBlockGets"format9,999,999,999,999
column"HitRatio"format999.99
TTitleleft"***Database:"xdbname",DBBlockBuffersHitRatio(Asof:"xdate")***"skip1-
left"Percent=((100*(1-(PhysicalReads/(ConsistentGets+DBBlockGets))))"skip2
selectpr.value"PhysicalReads",
cg.value"ConsistentGets",
bg.value"DBBlockGets",
round((1-(pr.value/(bg.value+cg.value)))*100,2)"HitRatio"
fromv$sysstatpr,v$sysstatbg,v$sysstatcg
wherepr.name=physicalreads
andbg.name=dbblockgets
andcg.name=consistentgets
/
prompt<<<<<<<<<<<<<<<<<<<NOTE:>>>>>>>>>>>>>>>>>>>>>>
prompt2.0InvestigationIFPercentislessthan70%,increaseDB_BLOCK_BUFFERS
prompt<<<<<<<<<<<<<<<<<<<NOTE:>>>>>>>>>>>>>>>>>>>>>>
TtitleOff
prompt
prompt
prompt++++++++++++++++++++++++++++++++++Item++++++++++++++++++++++++++++++++++
prompt+2.1DBBlockBuffer-HitRatio(SessionWise)+
prompt++++++++++++++++++++++++++++++++++Item++++++++++++++++++++++++++++++++++
clearbreaks
clearcomputes
breakonreport
computesumofConsistent_Getsonreport
computesumofBlock_Getsonreport
computesumofPhysical_Readsonreport
column"HitRatio%"format999.99
columnUsernameformatA10
TTitleleft"***Database:"xdbname",HitRatioForUserSessions(Asof:"xdate")***"skip1
selectUsername,
OSUSER,
Consistent_Gets,
Block_Gets,
Physical_Reads,
100*(Consistent_Gets+Block_Gets-Physical_Reads)/
(Consistent_Gets+Block_Gets)"HitRatio%"
fromV$SESSION,V$SESS_IO
whereV$SESSION.SID=V$SESS_IO.SID
and(Consistent_Gets+Block_Gets)>0
andusernameisnotnull
orderbyUsername,"HitRatio%";
prompt
prompt<<<<<<<<<<<<<<<<<<<NOTE:>>>>>>>>>>>>>>>>>>>>>>
prompt2.0/2.1Investigation
promptIfyouhave20ormoreusersandbatchuserscauselessthan50%
promptlogicalreadswithinyourdatabase,youshouldaimforahitratio
promptofbetween94%~97%.
promptIfyouhavefewerthan20users,thesharingofdataamongusersdepends
promptheavilyontheapplication,soyoushouldaimforahitratiointhe89%~94%
prompt<<<<<<<<<<<<<<<<<<<NOTE:>>>>>>>>>>>>>>>>>>>>>>
prompt
prompt
”由于MySQL已经是一个运行了众多知名Web2.0网站的数据,包括Craigslist、Digg、Wikipedia和Google等,或许我们可以说每一个Web2.0公司实质上是一个使用MySQL数据库的公司。 |
|