a db2 performance tuning roadmap --log introduction本文的内容是在整理报表时,对db2 stat log avitivity部分的一个补充,主要介绍了db2 log作用,overhead,涉及的部件以及部件之间的工作机制如何利用db2 log,现有的ibm 提供的 db2 log utilities。最后对db2 log的逻辑给出一个感性的认识。1 log overview db2 log fundamentals log aim: why need logging in perfect world overview of log work mechanism 2 understanding of log log implementation 1 log rba 2 when data sharing involed-lrsn 3 log page data sets factors of active log data sets: bsds – boot strap data set syslgrnx-dld factors of archive log datasets log structure what is being logged? information of ur page set information recovery infomation for system checkpoints undo/redo log exmplae compensation of log exmple recovery information example system checkpoints detail when is logging log usage start db2 recovery of objects replication sox compliance health checks log utilites,working with the log dsn1logp dsnju004、dsnju003 dsnju004 dsnju003 (a.k.a change log inventory) dsnjlogf recover bsds #recover bsds log related dataset log page format
1 log overviewdb2 log fundamentalslog aim:the db2 log has two main functions: to reapply or back out units of recovery, and to rebuild db2 back to a consistent state in the event of a failure
why need loggingoverheadit costs in ters of performance,dasd,dministration,cleanupit's assurance-just in case of an accidentin perfect worldno need to rollbackno need to recoverno program errorsno hardware errorsno power failturesno hurricances,terror attacks,fraud....let’s get the most out of the log since it’s here
overview of log work mechanism
usage of each components
active logswhere db2 puts the current log informationlog bufferswhere log information is held before externalisation to dasdbootstrap datasetsthese hold information about the current active and archive log datasetsarchive logsthese are copies of ‘old’ active log datasetssyslgrnxdb2 keeps track of when objects are (possibly) being updated2 understanding of loglog implementation1 log rbabyte addressable(rba=relative byte address)rba start=0x00000000000rba end=0xfffffffffffrba uniquely define a log record
2 when data sharing involed-lrsn
lrsn=log sequence range number,which is a modified timestamp base on sysplex storce clock
3 log page data setslog outputbufferactive logarchive log
when db2 go to the last active data sets ,wrap round to first active log data sets
factors of active log data sets:active log data sets numberactive log data sets sizesingle or dual active logperformance consideration:fast dasdconsider strippingdb2 zparm outbuffer+ logapstgbsds – boot strap data set? name: catalog.bsds01 and catalog.bsds02? must be two identical datasets? contains highest rba logged? contains active log description (begin – end rba and status)? contains archive log description? dataset name? volume name? rba range? contains other necessary system information? system checkpoint history, bp-description, ccsid info etc
syslgrnx-dld? table in directory so no user access available? contains the rba when any tablespace orpartition is opened or closed for update? note this information is also in db2 log? syslgrngx is used by db2 to speed uprecovery by limiting the amount of log data which needs to be scanned? modify utility removes this information along with syscopy rows
syslgrngx is key to speeding up log processing during recovery contains rbas when tablespaces are open for update. log ranges out ranges cannot contain updates for this tablespace and therefore we needed during the recovery process.syslgrngx is also updated by running the modify recovery utility
factors of archive log datasetsalways produce two files for one active logsit is an asynchronous processvcat.archlogn.bnnnnnncontainds the bsds information before archive is written first log being archived,is still known as active log in bsds
vcat.archiven.annnnnncontains the actual log for log rba range of than log data setsupdates bsds when complete
db2 zparms archpfx1+archpfx2+tstamp=yes|no|extvcat.archiven.dxxxxx.txxxxx.bnnnnnnnnwhen archive:active log fulltruncated:archive log comamnd or errorlog structurewhat is being logged?information of urbegin/end ur informationundo/redo statements and compensation log reccommit rollback processingpage set informationopen/close page setpending status information(copy,check,reorg)start/stop information(include which mode ut)dbd inforecovery infomation forinvoled tables:sysibm.sysutilx sysibm.dbd01 sysibm.syscopy
system checkpointsundo/redo log exmplaeupdate tset col='bbb'where id=1lrh004a002f 06000001 0e800006 cea48cc9 0006cea4 8d590526 0006cea4 8d59c7c0af504b23 0000
*lg** 80010c00 02000000 02000006 cea4049e 2b02 0000 00120101 00030900 000600c2 c2c200c1 c1c1
c2c2c2='bbb'c1c1c1='aaa'urid(0006cea48cc9)rba of ur started in log010c=dbid0002==page set obid000000 02=page id
compensation of log exmple
in case of the example the current value is bbb and after the update it should become aaa, but for some reason a rollback occurs, in thatcase db2 needs to undo this update. this undo by itself is also being logged. these log records are called compensation log records.
subtype(update in-place in a data page) clr(yes)*lg** 80010c00 02000000 02000006 cea550bf ab00 0000 00120101 00030900 000600c2 c2c200c1 c1c1
clr(yes) which indicates it is a compensation log record
recovery information exampledb2 writes “syscopy” information for certain system tables to the log instead of writing it to syscopy. the reason is simple. in case of adisaster recovery, we need to recover the system in precise steps.meaning that certain system tables have to be recovered before we can recover sysibm.syscopy. therefore the backup information of those objects is written to the log.
system checkpoints detailsystem checkpoint (snapshot of activity on system)
what is in system checkpointentry per active thread (amongst other status inflight/in commit etc)entry per open page set (including exception status)page externalizationhow often should one be taken ?every 3-5 minutes (many sites are at 15-20 minutes)chkfreq : v9 : # log records or # seconds v10: minimum of # log records and # seconds
important for (re)start up performance? start up always from last checkpointwhen is loggingas the work is being done? in log output buffer (outbuff)? regularly flushed to active log datasetsequentially first active copy1 then active copy2 (db2 v10 应该是双写)? at commit? at rollback? log write threshold (wrthrsh 20 pages without commit)? archive log command? system checkpoint? log write ahead force
log usagestart db24 phases :
log initializationread/compare bsdsfind current active log dataset and end of logcurrent status rebuildread last system checpointforward log recoverydo all work for incommit and indoubt threadsbackward log recoverydo all work for inabort and inflight threadsalways start from last system checkpointamount of work varies (ab)normal shutdownrecovery of objectsdb2 新增了一个参数backout(yes),这个参数应该不是太常用,更多的情况应该是使用imgcopy+log的方式去追,即point-in-time,这里不进行介绍。
replication现在idc内相当火的一个topic,它是实现双活或是多活的基础,平台版本的dbms也有实现,比如mysql的mater-slave方式,即mysql本身就支持,不需要新增软件,但是是单线程进行处理,为此很多vendors提供了增强版的版本使slave上支持并发。zos 上使用qrep+mq实现,支持异构数据库,延迟可以控制在分钟以内。rpt=2min,rto=2hour,
sox compliance这个更多是的是内审,外审的用途。相对来说使用审计log的方式,成本还是比较高的,有alternative software。
health checksbest practice,根据系统现在的运行情况,查看时候active log,achive log是否运行异常。
log utilites,working with the log多少一句,这个应该是目前平台比较欠缺的,可能目前也存在,只是我孤陋寡闻了。
dsn1logp? formats db2 log in a readable output? detailed or summarized (summary(yes/no/only)? include page set status (dataonly(yes/no)? include syscopy info (syscopy(yes/no)? limit range (from – to)? limit scope (e.g. urid,dbid,)? cannot read current active log? cannot read compressed logs by dfsms
dsnju004、dsnju003dsnju004will list certain parts of the bsds information? log data set name(s), log ranges, volume(s) etc? active log status? conditional restart history? system checkpoint history? backup system history? archive log history? ccsid information? does not show buffer pool configuration? be careful time values are in gmt except ltime column
dsnju003 (a.k.a change log inventory)? only runs when db2 is down? allows to change bsds content, use with care!? add/delete active and archive logs? add/delete system checkpoints? create conditional restart record (crestart)? startrba? endrba? cold start ? startrba=endrba? causes most of the time data loss
dsnjlogfdsnjlogf? pre-formats new active log dataset? avoids delay at first use !!
recover bsds#recover bsds? must have two identical bsds to start up? what if one bsds is broken ?? dsnj126i i/o error forced single bsds? do not stop db2? issue command –recover bsds ? automate this!? what if one bsds is broken at start up?? db2 does not start? idcams rename/define, repro
log related datasetlog page format对log page 有一个感性认识,log 的逻辑结构复杂了,后续如果有需要在补充上吧。1 byte=8bits1 nibble=4bitslog page size=4kblog page avaiable space=4075log page control intervalsize: last 21/x'15' byte of pageusage:ci describe the log pagestart rab of the pagelog rba do not have rba-----it's start rba of the page plus offset into page of the record1 log rec maybe span may log pages
本文所有的内容均整理自互联网,仅供参考学习,如有涉及版权问题,请自行删除本文,谢谢。
http://www.bkjia.com/phpjc/1097746.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/1097746.htmltecharticlea db2 performance tuning roadmap --log introduction 本文的内容是在整理报表时,对db2 stat log avitivity部分的一个补充,主要介绍了db2 log作用,overhead,...