A DB2 Performance Tuning Roadmap --LOG INTRODUCTION
The content of this article is a supplement to the DB2 STAT LOG AVITIVITY part when organizing reports. It mainly introduces the DB2 LOG function, overhead, and related How to use DB2 log and the existing DB2 Log utilities provided by IBM to understand the components and the working mechanism between them. Finally, we give a perceptual understanding of the logic of DB2 log.- 1 LOG OVERVIEW
- DB2 LOG FUNDAMENTALS
- LOG AIM:
- WHY NEED LOGGING
- IN PERFECT WORLD
- OVERVIEW OF LOG WORK MECHANISM
- DB2 LOG FUNDAMENTALS
- 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
- WHAT IS BEING LOGGED?
- 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 IMPLEMENTATION
- LOG RELATED DATASET
- LOG PAGE FORMAT
1 LOG OVERVIEW
DB2 LOG FUNDAMENTALS
LOG 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 LOGGING- overhead
- it costs in ters of performance,dasd,dministration,cleanup
- it's assurance-just in case of an accidentIN PERFECT WORLD
- no need to rollback
- no need to recover
- no program errors
- no hardware errors
- no power failtures
- no 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 logs
Where DB2 puts the current log information - Log Buffers
Where log information is held BEFORE externalisation to DASD - Bootstrap Datasets
These hold information about the current active and archive log datasets - Archive logs
These are copies of ‘old’ active log datasets - SYSLGRNX
DB2 keeps track of WHEN objects are (possibly) being updated
2 UNDERSTANDING OF LOG
LOG IMPLEMENTATION
1 LOG RBABYTE ADDRESSABLE(RBA=RELATIVE BYTE ADDRESS)
RBA START=0X00000000000
RBA END=0XFFFFFFFFFFF
RBA UNIQUELY DEFINE A LOG RECORD

LRSN=LOG SEQUENCE RANGE NUMBER,WHICH IS A MODIFIED TIMESTAMP BASE ON SYSPLEX STORCE CLOCK
LOG OUTPUTBUFFER
ACTIVE LOG
ARCHIVE LOG
WHEN DB2 GO TO THE LAST ACTIVE DATA SETS ,WRAP ROUND TO FIRST ACTIVE LOG DATA SETS
- ACTIVE LOG DATA SETS NUMBER
- ACTIVE LOG DATA SETS SIZE
- SINGLE OR DUAL ACTIVE LOG
- PERFORMANCE CONSIDERATION:
- FAST DASD
- CONSIDER STRIPPING
- DB2 ZPARM OUTBUFFER LOGAPSTG
? 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
? Table in Directory so no user access available
? Contains the RBA when any tablespace or
partition is opened or closed for update
? Note this information is also in DB2 log
? SYSLGRNGX is used by DB2 to speed up
recovery 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 utilityFACTORS OF ARCHIVE LOG DATASETS
- ALWAYS PRODUCE TWO FILES FOR ONE ACTIVE LOGS
IT IS AN ASYNCHRONOUS PROCESS
VCAT.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|EXT
VCAT.ARCHIVEN.DXXXXX.TXXXXX.BNNNNNNNN - WHEN ARCHIVE:
ACTIVE LOG FULL
TRUNCATED:ARCHIVE LOG COMAMND OR ERROR
LOG STRUCTURE
WHAT IS BEING LOGGED?INFORMATION OF UR- BEGIN/END UR INFORMATION
- UNDO/REDO STATEMENTS and compensation log rec
- commit rollback processing
- OPEN/CLOSE PAGE SET
- PENDING 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 EXMPLAE
UPDATE T
SET COL='BBB'
WHERE ID=1
LRH004A002F 06000001 0E800006 CEA48CC9 0006CEA4 8D590526 0006CEA4 8D59C7C0
AF504B23 0000
*LG** 80010C00 02000000 02000006 CEA4049E 2B02 0000 00120101 00030900 000600C2 C2C200C1 C1C1
C2C2C2='BBB'
C1C1C1='AAA'
URID(0006CEA48CC9)RBA OF UR STARTED IN LOG
010C=DBID
0002==PAGE SET OBID
000000 02=PAGE ID

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 that
case 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 a
disaster 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 CHECKPOINT (snapshot of activity on system)
- WHAT IS IN SYSTEM CHECKPOINT
- Entry per active thread (amongst other status inflight/in commit etc)
- Entry per open page set (including exception status)
- Page externalization
- How 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 CHECKPOINT
As the work is being done
? In Log output buffer (OUTBUFF)
? Regularly flushed to Active Log Dataset
Sequentially 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 USAGE
Start DB24 phases :
- Log initialization
Read/compare BSDS
Find current active log dataset and end of log - Current status rebuild
Read last system checpoint - Forward log recovery
Do all work for INCOMMIT and INDOUBT threads - Backward log recovery
Do all work for INABORT and INFLIGHT threads - ALWAYS start from LAST SYSTEM CHECKPOINT
Amount of work varies (ab)normal shutdowN
DB2 新增了一个参数BACKOUT(YES),这个参数应该不是太常用,更多的情况应该是使用imgcopy+log的方式去追,即point-in-time,这里不进行介绍。
REPLICATIONIt is a very popular topic in IDC now. It is the basis for realizing double-active or multi-active. It is also implemented in platform version of DBMS, such as mysql’s mater-slave method, which is supported by mysql itself and does not need to be added. Software, but it is processed by a single thread. For this reason, many vendors provide enhanced versions to support concurrency on the slave. QREP MQ is implemented on zos, supporting heterogeneous databases, and the delay can be controlled within minutes. RPT=2MIN, RTO=2HOUR,
SOX ComplianceThis is more for internal audit and external audit. Relatively speaking, the cost of using the audit LOG method is relatively high, and there are alternative software.
HEALTH CHECKSBEST PRACTICE, based on the current operation of the system, check whether the ACTIVE LOG and ACHIVE LOG are running abnormally.
LOG UTILITES, WORKING WITH THE LOG
How many sentences? This should be something that is lacking in the current platform. It may still exist, but I am ignorant.
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
Will 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
? 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
? LOSS
DSNJLOGF
? Pre-formats new active log dataset
? Avoids delay at first use !!
? 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 DATASET
LOG PAGE FORMAT
I have a perceptual understanding of LOG PAGE. The logical structure of LOG is complicated. I will add it later if necessary.
1 BYTE=8BITS
1 NIBBLE=4BITS
LOG PAGE SIZE=4KB
LOG PAGE AVAIABLE SPACE=4075
LOG PAGE CONTROL INTERVAL
SIZE: LAST 21/X'15' BYTE OF PAGE
USAGE:CI DESCRIBE THE LOG PAGE
START RAB OF THE PAGE
LOG RBA DO NOT HAVE RBA-----IT'S START RBA of the page plus offset into page of the record
1 log rec maybe span may log pages
All the contents of this article are collected from the Internet and are for reference and study only. If there are any copyright issues, please delete this article yourself. Thank you.

In PHP, you can use session_status() or session_id() to check whether the session has started. 1) Use the session_status() function. If PHP_SESSION_ACTIVE is returned, the session has been started. 2) Use the session_id() function, if a non-empty string is returned, the session has been started. Both methods can effectively check the session state, and choosing which method to use depends on the PHP version and personal preferences.

Sessionsarevitalinwebapplications,especiallyfore-commerceplatforms.Theymaintainuserdataacrossrequests,crucialforshoppingcarts,authentication,andpersonalization.InFlask,sessionscanbeimplementedusingsimplecodetomanageuserloginsanddatapersistence.

Managing concurrent session access in PHP can be done by the following methods: 1. Use the database to store session data, 2. Use Redis or Memcached, 3. Implement a session locking strategy. These methods help ensure data consistency and improve concurrency performance.

PHPsessionshaveseverallimitations:1)Storageconstraintscanleadtoperformanceissues;2)Securityvulnerabilitieslikesessionfixationattacksexist;3)Scalabilityischallengingduetoserver-specificstorage;4)Sessionexpirationmanagementcanbeproblematic;5)Datapersis

Load balancing affects session management, but can be resolved with session replication, session stickiness, and centralized session storage. 1. Session Replication Copy session data between servers. 2. Session stickiness directs user requests to the same server. 3. Centralized session storage uses independent servers such as Redis to store session data to ensure data sharing.

Sessionlockingisatechniqueusedtoensureauser'ssessionremainsexclusivetooneuseratatime.Itiscrucialforpreventingdatacorruptionandsecuritybreachesinmulti-userapplications.Sessionlockingisimplementedusingserver-sidelockingmechanisms,suchasReentrantLockinJ

Alternatives to PHP sessions include Cookies, Token-based Authentication, Database-based Sessions, and Redis/Memcached. 1.Cookies manage sessions by storing data on the client, which is simple but low in security. 2.Token-based Authentication uses tokens to verify users, which is highly secure but requires additional logic. 3.Database-basedSessions stores data in the database, which has good scalability but may affect performance. 4. Redis/Memcached uses distributed cache to improve performance and scalability, but requires additional matching

Sessionhijacking refers to an attacker impersonating a user by obtaining the user's sessionID. Prevention methods include: 1) encrypting communication using HTTPS; 2) verifying the source of the sessionID; 3) using a secure sessionID generation algorithm; 4) regularly updating the sessionID.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
