Professional Documents
Culture Documents
Certified IT Specialist
Agenda
Introduction to DB2 9.5 for Linux, Unix and Windows
Basic Terminology
General Architecture: Instances & Databases
Accessing Remote Dabases: clients, drivers and catalogs
Managing Storage
Logging, Backup & Recoveries
Managing Performances
Managing Security,users & groups
Autonomics Wrap-up
High Avaliability
pureXML : native XML storage manager
Monitoring
Miscellaneous
DB2 9.5 Editions
EIM
Information Services
Conformi alla SOA
Riutilizzabili
Semanticamente
consistenti
Esempi:
verfiche di
correttezza
trasformazioni di
formato
arricchimento,
aggregazione
sincronizzazione
query federate
Info 2.0
Information Services
IBM
IBMdesigns
designsIMS
IMS
starting
in
1966
starting in 1966for
for
the
Apollo
space
the Apollo space
program
program
1980
First IBM Relational
Data Server
IBM
IBMreleases
releasesRDBMS
RDBMS
for
System/38
for System/38
implementing
implementingthe
the
Relational
Relationalmodel
model
first
firstpublished
publishedby
by
Dr.
Edgar
Codd
Dr. Edgar Codd
2006
First Multi-Structured
Data Server
DB2
DB299first
firsttotosupport
support
both
relational
both relationaland
andXML
XML
structures
managed
structures managedby
by
single
single data
dataserver
server
DB2 9
Viper
IBM
70 patented technologies
part of DB2 9 Viper
25
20
Canon
Thousands
NEC
15
Hitachi
Sony
Matsushita
Toshiba
Mitsubishi Samsung
Motorola
10
Basic Terminology
Table
ID
NAME
EXTENSION
MANAGER
John S
54213
Susan P
59867
Jennifer L
59415
Andrew J
55935
Michael B
52137
Jeremy W
50603
Leah E
58963
Row
Field
7
Also supports XQUERY for querying XML data (see more later)
General Architecture:
Instances & Databases
DB2 Instances
Instances
Stand-alone DB2
environment
All instances share the
same executable binary files
Each instance has its own
configuration
DB2 Architecture
Instance = DB2 Engine (db2sysc)
Threaded model in which one main engine process exists (db2sysc) in
memory
Engine dispatchable units (EDU) exist as threads and perform work
Benefits of the threaded model:
Increased performance
Decreased memory usage
DB2 Instances
Some sample commands for working with instances
Note that most commands here can be performed in Control Center
Command
Description
Example
db2start
db2start
db2stop
db2stop -f
db2icrt
Create an instance
db2idrop
Drop an instance
db2idrop f db2inst1
db2ilist
db2ilist
db2imigr
db2iupdt
Example
Example
Change a Database
Setting
DB2 Instance
Monitor Heap mon_heap_sz
app_ctl_heap_sz (DPF)
db2agent
local
db2ipccm
remote
db2tcpcm
db2sysc
db2wdog
db2resyn
db2gds
db2fmtlg
db2rebal
stat_heap_sz
stmtheap
agent_stack_sz
Buffer Pools
4k buffer pool
Database Heap
Utility Heap
Package Cache
logbuffsz
8k buffer pool
util_heap_sz
pckcachesz
catalog_cache_sz
4k buffer pool
8k buffer pool
query_heap_sz
rqrioblk
others
DB2 Database
db2syslog
4k buffer pool
java_heap_sz
32k buffer pool
Lock List
Sorting
sheapthres_shr
locklist
sortheap
Other memory
areas
dir_cache
db2loggr
db2loggw
db2pclnr
db2dlock
db2pfch
others
\DB2
\node0000
\sql00001
Partition number (note: in ESE non DPF databases are a single node implementation)
Database ID
/SQLOGDIR
/db2event
\program files
\sqllib
\bin
db2start.exe
db2stop.exe
db2cmd.exe, etc.
Instance Name
\SQLDBDIR
\SQLNODIR
DB2DIAG.LOG
*.dmp
*.trc
etc.
/db2inst1
/node0000
/sql00001
Partition number (note: in ESE non DPF databases are a single node implementation)
Database ID
/SQLOGDIR
/db2event
/opt
/ibm
/bin
/instance
/java
/db2
/V9.5
/SQLLIB
/SQLDBDIR
/SQLNODIR
/cfg
..
/db2dump
Db2profile
..
Function
db2adminserver
db2comm
db2include
db2instance (e)
db2instdef
db2owner
db2slogon
db2path (e)
db2system
DB2 Clients
DB2 9 API:
DB2 Client
application
emb.
SQL
supp.
drivers
DB2 Server
embedded SQL
CLI, ODBC, OLE-DB, ADO.Net
JDBC, SQLJ
DB2
Connect
database services
On a Server:
Local System Database Directory
Possible in
Control
Center
Specifies Protocol (TCPIP) ADDRESS/HOSTNAME, Port to be accessed (Server and/or Service) or TCPIP
Service
catalog
tcpipmust
node
db2
A DB
to be accessed
be: db2node remote SERVER1 server 50001
CATALOGUED IN THE LOCAL SYSTEM DB DIRECOTRY
THIS DEFINITION MUST EVENTUALY RELY ON A NODE/SERVER DEFINITION
Eg: DB2 CATALOG TCPIP NODE MYSERVER REMOTE 172.17.192.44 SERVER 5000
db2
db2
db2
db2
.
catalog/uncatalog database/node
list database directory
list node directory
list admin directory
Tools
Centers
Task Scheduling
License management
Lock Inspection
Data Partitioning Wizard
Data Movement Wizards
Data Maintenance Wizard
Autobackup Wizard
Perspectives
Object Editors
ER Diagramming
Object Properties
Stored Procedure Builder and Debugging
Managing Storage
Tablespaces
Tablespaces
Logical layer to store data as link between
Three kinds:
SMS: System Managed Space.
Containers = directories
Average Perfomances
No maintenance (grow/shrink on need automatically)
Automatic Storage
Containers = files
High Perfomances
Auotresizing (grow/shrink) when needed based on predefined policies
Manual Intervention only to add NEW devices/disks when automatic storage pool
is exausthed
Tablespace Usage
Possibilities:
Regular
Large
Type of usage:
System
System Temporary
User
User Temporary
Pagesize
For all System/User (temporary or not) both Regular and Large:
Must specify a size for the data page at TBSPC level
4,8,16 or 32kb
Tablespace Capacity
DB2 performs I/O grouping bits in sets of Data Pages. Data page have a fixed sized of 4K, 8K, 16K, or 32K
Table spaces are created specifying one page size out of 4K, 8K, 16K, or 32K.
Page size limits the data that can be stored in the table space. One row MUST fit page size, except for Binary Data
Description
4K page
size limit
32K page
size limit
500
1012
1012
1012
4005
8101
16 293
32 677
64
128
256
512
16
Logging
Circular vs Archive
Backup & Logging
Backup
Cold
Warm
Partial
Recovery
Restore vs Forward Recovery
Log Buffer
synchronous
asynchronous
write
db2agent
db2pclnr
db2loggr
on COMMIT/
ROLLBACK
MINCOMMIT
SOFTMAX
Buffer Pool
write when
triggered
(chngpgs_thres
hold)
Database Files
Must force the log record for an update before the corresponding data page gets to
disk
Guarantees Atomicity (all actions in a transaction happen, or none happen)
How is it done:
DB2 uses ARIES (Algorithm for Recovery and Isolation Exploiting Semantics) as the
transaction recovery method supporting fine-granularity locking and partial rollbacks
"n"
PRIMARY
"n"
SECONDARY
DB2 archive
log file
(db2uext2)
12
OFFLINE
ARCHIVE
ACTIVE - Contains
information for
non-committed
13
14
OFFLINE ARCHIVE Archive moved from
ACTIVE log subdirectory.
(May also be on other
media)
15
16
Backup
Used to protect data in case of phisycal/logical failure affecting
them
Basic protection different from HA & DR concepts
Can be:
Full (entire DB is backed-up)
Partial (tablespace(s))
Incremental (only changes from latest activity)
Delta
Increment
Warm backup
Need LOG ARCHIVE method
Data is copied to disk WHILE
applications are changing them
Changes are written to LOG files
Log files written WHILE backing up
DB are PART of the Backup image
file produced.
Partial Backup
Partial(Incremental) backup types
Cumulative
backs-up everything since most recent full backup
Delta
backs-up only data that changed since last backup
(either full or incremental)
Sunday
Mon
Tue
Wed
Thu
Full
Fri
Sat
Sunday
Full
Cumulative Backups
Full
Delta Backups
Full
Automatic backup
Automatic backup was:
Scheduled backup (fixed time)
Automatic backup for DB2 is:
The possibility to tell when a backup is needed
Provide a time-frame
Recovery
Main assets: backup Image(s) + Log Files (when required)
Main steps:
Restore (of the backup image)
Mimic the changes accumulated in the Log Files after (and maybe
during) the backup timeframe.
Forward Recovery
Roll Forward (or Forward Recovery) when possible:
Optional: when Log Archive enabled and when restoring a Full Backup
Offline
Mandatory: when Log Archive enabled and when restoring a Full Backup
Online.
Log files contain eventually modified data during the timeframe of online backup
execution.
Minimum: rollforward reading AT LEAT the log files written during online
backup timeframe.
Mimic all the changes in ALL the log files DB2 can read
Beware of log sequences assocatiated with the backup Image
TO ISO TIME
Mimic all the changes contained in ALL the log files DB2 can read AND
up to a specified timestamp.
Managing Performance
At system level
At RDBMS level
DATABASE
MEMORY
Sorts &
Hash Joins
DB2 advisors
DB2 Activity Monitor:
To produce reports to analyze SQL cache and feed Design Advisor
DB2 Design Advisor:
To analyze the workload (eg: coming from Activity Monitor) and
suggest:
Indexes
MQTs
MDCs
Graphical
Specify costs for each part of the query
Determine when indexes are used and why they are not
Q2
Q1
Qn
aggregation
join
base tables
Qz
Qn
Q2
Q1
MQT
aggregation
join
base tables
2008 IBM Corporation
Row Compression
Automatically Compress a Table
without DBA intervention (Lempel-Ziv)
Automatically create a Compression
Dictionary for entire Table
Q u e ry #
N o c o m p re s s io n
R o w C o m p r e s s io n
M in
M in
% d iff
9 7 .3
7 3 .8
76%
9 .8
7 .9
81%
7 7 .0
5 5 .6
72%
9 3 .3
4 8 .5
52%
1 0 3 .0
6 2 .8
61%
1 4 .8
9 .3
63%
6 6 .7
4 4 .3
66%
2 3 0 .8
1 8 4 .0
80%
1 4 6 .3
9 2 .1
63%
10
1 0 2 .6
5 6 .1
55%
11
9 3 .9
3 4 .0
36%
12
1 0 5 .4
5 2 .4
50%
13
7 8 .2
7 6 .7
98%
14
6 .8
5 .0
74%
15
9 .8
9 .7
99%
101%
16
1 3 .3
1 3 .4
17
3 7 .2
2 8 .9
78%
18
2 7 8 .6
2 6 9 .0
97%
19
3 3 5 .2
2 6 6 .1
79%
20
4 6 .1
3 1 .6
69%
21
3 0 0 .2
1 6 6 .8
56%
22
6 .0
5 .3
88%
TS
2 2 5 8 .2
1 5 9 7 .9
71%
ORGANIZE BY DIMENSIONS
Node 1
Node 2
Distribute
Node 3
TS1
TS2
TS1
TS2
TS1
TS2
Jan
Feb
Jan
Feb
Jan
Feb
North South
North South
North South
North South
North South
North South
East West
East West
East West
East West
East West
East West
Organize
No Partitioning
Data
Distribute by Hash
Divide & Conquer Parallelism
P1
P2
P3
P4
P1
P2
P3
P4
2
0
0
6
2
0
0
5
P1
P2
P3
P4
2
0
0
6
2
0
0
5
Workload Management
User Database
Requests
Superclass 1
Workload A
Stable and
Predictable
Performances by
predefining amount
of System and DB2
resources to be
used by workload
Workload B
Workload C
Work
Action
Set
Subclass1.1
Subclass1.2
Subclass1.3
Workload D
Default User
Class
Default workload
System Database
Requests
Default System
Class
UR
CS
RS
RR
Authentication
delegatated by default to Operating System
Can be done by Server (default) or Client (security
issues here)
Can be compliant with
LDAP/Active Directory
Kerberos
Data Encryption
Optionally: via User exit (eg: Migrations)
DB2 Security
There are 3 types of authorization in DB2:
Authorities (Groups/Roles)
Privileges (Grant/revoke on objects like Tables, Views,
Packages,SP, Triggers..)
LBAC credentials
Explicit authorities/privileges:
Granted explicitly to the user, usually in the form of a GRANT
statement
Implicit authorities/privileges:
Granted to a group to which the user belongs, or to a role in
which the user, the group, or another role is a member
LBAC Query
No
LBAC
SEC=254
SEC=10
0
SEC=50
ID
SALARY
255
60000
100
50000
50
70000
50
45000
60
30000
250
56000
102
82000
100
54000
75
33000
253
46000
90
83000
200
78000
Autonomics wrap-up
High Availability
Portland
Toronto
Online commercial
applications
Challenge
HADR
24 x 7 Availability
Failover in seconds
Disaster recovery
Solution : HADR
Primary
Database
Server
Standby
Database
Server
Standby
HTTP & App.
Servers
More
later
Ultra-fast failover
Local and remote site
recovery
Value
Business continuation
Tight integration; Very
simple to use
Automatic Reroute
R
HAD
Client
Application Server
Standby Database
Server
Primary Database
Server
Synchronization modes
This diagram shows when acknowledgements are received in Synchronous,
Near Synchronous and Asynchronous modes
TCP/IP socket
HADR
HADR
send()
ro
ch
yn
As
log writer
receive()
us
no
new
logs
Primary
r
ea
hr
c
n
Sy
o
on
Synch
Commit Succeeded
us
ronou
new
logs
Standby
Relational columns
are stored in relational
format (tables)
deptID
PR27
deptdoc
<dept>
<emp></emp>
</dept>
Parse
XML
XMLtext
textrepresented
represented
as
asdocument
documenttree
tree
dept
employee
id=901
name
John Doe
phone
408-555-1212
employee
office
344
id=902
name
Peter Pan
phone
408-555-9918
office
216
employee
id=901
name
John Doe
phone
"Compression"
employee
office
408-555-1212
344
id=902
name
Peter Pan
phone
Reduced storage
Fast comparisons &
navigation
office
408-555-9918
216
SYSIBM.SYSXMLSTRINGS
0
4
1
5
2
3
String table
dept
employee
name
id
phone
office
5=901
John Doe
408-555-1212
5=902
344
Peter Pan
408-555-9918
216
employee
id=901
name
John Doe
phone
408-555-1212
employee
office
344
/
/dept
/dept/employee
/dept/employee/@id
/dept/employee/name
/dept/employee/phone
/dept/employee/office
(...)
id=902
name
Peter Pan
phone
office
408-555-9918
216
5=901
John Doe
408-555-1212
5=902
344
Peter Pan
408-555-9918
216
Example:
Path index
Region index
/dept
/dept/employee
/dept/employee/@id
1
1.3
1.1
1.4
1.4.1
1.4.1.3
1.3.1.1.5.3
page
page
page
XML Storage
INX Object
DAT Object
ID
PR27
PR28
ACC
DEPTDOC
Region
Path
/dept
/dept/employee
/dept/employee/@id
XDA Object
AgeIndex
Index on an XML Column
/Person/Age
/Person/Age
17
6322
Relational Table T1
DocID
AgeUnitIndex
XMLDoc
1
/Person/Age/@unit
/Person/Age/@unit
XML Document
<?xml version="1.0"?>
<Person gender="Male">
<Name>
<Last>Cool</Last>
<First>Joe</First>
</Name>
<Age unit="years">17</Age>
<Age unit="days">6322</Age>
</Person>
"days"
"years"
@gender
"Male"
Person
Name
Age
Last
First
text()
"Cool"
text()
"Joe"
@unit
"years"
Age
text()
"17"
@unit
"days"
text()
"6322"
Relational
Index
Relational Column 1
Relational Column 2
Index
on XML
Column
XML Column
Logical mapping of
regions in an XML
XML
document used to retrieve
Regions Index
the document data
XML
Column
Paths
Index
Created by users to
improve performance
during queries on XML
documents
XML Storage
.XDA file
XML
Parsing
Parsed
format
SQL Update
XML
Serialization
XML
Serialization
Change
XML Parsing
<dept bldg=101>
<employee id=901>
<name>John Doe</name>
<phone>408 555 1212</phone>
<office>344</office>
</employee>
</dept>
Transmission
<dept bldg=101>
<employee id=901>
<name>John Doe</name>
<phone>408 555 1212</phone>
<office>344</office>
</employee>
</dept>
XML
Parsing
Parsed
format
SQL Update
w/ XQuery Transform
XML
Serialization
XML
Serialization
Change
XML Parsing
<dept bldg=101>
<employee id=901>
<name>John Doe</name>
<phone>408 555 1212</phone>
<office>344</office>
</employee>
</dept>
<dept bldg=101>
<employee id=901>
<name>John Doe</name>
<phone>408 555 1212</phone>
<office>344</office>
</employee>
</dept>
CLOB/Varchar
Extract
selected
elements/attr.
Shredding
XML
DOC
Fixed
Mapping
XML
DOC
"Decomposition"
Shredder
Side Tables
XML DOC
XML DOC
XML DOC
Varchar or clob
column
Regular
relational
tables
2008 IBM Corporation
Replication
Validation triggers
Validation check constraints
Non-Unicode databases
XML Load
Monitoring
Tools
DB2 collects monitornign data based on specific criteria
Data exposed via non graphical built-in tools such as:
Snapshot Monitor
Event Monitor
Data exposed via Graphical Interface (DB2 CC):
Health Center
Data exposed in reports with aggregation and trend analisys:
DB2 Performance Expert tool (java application)
In future via Optim Data Studio Administration Console (web)
DB2 Editions
DB2 Workgroup
Linux
Windows
UNIX
4 CPUs, 16 GB RAM
DB2 Enterprise
Linux/Windows/UNIX
No limits
Servers
Free download,
64-bit
AIX
Windows Intel/AMD
Linux Intel/AMD, PowerPC, zSeries
Solaris, Sun IPF
HP PA-RISC, HP IPF
32-bit
Windows Intel/AMD
Linux Intel/AMD
DB2 Express
Linux/Windows
2 CPUs, 4GB RAM
DB2 Express-C
Linux/Windows
2GB RAM
Clients
DB2 Everyplace
Linux/Windows & PDA
2008 IBM Corporation
DW Starter
DW Intermediate
DW Advanced
DW Enterprise Base
DW Enterprise
200 PVUs /
4GB database memory
400 PVUs /
32GB total memory
None
None
Linux Windows
Linux Windows
Linux only
Any
Any
DB2
Performance Optimization
Feature
Storage Optimization
Feature
Alphablox
Alphablox
Licence limitations
(maximums)
Platform Support
Alphablox connectors
Alphablox
non-DWE Connectors
Intelligent Miner
DW Enterprise
DW Enterprise Edition
N/A
DW Advanced
Trade-ups available
DW Intermediate
DW Enterprise Base
Includes pureXML
Fixed Term License (FTL) can be purchased for support. See
http://www.ibm.com/software/data/db2/express/support.html
2008 IBM Corporation
Misc
Developer communities
C/C++
Java (JDBC / SQLJ)
.NET (C#, VB .NET)
Open Source
PHP
Perl
Python
Most of the sample application programs that come with DB2 use
sample database
2008 IBM Corporation
Grazie