You are on page 1of 39

Basic DB2 Architecture

DB2 Architecture

• DB2 contains a very large number of Internal components.


• These could be grouped according to their functionality into four groups or major components.
• They are :
• System Services
• Locking Services
• Database Services
• Distributed Data Facilities
• Each of these components runs as separate address space in operating system ( MVS ) .
System Services

• Controls connections to other MVS subsystems running under different address spaces.
• e.g. CICS, TSO etc.
• Handles System startup and shutdown.
• Manages the System Log
• DB2 uses two Active Log datasets. When one Active Log is full, DB2 automatically switches to
other Log.
• While the second Log Dataset is being written to, the first dataset is backed up on an Archive Log
which is usually a Cartridge or disk.
• DB2 maintains two copies of both the Active and Archived Datasets.
• It allocates a thread at the beginning of program execution.
• Monitors the progress of execution.
Database Services

• Database Services are responsible for :


• Manipulation of DB2 data structures
• Storage, Retrieval and Update of database data.
• Preparation of Application Programs for execution.
• Allocating resources and subsequent execution of those programs.
• This component is responsible for the execution of SQL and management of buffers
• The various components that implement the functions listed above are :
• Pre-compiler
• Bind
• Runtime Supervisor
• Data Manager ( DM )
• Buffer Manager ( BM )
• Environmental Descriptor Manager (EDM)
Database Services ( Contd.)

Pre-compiler :
• Input : The source program written in the host language e.g. COBOL, PL/I etc. is the input to the
Pre-compiler.
• Outputs : The outputs are the modified Source Program and DBRMs.
• Process : Pre-compiler strips out all the embedded SQL statements from the host language
program, replaces them with host language CALL statements and using the extracted SQL
statements, constructs a Database Request Module ( DBRM )
• The inserted CALL statements issue a call to the DB2 Language Interface Module.
Source
Module

Modified DBRM
Source
Module PRECOMPILER

CATALOG
Bind
Compiler

Object PACKAGE
Module
Module

Modified DBRM
Source PRECOMPILER
Module

CATALOG Bind
Compiler

Object
Module

Other List Of
Object Packages
Linkage Modules
Editor Bind

Application
Load Plan
Module
Database Services ( Contd.)
Bind :
• Input : Source DBRMs constructed by the Pre-compiler.
• Outputs: Package and Application Plan.
• Process : There are two distinct stages in which Bind can be used.
• Bind compiles the DBRMs into a Package.
• It then compiles a list of packages into an Application Plan.
• The Package and Application Plan are stored in the Directory.
• A Package is a compiled form of the Database Requests.
• Package contains complete information regarding the runtime access path ( access strategy )
of the SQL statements in the DBRM.
• Thus Bind is really an Optimizing Compiler.
• Bind performs the compilation in four steps.
• 1) Syntax checking
• 2) Optimization : Bind Optimizer chooses the optimum access path from the database
statistics stored in the various Catalog Tables.
Database Services ( Contd.)
• Bind ( Contd. )
A special utility called RUNSTATS is provided for gathering this statistics. e.g. The optimizer may
choose to have a sequential table scan instead of using an Index defined on a table.
• 3) Package generation
• 4) Authorization checking
Bind checks that the owner of the bind is allowed to perform the operations requested in the
SQL statements that constitute the DBRMs to be bound.
• If an object is dropped, all Application Plans that were using the object are marked by DB2 as
invalid.
• At run-time, when a program requests to load such an invalid plan, DB2 automatically invokes
Bind and the corresponding Application Plan is rebound to use an alternative access path.
• However if a new object is created, DB2 does not automatically start using it.
• e.g. If a new Index is defined on a table, all concerned Application Plans must be explicitly
rebound by the developer for DB2 to be able to use the Index.
Database Services ( Contd.)
• Runtime Supervisor
• It’s job is to oversee the running of the Application Program.
• When the runtime supervisor comes across an SQL statement, it loads the corresponding
Application Plan,
• and as per the plan requests the Data Manager to perform appropriate operations.
• Data Manager
• Performs functions such as search, retrieval and update of data, index maintenance.
• Buffer Manager
• Responsible for the physical transfer of data between DASD and virtual memory.
• It keeps the frequently read and updated pages in the main memory to minimize physical
I/Os.
• The buffer pages that are Least Recently Used
( LRU ) are swapped out first.
• It uses techniques such as read ahead buffering for better performance.
• If the required Application Plan is not present in the Bufferpools at run-time, Buffer Manager
loads the Plan and passes control to the Environment Descriptor Manager.
Database Services ( Contd.)
• Environment Descriptor Manager.
• The Plan is physically stored as Skeleton Cursor Table or SKCT and a Package is called a
Skeleton Package Table or SKPT.DB2 loads the copy of this in the EDM pool
Source Module
EXEC SQL
.....
END EXEC
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module

Runtime Supervisor
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module

Runtime Supervisor

Data Manager
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module

Runtime Supervisor

Data Manager

Buffer Manager
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module

Runtime Supervisor

Data Manager

Buffer Manager

EDM Manager
Source Module
EXEC SQL
.....
END EXEC Language Interface
Module

Runtime Supervisor

Data Manager

Buffer Manager

EDM Manager

Application Plan/Package
DB2 Objects
Storage Group

User User Catalog


Database 1 Database 2 Database

Tablespace Indexspace

Table Index

View Synonym
Db2 Objects
• A DB2 sub-system consists of several User and System Database.
• A mandatory system database is the Catalog Database.
• Each database is divided into Tablespaces and Index spaces.
• Every Tablespace contains one or more Tables.
• Every Index space contains exactly one Index.
• Every Tablespace or Index space is divided into a set of Pages.
• A page is also called as a block or unit of physical I/O.
• All Index space pages are of 4K bytes in size.
• All Tablespace pages are either of 4K bytes or 32K bytes in size.
• Every Table or Index is wholly contained in their respective Tablespace or Indexspaces.
• Every Table and all of it’s associated Indexes are wholly contained in the same Database.
Db2 Objects(Contd.)

• Every Index space or Tablespace has an associated Storage Group.


• A Storage Group is a collection of one or multiple DASD volumes all of the same device type.
• A Storage Group can contain objects from different databases.
• Also objects from the same database can span across multiple Storage Groups.
• Within each Storage Group, the spaces are stored as VSAM linear datasets.
• DB2 Spaces dynamically expand using free space from the associated Storage Groups.
DB2 - Address Spaces
MVS
Early Code uses SubSystem Name (SSN) Table
to start DB2 System Services

starts

ssidMSTR ssidDBM1 IRLMPROC


DB2 DB2 IRLM
starts connects
or
starts
System Data Base Locking
Services Services Services

BSDS LOG CAT DIR

 SYS1.PARMLIB(IEFSSNxx) contains the SSID and the subsystem recognition string


DB2 Address Space Functions
System Services Data Base Services IRLM
(Control) Address Space Address
Address Space Space

Create and maintain Data space management Locking


connections
Relational Data System
Logging to active/
archive logs Data management

BSDS Processing Buffer management

Message/command Locking via IRLM


processing

Storage management

Accounting/statistics/
performance traces

Startup/shutdown
checkpointing/recovery
DB2 - Allied Address Spaces
WebSphere BATCH / TSO IMS CICS
Application DB2 Control Control
Server Utilities Region Tx Tx Tx
Application TSO ONLINE MPP A B C
TSO BATCH BMP
CAF Fast Path
DL/I
Batch

DB2
Locking
System Services Database Services Services
(IRLM)

User
BSDS LOG DBs CAT DIR

Every user has unique connection to DB2


 Maximum of one connection per MVS TCB.
 Connection to DB2 allows program to access DB2 code
within DB2 address spaces.
 Controlling the type and number of connections is fundamental.
BSDS and Log Relationship
BSDS Bootstrap Data Set (BSDS)
– Contains log data set descriptors:
DS01 000000-010FFF REUS
– Name of each data set,
DS02 011000-020FFF REUS
its starting/ending RBA, and status
DS03 021000-030FFF NOTREUS
...

Archive Log Active Log ... Time

DS01 DS02 DS03

000000 ... 011000 ... 021000 ...


010FFF 020FFF 030FFF

 Active log data sets have recent portion of the log


 Archive data sets are further back in time
BSDS is index for locating a log record
Db2 Directory and Catalog Relationships
SYSTEM DSNDB01 DSNDB06 DSNDB07
DATABASES DB2
DB2 DB2
CATALOG WORK FILE
DIRECTORY DATABASE

DIRECTORY CATALOG
TABLES TABLES 4 KB ROWS

32 KB ROWS

USER DSNDB04 USER DBs


DATABASES DB2 USER USER
DEFAULT DATA
DATABASE BASES

USER USER
TABLES TABLES

The DB2 Catalog defines itself, DSNDB07, DSNDB04, and all user DBs
Db2 Directory and Data Sets
dsnzparm
CATALOG

catname.DSNDBx.DSNDB01.spacename.y0001.Annn
table space index space
SYSIBM.tablename
DSNLUX01
SYSUTILX SYSUTIL DSNLUX02
DBD01 DBD01 none
DSNLLX01
SYSLGRNX SYSLGRNX DSNLLX02
SCT02 SCT02 DSNSCT02
DSNSPT01
SPT01 SPT01 DSNSPT02
 Not all the DIRECTORY Tables can be accessed by SQL
 However, the contents can be determined by:
SYSUTIL -DISP UTIL command or DIAGNOSE utility
DBD01 -DISP DB command or DIAGNOSE utility
SYSLGRNG REPORT utility
SCT02 SQL on SYSPLAN in catalog
SPT01 SQL on SYSPACKAGE in catalog
DB2 Catalog - For All Users
System Database Application
Administrator Administrator Programmer

SQL

DB2
CATALOG

Data Security Recovery


Definitions Definitions Information

The DB2 catalog is


an integrated tool for all DP personnel
and DB2 itself
DB2 Catalog and Data Sets
dsnzparm
CATALOG

catname.DSNDBx.DSNDB06.spacename.y0001.Annn
table space SYSIBM.tablename index space

SYSCOPY SYSCOPY DSNUCH01,DSNUCX01

SYSDATABASE DSNDDH01,DSNDDX02
SYSDBAUT
SYSDBAUTH DSNADH01,DSNADX01

SYSUSER SYSUSERAUTH DSNAUH01,DSNAUX02

SYSCOLAUTH DSNACX01
SYSCOLUMNS DSNDCX01,DSNDCX02
SYSINDEXES DSNDXX01,DSNDXX02,
DSNDXX03,DSNDXX04
SYSINDEXPART DSNDRX01, DSNDRX02
SYSKEYS DSNDKX01

SYSDBASE
SYSFIELDS
SYSFOREIGNKEYS
-----
DSNDRH01
SYSRELS DSNDLX01,DSNDLX02
SYSSYNONYMS DSNDYX01
SYSTABAUTH DSNTAX01,DSNTAX02,
DSNTAX03,DSNTAX04
SYSTABLEPART DSNDPX01,DSNDPX02,DSNDPX03
SYSTABLES DSNDTX01,DSNDTX02,DSNDTX03
SYSTABLESPACE DSNDSX01
DB2 Catalog Maintenance

catname.DSNDBx.DSNDB06.spacename.y0001.Annn

Take good care of your catalog!

 Frequent image copies


 Runstats
 Reorg
 Checking utilities
Starting DB2
-START DB2 PARM(DSNZPARM) ACCESS(*)

-START DB2 PARM(DSNZPARM)

 DSNZPARM module provides parameters for DB2 execution


 ACCESS (MAINT) restricts DB2 access to the SYSADMs and SYSOPRs
named in DSNZPARM
DSNZPARM
DSN6LOGP OUTBUFF=4000K,
TWOACTV=2,TWOARCH=2,
MAXARCH=1000
DSN6ARVP ARCPFX1=DSNCAT.ARCHLOG1,
ARCPFX2=DSNCAT.ARCHLOG2,
TSTAMP=NO,BLKSIZE=24576,
UNIT=TAPE,COMPACT=NO,CATALOG=NO,
ARCWTOR=YES,ARCWRTC=1,3,4
DSN6SYSP ROUTCODE=1,CHKFREQ=500000,RLF=NO,
IDFORE=50,IDBACK=50,CTHREAD=200,
AUDITST=NO,SMFACCT=1,SMFSTAT=YES,MON=NO
DSN6SPRM RESTART,ALL,AUTH=YES,
DSMAX=10000,CATALOG=DSNCAT,
SITETYPE=LOCALSITE,EDMPOOL=32768,
IRLMAUT=YES,IRLMPRC=IRLMPROC,
IRLMSID=IRLM,IRLMRWT=60,
SYSADM=SYSADM,SYSADM2=SYSADM,
SYSOPR1=SYSOPR,SYSOPR2=SYSOPR,
DEFLTID=IBMUSER,RELCURHL=YES
DSN6FAC DDF=NO

 This is part of DSNTIJUZ in DSNx10.NEW.SDSNSAMP


 To update DSNZPARM:
– Run install CLIST, Run DSNTIJUZ ... Stop/Start DB2 or
– SET SYSPARM
The DB2 CONNECTION Process
Will MVS let the user 'logon'?
Can the address space talk to DB2?
IDENTIFY
Can the user talk to DB2?
IDENTIFY (TSO and Batch)
SIGNON (IMS, CICS, and WebSphere)
Can the user run the plan?
CREATE THREAD
Dynamic SQL only: Can
user access data?

Work!
DIS LOG
DIS BUFFERPOOL (BP0)
DIS DATABASE(*) SPACE(*)
Summary
• DB2 Architecture
• Described DB2 address space structure
• DB2 Objects
• Outlined DB2 Logging
• Described DB2 Catalog and Directory
• Described DSNZPARM
• Explained the DB2 Connection process
• Described DB2 self-descriptors: DSNZPARM, DSNDB01, and DSNDB06
Any Questions?
Thanks !!!

You might also like