dbccchecktable:SYBASE dbcc




  dbcccheckstorage检查数据库致性在新版本数据库中用处比任何个DBCC命令都大尤其在数据库备份前这篇文章用意是帮助你:

Ø掌握dbcccheckstorage命令
Ø维护dbccdb数据库
Ø根据dbccdb生成报告

  本文使用案例中你将首先由sp_plan_dbccdb输出得到运行dbcccheckstorage命令所需资源环境并在此基础上规划资源建立dbccdb数据库最终根据dbccdb数据库生成报告

本节练习将基于如下环境:

Ø系统中存在用户数据库aca_db容量为20MB(数据10MB、日志10MB)
Øaca_db数据库占用disk1和disk2两个设备
Øaca_db数据库中有若干个用户表(auths,article等)

步骤如下:

1、为目标数据库获取有关数据库大小、设备工作空间大小高速缓存Cache大小和工作进程数建议

sp_plan_dbccdbaca_db

执行结果为:

Recommendedsizefordbccdbdatabaseis15MB(data=13MB,log=2MB).
Nosuitabledevicesfordbccdbinmaster..sysdevices.
Recommendedvaluesforworkspacesize,cachesizeandprocesscountare:
dbnamescanwstextwscacheprocesscount
aca_db272K80K1280K2
(status=0)

2、如果必要调整AdaptiveServer工作进程数

3、为dbcc创建命名高速缓存Cache

  配置个dbcccheckstorage专用命名高速缓存Cache不仅可以提高性能并且还可以使数据库致性检查对其他用户影响降到最小

  Dbcccheckstorage要求在命名高速缓存Cache16k内存池中为每个工作进程准备至少640k存储空间16k内存池最小容量为推荐高速缓存Cache容量

  Sp_cacheconfigaca_cache,”3072k”

(注意:重新启动AdaptiveServer才起作用)

4、配置16kI/O缓存Cache池

sp_poolconfigaca_cache,”2048”,”16k”
使用sp_poolconfigaca_cache命令查看命名高速缓存Cache结果如下
CacheNameStatusTypeConfigValueRunValue
-----------------------------------------
aca_cacheActiveMixed3.00Mb3.00Mb
IOSizeWashSizeConfigSizeRunSizeAPFPercent
----------------------------------------------
2Kb204Kb0.00Mb1.00Mb10
16Kb400Kb2.00Mb2.00Mb10


4、如果dbccdb存在则在创建新dbccdb数据库的前删除它及其相关所有设备

usemaster
go
exists(select*frommaster.dbo.sysdatabases
wherename="dbccdb"\" border=0>
begin
pr"+Droppingthedbccdbdatabase"
dropdatabasedbccdb
end
go

5、化用于dbccdb数据和日志磁盘设备

diskinit
name="dbccdb_dat",
physname="d:\\sybase\\example\\dbccdata.dat",
vdevno=6,
size=7680
diskinit
name="dbccdb_log",
physname="d:\\sybase\\example\\dbcclog.dat",
vdevno=7,
size=1024

6、在数据库设备上创建dbccdb数据库

createdatabasedbccdb
ondbcc_dat=13
logondbccdb_log=2

7、添加磁盘段

usedbccdb
sp_addsegmentscanseg,dbccdb,dbccdb_dat
sp_addsegmenttextseg,dbccdb,dbccdb_dat

8、填充dbcc数据库并安装dbcc存储过程

执行dbccdb脚本为dbccdb创建表并化dbcc-type表

isql-Usa–P-S-Iidbccdb

9、建立和化scan和text空间

sp_dbcc_createwsdbccdb,scanseg,scan_aca,scan,"272k"
sp_dbcc_createwsdbccdb,textseg,text_aca,text,"80k"
10、更新dbcc_config配置值
usedbccdb
sp_dbcc_updateconfigaca_db,"maxworkerprocesses","2"
sp_dbcc_updateconfigaca_db,"dbccnamedcache",aca_cache,"3072"
sp_dbcc_updateconfigaca_db,"scanworkspace",scan_aca
sp_dbcc_updateconfigaca_db,"textworkspace",text_aca
sp_dbcc_updateconfigaca_db,"OAMcountthreshold","5"
sp_dbcc_updateconfigaca_db,"IOerrorabort","3"
sp_dbcc_updateconfigaca_db,"linkageerrorabort","8"

11、检查aca_db数据库

dbcccheckstorage(aca_db)

执行结果为:

Checkingaca_dbServerMessage:Number9954,Severity10
Line1:
Storagechecksfor\'aca_db\'arecomplete.DBCCisnowrecordingtheresultshedbccdbdatabase.


ServerMessage:Number9974,Severity10
Line1:
DBCCCHECKSTORAGEfordatabase\'aca_db\'sequence1completedatMay30200010:01AM.0faultsand0suspectconditionswerelocated.0checkswereaborted.Youshouldinvestigatetherecordedfaults,andplanacourseofactionthatwillcorrectthem.

11、dbccdb生成报告

Øsp_dbcc_summaryreport在指定日期或该日期的前为指定数据库完成所有dbcccheckstorage操作

举例:

sp_dbcc_summaryreport

DBCCOperation:checkstorage
(1rowaffected)
(status=0)
DatabaseNameStarttimeEndTimeOperationIDHardFaultsSoftFaultsTextColumnsAbortCountUserName
-------------------------------------------------------------------------------------------------aca_db05/30/200010:01:3610:1:50:50310000sa
Øsp_dbcc_configreport为目标数据库生成配置信息报告

举例:

sp_dbcc_configreport

Reportingconfigurationinformationofdatabaseaca_db.
ParameterNameValueSize
databasenameaca_db20480K
dbccnamedcacheaca_cache3072K
textworkspacetext_aca(id=544004969)80K
scanworkspacescan_aca(id=512004855)272K
OAMcountthreshold5%
IOerrorabort3
linkageerrorabort8
maxworkerprocesses2
operationsequencenumber1
(1rowaffected)
(status=0)
Øsp_dbcc_statisticsreport产生从dbcc_counter表中得到统计信息

举例:

sp_dbcc_statisticsreport"aca_db","auths"

结果:

ParameterNameIndexIdValue
---------------------------
count020.0
maxsize088.0
maxcount020.0
sdata01321.0
sused01599.0
count11.0
maxcount11.0
maxlevel10.0
maxsize111.0
sdata16.0
sused143.0
count2550.0
maxsize2550.0
maxcount2550.0
sdata2550.0
sused2550.0
ParameterNameIndexIdPartitionValueDev_name
--------------------------------------------
pagegaps011.0disk1
pagesused012.0disk1
extentsused011.0disk1
overflowpages010.0disk1
pagesoverhead011.0disk1
pagesreserved016.0disk1
pageextentgaps010.0disk1
wsbuffercrosses010.0disk1
pageextentcrosses010.0disk1
pagegaps111.0disk1
pagesused112.0disk1
extentsused111.0disk1
overflowpages110.0disk1
pagesoverhead111.0disk1
pagesreserved116.0disk1
pageextentgaps110.0disk1
wsbuffercrosses110.0disk1
pageextentcrosses110.0disk1
pagegaps25511.0disk1
pagesused25512.0disk1
extentsused25511.0disk1
overflowpages25510.0disk1
pagesoverhead25511.0disk1
pagesreserved25516.0disk1
pageextentgaps25510.0disk1
wsbuffercrosses25510.0disk1
pageextentcrosses25510.0disk1
Øsp_dbcc_faultreport报告指定数据库对象中发现在指定日期或该日期的前发生故障可以生成短报告也可以生成长报告

举例:

sp_dbcc_faultreport\'\'


sp_dbcc_faultreport\'long\'




jazy 回复于:2002-09-16 16:33:46大家觉得是不是很有必要建立个dbccdb数据库?讨论下这样做可以带来哪些好处?

jazy 回复于:2002-09-16 16:37:06如果我执行sp_plan_dbccdb的后结果为:

Recommendedsizefordbccdbdatabaseis370MB(data=368MB,log=2MB).

Nosuitabledevicesfordbccdbinmaster..sysdevices.

Recommendedvaluesforworkspacesize,cachesizeandprocesscountare:

dbnamescanwstextwscacheprocesscount



master2464K624K640K1
tempdb25200K6304K6301K2
model64K48K640K1
testdb214M53M53M7
sybsystemdb64K48K640K1
sybsystemprocs2464K624K640K1


那么我是不是需要创建个大小为370MBdbccdatabase?

freebob 回复于:2002-09-16 17:26:55dbccdb数据库我觉得很有必要如果你数据不容有任何差错还是建立为好
但运行dbcccheckstorage很费时而且在singleuser下用;

jazy 回复于:2002-09-16 17:33:12我们业务数据库是24小时所以很难有机会进行这样耗时操作顺便问我定时执行dbcc操作就可以了为什么定要建库呢?

freebob 回复于:2002-09-16 18:03:23dbcccheckstorage
产生结果存放在dbccdb数据库表里如果你不deletehistory,它会直保存
dbcccheckdb,dbcccheckalloc,...
你只有定向输出到文件里
如果你在dbcccheckstorage时还有对数据库操作结果会有歧义
我现在backup前只对关键表作dbccchecktable,dbcctablealloc等

我建议有条件建立个和生产机数据库将dump数据库load到哪里
dbcccheckstorage,如果发现修正后再load回生产机
我现在就这么干

jazy 回复于:2002-09-16 18:22:53是个好主意dump速度很快这样就不会长时间影响业务运行了!

不过有机会再试吧!

月冷西湖 回复于:2002-09-16 18:27:16我们数据库直用DUMP很安全可靠

chuxu 回复于:2002-11-11 16:27:48dbcccheckstorage命令执行速度最快检查最全面而且只产生共享锁应该是最好选择


jazy 回复于:2002-11-11 16:35:10执行dbccheckdb(database)时业务将完全受影响!至于执行dbcccheckstorage能否足够全面以及是否会影响业务我还没做过测试待会测下看看!

jazy 回复于:2002-12-07 20:57:21在进行sp_plan_dbccdb时我觉得系统是根据某库所占有设备数来给出numberofworkerprocesses推荐值比如你生产库使用了7个设备那么将给出numberofworkerprocesses为7推荐值!但是实际上你可以多配点也可以相应少配点另外配置改参数需要rebootASE所以不可轻易在生产环境中进行修改!另外在配置命名缓存Cache时也需要进行rebootserver!


jimhongchen 回复于:2002-12-31 02:04:03Iperformedallcommandsneededforcreatingdbccdbforpubs2.
WhydoIhavethefollowingerrormessage?
Iused"sp_dbcc_evaluatedb"tocheckandeverythingseemedtobeok.



1>dbcccheckstorage(pubs2)
2>go
Checkingpubs2
Msg9961,Level17,State3:
Line1:
DBCCfailedtoconnecttotherequestednumberofworkerprocesses.Thenumberofworkersconfiguredisinsufficient,orthenumberofworkersexceeds128.Usesp_dbcc_updateconfigtoreduce\'maxworkerprocesses\'forthisdatabase.
Msg9960,Level20,State1:
Line1:
Anon-recoverableerrorhasoccurredheCHECKSTORAGEoperation.Theoperationhasbeenaborted.
DBCCCHECKSTORAGEfordatabase\'pubs2\'encounteredanerror.Someresultsmaynotbeavailable.CorrecttheproblemsreportedandreexecutetheCHECKSTORAGEcommand.
1>
2>re
1>sp_dbcc_evaluatedb
2>go
Recommendedvaluesforworkspacesize,cachesizeandprocesscountare:

Databasename:pubs2
currentscanworkspacesize:64Ksuggestedscanworkspacesize:64K
currenttextworkspacesize:48Ksuggestedtextworkspacesize:48K
currentcachesize:640Ksuggestedcachesize:640K
currentprocesscount:1suggestedprocesscount:1


(status=0)
1>



bigbug99 回复于:2002-12-31 17:31:03我前面配置都差不多但执行到这里如何报错了?
1>dbcccheckstorage(wxjj)
2>go
Checkingwxjj:Logicalpagesizeis2048s
Msg9961,Level17,State6:
Server\'wxjj\',Line1:
DBCCfailedtoconnecttotherequestednumberofworkerprocesses.Thenumber
ofworkersconfiguredisinsufficient,orthenumberofworkersexceeds128.Use
sp_dbcc_updateconfigtoreduce\'maxworkerprocesses\'forthisdatabase.
Msg9960,Level20,State1:
Server\'wxjj\',Line1:
Anon-recoverableerrorhasoccurredheCHECKSTORAGEoperation.The
operationhasbeenaborted.
DBCCCHECKSTORAGEfordatabase\'wxjj\'encounteredanerror.Someresultsmaynot
beavailable.CorrecttheproblemsreportedandreexecutetheCHECKSTORAGE
command.


jazy 回复于:2002-12-31 22:28:25很明显,你们workerprocesses不足!

rekcah0 回复于:2003-01-01 22:33:53请问各位大师们:
1.dbcccheckstorage带不带fix功能?
2.如果我系统完全能容忍我任意执行dbcccheckdb,dbcccheckalloc且我对输出内容保存方式不敏感话,dbcccheckstorage还比dbcccheckdb,dbcccheckalloc优越吗?

bigbug99 回复于:2003-01-02 12:01:47我执行第步结果如下哪位大虾帮我搞个好DBCC方案出来?多谢
1>sp_plan_dbccdbwxjj
2>go

Recommendedsizefordbccdbdatabaseis38MB(data=36MB,log=2MB).

Nosuitabledevicesfordbccdbinmaster..sysdevices.

Recommendedvaluesforworkspacesize,cachesizeandprocesscountare:

dbnamescanwstextwscacheprocesscount


wxjj18448K4624K4615K2

(status=0)


菜虾 回复于:2003-01-04 04:00:07收藏

jimhongchen 回复于:2003-01-04 23:47:55Jazy,thankyou.
Isolvedmyproblemafteryourh.
bigbug99,youcanusefollowingcommandtoincreahenumberofworkerprocess.



1>sp_configure"numberofworkerprocesses",1
2>go
ParameterNameDefaultMemoryUsedConfigValueRunValue
---------------------------------------------------------------------------
numberofworkerprocesses017611

(1rowaffected)
Configurationoptionchanged.Sincetheoptionis,AdaptiveServermustberebootedinorderforthechangetotakeeffect.
(status=0)
1>

Tags:  dbccdbreindex dbcccheckdb dbccshrinkfile dbccchecktable

延伸阅读

最新评论

发表评论