Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Scelte tecnologiche di gestione su DBMS centralizzati e distribuiti; servizi automatizzati e ruolo del DBA
Agenda
Quick review of some DB2 basics
Part 1: how DB2 implements data access, integrity and security
Transactions: Concurrency, Locking
Transactions: Recovery
Backup & Restore
Security features
Optimizer
Part 2: aspects of DB2 database administration
Automated tasks and autonomic capabilities
High-value DBA tasks
Applications
Other
develop
tools
Developer
Other
system
tools
SQL, XQuery
DBMS engine
Develop
tools
Optimizer
DBA
tools
&
utilities
Transactions:
concurrency, locking
7
High-value
tasks
2
Transactions:
recovery
DBA
6
Automated tasks &
autonomic capabilities
4
Security
features
Databases
(relational & XML)
DB2 architectures
Appl
DB2
Appl
DB2
DB2
DB2
DB2
disk
disk
disk
disk
Thousands of users
Appl
DB2
DB2
disk
Database
PROD_DB3
Log
Catalog
Database
PROD_DB5
Log
DBconfig
Buffer
Pools
DBconfig
Buffer
Pools
In a DB2 instance
Many threads are shared by all
databases
Instance configuration
parameter (dbm cfg) affects all
databases in that instance
Database configuration (db cfg)
parameters exist for each
database
DBMconfig
Database
TEST_DB3
Database
TEST_DB5
Log
DBconfig
Buffer
Pools
DBconfig
Buffer
Pools
db2start
DBMconfig
Physical
Database
Table space
Container
Object
(Tables Indexes)
Extent
DB2 Page
OS Page
DB2 Control
Center
DB2 Health
Center
DB2 Command
Window (CLP)
DB2 Task
Center
2010 IBM Corporation
Tool bar
Perspective
(a collection of
views and
editors)
Data
Project
Explorer
view
Editor view
Drag &
drop views
anywhere
Data
Source
Explorer
view
SQL Results
view
Resize button
Part 1
Part 1
How DB2 implements
data access, integrity and security
10
11
ACID
A number of features in DB2 (concurrency management, locking, logging, recovery...) are designed
and implemented to ensure full compliance with these ACID properties in every possible situation
12
Basic concepts
Database Transactions
Concurrency
Concurrency Issues
Concurrency Control
Isolation Levels
Locking
Specifying Isolation Levels
13
Database Transactions
Transaction
sequence of one or more SQL operations, grouped together
as a single unit
also known as a unit of work (uow) or logical unit of work (luw)
Committed Data
using the COMMIT statement commits any changes made
during the transaction to the database
Uncommitted Data
changes during the transaction before the COMMIT statement
is executed
14
Concurrency
Concurrency
Sharing of resources by multiple interactive users or application
programs at the same time
Lost Update
Uncommitted Read
Non-repeatable Read
Phantom Read
15
Concurrency Issues
Lost Update
Occurs when two transactions read and then attempt to update the
same data, the second update will overwrite the first update before
it is committed
1) Two applications, A and B, both read the same row and
calculate new values for one of the columns based on the
data that these applications read
2) A updates the row
3) Then B also updates the row
4) A's update is lost
16
Concurrency Issues...
17
Concurrency Issues...
Non-repeatable Read
Occurs when a transaction reads the same row of data twice and
returns different data values with each read
18
Concurrency Issues...
Phantom Read
Occurs when a search based on some criterion returns
additional rows after consecutive searches during a transaction
19
Concurrency Control
Isolation Levels
determine how data is locked or isolated from other concurrently executing
processes while the data is being accessed
are in effect while the transaction is in progress
Uncommitted read
ANSI Serializable
ANSI Repeatable Read
ANSI Read Committed
Equivalent to Oracle Statement Level Snapshot IL***
20
Locking
Locking Attributes
resource being locked is called object
objects which can be explicitly locked are databases, tables and
table spaces
objects which can be implicitly locked are rows, index keys, and
tables
implicit locks are acquired by DB2 according to isolation level and
processing situations
object being locked represents granularity of lock
length of time a lock is held is called duration and is affected by
isolation level
21
Types of Locks
(simplified overview)
Share (S)
Update (U)
Exclusive (X)
concurrent transactions are prevented from accessing the data in any way
does not apply to transactions with an isolation level of UR
22
Types of Locks...
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
(detailed view)
23
Types of Locks...
lock compatibility
24
Deadlock
Deadlock Detector
discovers deadlock cycles
randomly selects one of
the transactions involved
to roll back and terminate
transaction chosen is then
sent an SQL error code,
and every lock it had
acquired is released
What is a deadlock?
A deadlock occurs when two separate processes compete
for resources held by one another.
For example, consider the following processing sequence
for two concurrently executing application programs:
Job A
Update Table A/Page 1
Lock established
Intermediate processing
Update Table B/Page 1
Lock (wait)
Job B
Update Table B/Page 1
Lock established
Intermediate processing
Update Table A/Page 1
DEADLOCK Lock (wait)
25
Repeatable Read
26
Read Stability
27
Cursor Stability
28
Currently Committed
Situation
Result
Situation
Result
No
No
Maybe
No
Yes
No
Yes
Yes
ANSI standard
Implemented in DB2 from V1
29
Currently Committed
Up to DB2 9.5
Cursor Stability is the default isolation level
30
Transaction A
Transaction B
No locking
Reads last committed version
of the data
No locking
Reads last committed version
of the data
No
Nodeadlocks,
deadlocks,no
notimeouts
timeoutsin
inthis
thisscenario!
scenario!
2010 IBM Corporation
31
PRECOMPILE/BIND
CONCURRENTACCESSRESOLUTION: Specifies the concurrent
access resolution to use for statements in the package.
USE CURRENTLY COMMITTED
WAIT FOR OUTCOME
32
Uncommitted Read
33
Isolation Levels
Summary
Isolation Level
Dirty Read
Non-repeatable
Read
Phantom
Read
Possible
Possible
Possible
Possible
Possible
Possible
DEFAULT
Application Type
Read-write transactions
Read-only transactions
34
Precompile / Bind
ISOLATION option of PREP or BIND command
Can determine isolation level of a package by executing the
following query
SELECT ISOLATION FROM syscat.packages
WHERE pkgname = 'pkgname'
AND pkgschema = 'pkgschema'
Statement Level
Use the WITH {RR, RS, CS, UR} clause
The WITH UR option applies only to read-only operations
ensure that a result table is read-only by specifying FOR READ ONLY
in the SQL statement
35
36
Transactions: Recovery
Transactions: Recovery
37
2 Transactions: recovery
Capire
che cosa devo predisporre per poter ripristinare un database che
presenta dei problemi e che non pi accessibile
quali informazioni trover nel database dopo il ripristino
2010 IBM Corporation
38
DB2 Logging
2 Transactions: recovery
39
2 Transactions: recovery
Log Buffer
MINCOMMIT
SOFTMAX
asynchronous
write
db2agent
db2pclnr
on COMMIT/ ROLLBACK
db2loggr
synchronous
write
Buffer Pool
when triggered
(chngpgs_threshold)
Database Files
40
2 Transactions: recovery
Write-ahead logging:
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)
Must write all log records for a transaction before commit: Guarantees Durability
(if a transactions commits, its effects persist)
How is it done:
Each log record has an unique Log Sequence Number (LSN)
Each data page contains a pageLSN
System keeps track of flushed LSN: before a page is written, ensure
pageLSN <= flushed LSN
2010 IBM Corporation
41
2 Transactions: recovery
Database Configuration:
USEREXIT = OFF
LOGRETAIN = OFF
"n"
PRIMARY
"n"
SECONDARY
42
2 Transactions: recovery
Database Configuration:
USEREXIT = ON
LOGRETAIN = RECOVERY +
Others for variuos
methods Use wizard
DB2 calls
db2uext2
12
ACTIVE
Contains information
for non-committed trx
13
14
OFFLINE ARCHIVE
Archive moved from
ACTIVE log subdirectory.
(may also be on other media)
ONLINE ARCHIVE
Contains information
for committed trx.
Stored in the ACTIVE
log subdirectory.
15
16
43
2 Transactions: recovery
44
2 Transactions: recovery
45
2 Transactions: recovery
DB2 will not report any error because of disk full in the active log
path
Will attempt to create the log file again after 5 minutes
Will continue this behavior until log is successfully created
Record written to the db2diag.Log whenever a log create fails
46
2 Transactions: recovery
47
2 Transactions: recovery
~0.LOG
S ~1.LOG
~2.LOG
S ~3.LOG
S ~4.LOG
BACKUP
y RESTORE DATABASE
without rolling forward
48
2 Transactions: recovery
Usage notes
If user exit is enabled, an archive request is issued after the logs
are closed and truncated
Performance may be impacted during execution of the command
49
Dual Logging
2 Transactions: recovery
50
2 Transactions: recovery
51
2 Transactions: recovery
52
2 Transactions: recovery
53
2 Transactions: recovery
End of Logs
"End" means the end of the current log path
Other logs may need to be moved in the path
Point in time
Specified in Coordinated Universal Time (UTC) or Local Time (Version 8)
Format: yyyy-mm-dd-hh.mm.ss.nnnnnn
ONLINE backup
Requires roll forward past end of backup
Recovery history file is useful
54
2 Transactions: recovery
55
56
Data Files
(Data Pages)
Recovery
History File
Backup /
Restore
Recovery
(Transaction)
Logs
57
Concepts
58
59
Archive Logging
Log
Buffer
Buffer
Pool
db2logger
db2pgclnr
logarch
method1
[softmax]
Data Files
Log
Control
File
Recovery
Log
Files
Archive
Log Files
Active Log
Non-Committed or Non-Externalized Transactions
60
61
Screens walk
you through
logging setup
62
Parameter
Usage
archretrydelay Wait in second between archive log failure attempts. 0 means no retry.
blk_log_dsk_ful Prevent disk full errors from being generated.
failarchpath
Alternate directory for the archive log files if the log archive method specified
fails.
Log Archive Methods 1 & 2 logarchmeth1
These parameters cause the database manager to archive log files to
logarchmeth2
locations that are not the active log path.
Values are OFF, RETAIN, USEREXIT, DISK, TSM, VENDOR
Log Archive Options 1 & 2 logarchopt1
Works with logarchmeth1 & 2 for vendor options if using TSM or VENDOR
logarchopt2
values.
Log Buffer
logbufsz
Amount of memory to use as a buffer for log records in 4-KB pages.
Log File Size
logfilsiz
The size of each configured log, in number of 4-KB pages.
Max Logs per Transaction max_log
Percentage of primary log space that can be consumed by one transaction.
0 means no limit.
Mirror Log Path
mirrorlogpath
Location where an identical copy of the logs will be kept.
New Log Path
newlogpath
Location to change for log path away from default SQLOGDIR.
Number of Commits to
mincommits
Allows you to delay the writing of log records to disk until a minimum number
Group
of commits have been performed.
Number of Archive Retries numarchretry
Number of attempts that will be made to archive log files using the specified
log archive method before they are archived to the path specified by the
failarchpath.
Number of Log Span
num_log_span Number of active log files that an active transaction can span. 0 means no
limit.
Overflow Log Path
overflowlogpath Multi-function parameter used for rollforward and archived log retrieval
operations.
Primary Logs
logprimary
Number of primary logs. Also determines number of logs in active log path.
Secondary Logs
logsecond
Number of secondary logs allocated if needed. -1 is unlimited active logs.
Archive Retry Delay
Block on Log Disk Full
Failover Archive Path
Default
20
NO
NULL
OFF
NULL
8
1000
0
NULL
NULL
1
5
0
NULL
3
2
63
BACKUP
BACKUP DATABASE
DATABASE SAMPLE
SAMPLE TO
TO
c:\db2backup;
c:\db2backup;
64
LOGFILSZ
LOGBUFSZ
LOGPRIMARY
LOGSECOND
NEWLOGPATH
MIRRORLOGPATH
BLK_LOG_DSK_FULL
OVERFLOWLOGPATH
Dont forget the logging wizard can help you do all of this!
65
Online Backup
Contains
Can be throttled
Still, minimum activity usually desired during online backup
Parallelization is automatic but can be overridden if desired
66
Examples
67
Restore
Full Database
From offline backup
From online backups: need considerations
Partial Database
Tablespace level
From offline or online backup: need considerations
Forward recovery
Optional step when restoring full offline backups and Archive Log
is enabled
Mandatory step when restoring full online backups:
Mandatory step when restoring partial/tablespace backups
68
Restore...
69
Restore / Recover
Database Considerations
Database restore/recover done offline from online backup
Full restore/recover brings up & applies all crucial files
automatically
DB2 RESTORE: used with roll-forward for more control
DB2 RECOVER: for ease of use
RECOVER
RECOVER DB
DB SAMPLE
SAMPLE TO
TO END
END OF
OF LOGS;
LOGS;
RESTORE
RESTORE DATABASE
DATABASE SAMPLE
SAMPLE FROM
FROM c:\db2backup
c:\db2backup TAKEN
TAKEN
AT
AT 20041201194626
20041201194626 WITHOUT
WITHOUT PROMPTING;
PROMPTING;
ROLLFORWARD
ROLLFORWARD DATABASE
DATABASE SAMPLE
SAMPLE TO
TO END
END OF
OF LOGS
LOGS AND
AND
COMPLETE;
COMPLETE;
70
Online Restore
You can also rebuild an entire database from table space backups!
2010 IBM Corporation
71
Incremental Backups
Backup all pages changed since the most recent full, incremental or delta back up
72
Incremental Backups
Using
Pls. Note: immediately after having set the Trackmode to yes a Full backup is required in order
to get synchronized with the changed pages that will be tracked from now on
73
Incremental Restore
Using
RESTORE
RESTOREDATABASE
DATABASESAMPLE
SAMPLEINCREMENTAL
INCREMENTALAUTOMATIC
AUTOMATIC
FROM
FROMc:\DB2Backup
c:\DB2Backup
TAKEN
TAKENAT
AT20040901230402
20040901230402WITHOUT
WITHOUTPROMPTING;
PROMPTING;
For automatic restore, the timestamp is of
The most recent incremental or delta backup
ROLLFORWARD
ROLLFORWARDDATABASE
DATABASESAMPLE
SAMPLETO
TOEND
ENDOF
OFLOGS
LOGS
AND
ANDCOMPLETE;
COMPLETE;
Dont forget the Restore Wizard can help you!
2010 IBM Corporation
74
75
Supporting Utilities
db2tapemgr
Stores archived log files to tape
76
list
list history
history backup
backup all
all for
for sample;
sample;
select
select ** from
from table(sysproc.admin_list_hist())
table(sysproc.admin_list_hist())
as
as history;
history;
77
To automate the cleanup of backup images, log files & load copy
images to coincide with the recovery history file, set DB CFG:
AUTO_DEL_REC_OBJ
78
Stored procedures,
UDFs
Triggers
UDTs
Grants
Monitors
Indexes
and more
Database RI
Application logic RI
Trigger relationships
User defined relationships
79
Security Features
Security Features
80
4 Security features
Controllo
Automazione
Application Security
Infrastructure Security
81
4 Security features
Define
Controls
Monitor ,
Audit,
Report
Information
Discovery
&
Classification
Enforce
Controls
82
4 Security features
Countermeasures
Products
recommended
Config. threats
Audit threats
Exec. threats
83
Security
4 Security features
84
DB2 Client
DB2 Client
4 Security features
DB2 Client
DB2 Client
Authenticate
Here!
Data
Encryption
Data
Encryption
Data
Encryption
Authenticate
Here!
Authenticate
Here!
Instance 1
SERVER
AUTHENTICATION
AUTHORIZATION
Data
Encryption
Plug-ins
Instance 2
Instance 3
CLIENT
AUTHENTICATION
GSSPLUGIN
AUTHENTICATION
Kerberos
Server
Instance 4
KERBEROS
AUTHENTICATION
Authenticate
Here!
Database Authorities
SECADM
DBADM
CONNECT
CREATETAB
LOAD
IMPLICIT_SCHEMA
QUIESCE_CONNECT
CREATE_EXTERNAL_ROUTINE
CREATE_NOT_FENCED_ROUTINE
BINDADD
ACCESSCTRL
DATAACCESS
SQLADM
WLMADM
EXPLAIN
Object Privileges
Table
Index
Package
Workload
Sequence
Security
Label
Nickname
Server
View
Role
XSR
Schema
Routine
Table
Space
Global
Variable
Module
Setsessionuser
85
2010 IBM Corporation
85
Security Basics
Level: Security in DB2 starts at the instance
User definition: defined outside the database
Authentication: is plug-in controlled
Security plug-ins (DLLs or exits) for client and server
authentication as well as group management
Default plug-ins use OS authentication DLLs
Authentication is by one of these methods
Client side
Server side
GSS Plug-in
Kerberos server
Groupings:
Groups: Supports groups as defined in the OS
Authorities: Instance or database level groupings of privileges
Roles: Supports roles similar to Oracle, but can grant to users,
groups or other roles
Trusted Contexts: Trusted Connections established through
Trusted Contexts, can be tied to a role
4 Security features
86
DB2 Authorities
Database level
4 Security features
Instance level
87
Grant / Revoke
4 Security features
The following example grants SELECT privileges on the EMPLOYEE table to the user HERON:
The REVOKE statement allows authorized users to revoke privileges previously granted to other users.
88
4 Security features
SELECT
SELECT* *FROM
FROMEMP
EMP
WHERE
SALARY
>=
WHERE SALARY >=50000
50000; ;
No LBAC
SEC=254
1. Hierarchical (tree)
2. Group (array)
3. Set types
Row labels appear as a single
additional column in a protected table
Regardless of the number of label
components
SEC=100
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
= row returned
89
Trusted Context
Basics
4 Security features
In a typical three tiers scenario (Web + Appl. Server + DB2) the mid tier authorization
is used for all the web users. It is therefore convenient to set up a "trusted context"
for security across the application server and the database server environments.
Trusted context can be used:
Setup
Usage
Open/establish the
trusted connection
90
Trusted Context...
4 Security features
Trusted Contexts:
Are database objects that provide greater control when you use
restricted and/or sensitive privileges
userA
userB
userD
userC
Middle Tier
Application Server
Can then acquire additional capabilities not allowed outside the trusted context
IP address (or domain name): Represents the host from which a database
connection was established
Data stream encryption: Represents the encryption setting (if any) for the data
communication between the database server and the database client
Trusted Contexts defined having:
Trusted Contexts defined having:
[1] System authid used to establish the connection
[1] System authid used to establish the connection
[2] Trust attributes used to establish the connection
[2] Trust attributes used to establish the connection
[3] Default role (optional)
[3] Default role (optional)
[4] A list of authids allowed to switch (optional)
[4] A list of authids allowed to switch (optional)
Trusted Connection
wasUserB, context2
Trusted Connection
wasUserA, context1
DB2 Database
Context2:
Context1:
wasUserB allow
userC; userD
wasUserA allow
userA; userB
91
4 Security features
In cryptography,
the Advanced
Encryption
Standard (AES) is
an encryption
standard adopted
by the U.S.
government.
Client requests an SSL connection listing its SSL version and supported cipher suites
Server responds with a selected cipher suite
Server sends its digital certificate to the client
Client verifies the validity of the server's certificate (server authentication)
Client and server securely negotiate a session key
Client and server securely exchange information using the key selected above
Signer
Certificate
Database
iKeyman tool
JCC Client
SSL (JSSE)
TCP/IP
DB2 Server
Encrypted
Communication
SSL (GSKit)
TCP/IP
Digital
Certificate
Database
iKeyman tool
92
DB2 Audit
4 Security features
Audit Features
93
Optimizer
Optimizer
94
DB2 Optimizer
5 Optimizer
The optimizer is the heart and soul of DB2. It analyzes SQL statements and determines the most
efficient access path available for satisfying each statement.
DB2 accomplishes this by parsing the SQL statement to determine which tables and columns must be
accessed. The DB2 optimizer then queries system information and statistics stored in the DB2 system
catalog to determine the best method of accomplishing the tasks necessary to satisfy the SQL request.
http://www.globalguideline.com/articles/analysis.php?k=Optimization_of_DB2
95
DB2 Optimizer...
5 Optimizer
96
5 Optimizer
Different from
Oracle, DB2
doesn't use
hints
Static
statements
Dynamic
statements
Legend
tables
Provide Information
on these objects
and parameters
Indexes
Table
Functions
operators
97
5 Optimizer
Parse Query
Check Semantics
Rewrite Query
Optimize Plan
98
5 Optimizer
Reorg
Runstats
Learning Optimizer (LEO) --> autonomics
Static & Dynamic SQL
Explain facilities
99
Explain Facilities
5 Optimizer
Run from the Control Center or Command Editor or IBM Data Studio
Entirely GUI driven
Provides a visual graph of the plan
Allows drill-down on objects and nodes for more detail
db2exfmt
Formatter for previously stored explain data from optimizer information only
Line command driven
Text output with text based graphs
db2expln
To see the access plan information available for packages of static SQL statements (static
mode)
Shows the actual implementation of access plan, not just optimizer information
Shows on the fly execute and explain or explain from cache (dynamic mode)
Line command driven
Text output with text based graphs
100
Explain Facilities
5 Optimizer
Explain
Tables
GUI Interface
Visual
Explain
db2exfmt db2expln
Yes
Text Output
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
101
Explain Facilities
5 Optimizer
Function
EXPLAIN_INSTANCE
EXPLAIN_STATEMENT
Contains the text of the SQL statement as it exists for the different levels
of Explain information.
EXPLAIN_ARGUMENT
EXPLAIN_OBJECT
EXPLAIN_OPERATOR
Contains all the operators needed to satisfy the SQL statement by the
SQL compiler.
EXPLAIN_PREDICATE
EXPLAIN_STREAM
Advise Tables: tables named ADVISE_* used for explain mode processing shown in following slide
102
Explain Facilities
5 Optimizer
Explain Mode
Function
NO (default)
YES
EXPLAIN
REOPT
Enables explain. Causes explain info. to be captured into explain tables but only at
re-optimization time when host variables are resolved.
SQL statements executed and real-time statistics are used if available.
RECOMMEND INDEXES
Enables explain. Causes explain info. to be captured into explain tables & populates
ADVISE_INDEX table.
SQL statements not executed.
EVALUATE INDEXES
RECOMMEND PARTITIONINGS
Enables explain. Causes explain info. to be captured into explain tables & populates
ADVISE_PARTITION table.
SQL statements not executed.
EVALUATE PARTITIONINGS
103
5 Optimizer
Explain Facilities
Function
NO (default)
YES
Enables explain. Causes explain info. to be captured into explain tables for:
Static SQL at prep / bind time
Reoptimizable incremental statements at run time
SQL statements executed.
REOPT
Enables explain. Causes explain info. to be captured into explain tables for:
Reoptimizable incremental statements at run time
Dynamic SQL at run time overriding CURRENT EXPLAIN MODE.
SQL statements executed.
ALL
Enables explain. Causes explain info. to be captured into explain tables for:
Static SQL at prep / bind time
Reoptimizable incremental statements at run time
Dynamic SQL at run time overriding CURRENT EXPLAIN MODE.
SQL statements executed.
104
Explain Facilities
5 Optimizer
Explain Terminology
Timerons
An invented relative unit of measure. Timerons are determined by the optimizer based on internal values such as
statistics that change as the database is used.
Node
Numbered section of each explain plan. To read a plan, start at bottom right and work right to left, bottom to top. There
are two kinds of nodes: Operator (the action that is performed) & Operand (the object the action is performed against)
OPERATOR TYPE
FUNCTION
FETCH
TBSCAN
Index Scanning
IXSCAN, EISCAN, RIDSCN
FILTER
UNIQUE
Removes duplicates
Nested Loop, Merge Scan, Union (concatenation), Index ANDing (dynamic bit map), Hash
GRPBY
SORT
Sorts rows in the order of specified columns, and optionally eliminates duplicate entries.
TQUEUE
GENROW
RETURN
TEMP
105
Explain Facilities
5 Optimizer
Rectangles
Diamonds
Octagons
Hexagons
Parallelograms
Timerons
Operator #
Nodes
106
Explain Facilities
5 Optimizer
Timerons
Tables:
Indexes:
Operators:
Functions:
Tqueues:
Rectangles
Diamonds
Octagons
Hexagons
Parallelograms
Operator #
Nodes
107
Explain Facilities
5 Optimizer
db2exfmt Output
Operator Type
Timerons (can be changed to show other stats)
Operator #
Nodes
Rows
Total Cost
I/O Cost
108
5 Optimizer
Federated
database
server
Federated
database
server
local data
database virtuale
DB2
SQL Srv
non relational
relational
Aree di applicabilit
Benefici
(p.e.
architetture applicative
ambienti analitici
acquisizioni e fusioni aziendali
ambienti multi-sito
portali
processi IT
.
109
5 Optimizer
database statistics
ulteriori fattori di costo
network bandwidth
data source capabilities
data volumes
predicate pushdown
Supporto dei
nicknames
Caching eterogeneo
trasparenza applicativa
applicazione
100
200
300
400
500
EMPNAME
Smith
Jones
Adams
Miller
Bennett
write
SELECT X_EMP.EMPNAME,
O_OFFICE.OFFICENO
FROM X_EMP, O_OFFICE
WHERE X_EMP.EMPNO=
OFFICE - owner J15USER1 O_OFFICE.EMPNO
Oracle
EMPNO
OFFICENO
100
200
300
400
500
C200
C202
C204
C206
C208
EMPNAME
OFFICENO
Smith
Jones
Adams
Miller
Bennett
C200
C202
C204
C206
C208
read
read
A B C
DB2
WS II
C
Microsoft
110
5 Optimizer
Tecnologia di
global optimizing
Non-DB2
db
(4GB)
2.0
Ratio of query elapsed time
Federated vs. Native interface
1.5
1.0
0.5
14
22
19
16
02
10
18
07
12
08
21
01
11
05
06
03
04
09
15
20
0.0
111
5 Optimizer
Federation Terminology
Server2
Wrapper A
Nickname
Nickname
Server1
Nickname
Nickname
Federated views
Table
Server3
WrapperB
(remote data
source 1)
(remote data
source 2)
(remote data
source 3)
112
5 Optimizer
Server2
Wrapper A
Nickname
Nickname
Server1
Nickname
Table
Nickname
Server3
WrapperB
(remote data
source 2)
(remote data
source 3)
113
5 Optimizer
Invokes functions at
remote sources as needed
Local + Remote
Execution Plans
Rel. Wrapper
NR. Wrapper
Client library
Client library
Table
Cost-based optimizer
Nickname
Federated Server
Nickname
Cost-based optimizer
chooses query plan with
pushdown as appropriate
Non-SQL
114
5 Optimizer
Query Properties:
Optimization class, data distribution,
operators used, query type,
cost models, FIRST N ROWS ?
Statistics:
Table Statistics
Column statistics
Index statistics
SERVER
Characteristics
Cpu/io ratio,
Commrate
Capabilities
Type/version
Non-Relational Wrapper
Wrapper Plans
Cost Models
115
5 Optimizer
Local Caching
Materialized Query Tables (MQTs) Over Nicknames
Remote
data
Nickname
Fed server
MQT
Local Data
Remote
data
Remote
data
Local Data
116
5 Optimizer
Multi-site Update
V8.x
Disallowed:
transaction
atomicity
Cannot be
guaranteed
V9.1
UPDATE S1
UPDATE S2
Federated
Server
UPDATE S1
UPDATE S2
Federated
Server
UPDATE S1
S1
S2
UPDATE S1
S1
UPDATE S2
S2
117
Part 2
Part 2
Aspects of DB2 database administration
118
Storage management
Backup / Restore
Automatic Backup
Automatic Maintenance
Workload mgmt
Disegno fisico dei dati
Indici, partizioni, MQT, MDC...
STMM
WorkLoad Manager
Advisors
Data maintenance
Reorg, runstats, rebind...
Monitoring
a livello dbms
di sistema
Tools
Health Monitor
Tivoli sw
119
Aspetti architetturali
High Availability / Disaster Recovery
Data volume explosion (Storage)
Data Governance
2010 IBM Corporation
120
121
Autonomic Computing
Definition
Autonomic computing systems have the ability to manage themselves and dynamically adapt to change
in accordance with business policies and objectives.
This enables computers to identify and correct problems often before they are noticed by IT personnel.
They can also learn, adapt and protect themselves for future situations.
Self-Configuring
Self-Healing
Self-Optimizing
Self-Protecting
Business resiliency
Operational
Optimizing
efficiency
Tune resource &
balance workloads to
maximize use of IT resource
SelfHealing
SelfProtecting
Discover, diagnose
& act to prevent
disruptions
Secure information
and resources
122
ANSWER:
Not at all. DB2 Self-Tuning Memory
Manager handles this for you!
DB2 Self-Tuning Memory Manager uses out of the box autonomics which:
Constantly re-evaluated cached based memory usage
Can share various cached based database memory heaps with each other
NOTE:
DB2 Self-Tuning Memory Manager manages cache based
memory in DB2. Functional based memory used by application
programs are controlled by the parameter
APPLICATION_MEMORY, or if this is set to AUTOMATIC then
INSTANCE_MEMORY with control this.
123
Memory consumption is
based on three concepts
Instance Memory
Database Memory
Application Memory
General Rule
Instance Memory = Sum(all DB memories + all Application Memories) + overhead (10%)
Instance Memory
Is the total amount of memory
addressable by DB2 Instance
2 GB for Express-C, 4 GB for
Express, 16 GB for Workgroup
Managed by specific Parameter (can be
automatic and managed by STMM)
Database Memory
Is the total amount of memory used
internally by each DB and include:
All the buffers
All the caches
All the sort areas
Locks
Managed by specific Parameter (can be
automatic and managed by STMM)
Application Memory
Is the total amount of memory used by
agents (instance threads) servicing local
and remote applications when connected
to the DB
Managed by specific Parameter (can be
automatic and managed by STMM)
124
The database borrows memory from the operating system, or gives it back
The buffer pools share memory with each other, even converting the various page sizes
The other database memory heaps share with each other as well as the buffer pools
OPERATING SYSTEM MEMORY
DATABASE_MEMORY
BUFFER
POOL 1
BUFFER
POOL 2
BUFFER
POOL 3
SHEAPTHRES
_SHR
BUFFER POOL 4
SORTHEAP
(Sorts &
Hash Joins)
* Registry variable db2_mem_tuning_range limits upper and lower ranges of OS memory usage
125
DB2 Self-Tuning Memory Manager itself is on by default for newly created databases
To turn it off, use the Control Center GUI to change SELF_TUNING_MEM to OFF
Or use the following CLP command:
UPDATE
UPDATEDB
DBCFG
CFGFOR
FORDATABASE
DATABASE[db-name]
[db-name]USING
USINGSELF_TUNING_MEM
SELF_TUNING_MEMOFF;
OFF;
Buffer pools are set to SIZE AUTOMATIC by default if size is not specified
To freeze this, use the Control Center GUI to alter the buffer pool size to a set page amount
Or use the following CLP command:
ALTER
ALTERBUFFERPOOL
BUFFERPOOL[bufferpool-name]
[bufferpool-name]size
size[pages];
[pages];
126
127
DB2 V8.x
For tables in all table spaces
(regular, temporary, DMS, SMS)
Large Tablespaces ONLY for LOB
DB2 V9.x
New Large and Temporary Table Spaces
For tables in LARGE table spaces
(DMS only)
Also all SYSTEM and USER
temporary table spaces
128
Automatic Storage
2.
Thats it! Under the covers, DB2 now creates, names and sizes the data files
needed to support the table space without any DBA intervention.
Path or drive can be any number of subdirectories, mount points or drives
Path or drive list can be added to later with an ALTER DATABASE command
DB2 manages all automatic storage containers within this path
Smart enough to make temporary table spaces SMS, all others DMS
Automatically stripes containers for you by your number of paths or drives
Create other DMS or SMS table spaces outside automatic storage if desired
Health Monitor indicators signal if paths or drives about to become full
129
Automatic Storage
p1
p2
C0 C1
p1
p2
C0 C1
ALTER DATABASE
ADD p3, p4
p3
p4
p1
p2
p3 p4
C0 C1 C2 C3
p1
p2
p3 p4
C0 C1 C2 C3
131
Automatic Storage
p2
p3
p1
p2
p3
C1 C2
C3
C1
C2
C3
ALTER DATABASE
DROP p2
p1
p3
C1
C3
ALTER TABLESPACE ..
REBALANCE
Drop Pending
2010 IBM Corporation
132
Storage management
Some examples
=
=
=
=
=
=
=
/storagePath1
0
In Use | Not In Use | Drop Pending
64768
66725142528
50100731904
317068410880
133
Optimizes resources by
Phase I - Determining best time to run any given activity in:
Online window
Offline window
UP
CK ATS
BA NST
RU
BACKUPs
RUNSTATs
REORGs
RG
Perf. & Tuning --> Data maintenance --> Reorg & Runstats
Backup / Restore
RE
O
Is easy to manage
GUI wizard walks you through the entire process
Saves your settings in a profile & can be run over and over again
134
Automatic Maintenance
GUI
135
Automatic Maintenance
Concepts Used
Defined as:
Periods of time for hours of the day, days of the week or month
For online and offline time periods
Inside or outside defined time periods
DB2 uses this window to consider running selected utilities
This window should be a relatively unused time period for your database
Notification
List of contacts can be built and used to notify results of auto maintenance actions
Throttling
Auto maintenance uses adaptive utility throttling which it controls all by itself
The defined maintenance window is used as the overriding priority
Uses a fixed 7% limit on resources
136
Automatic Maintenance
Perf. & Tuning --> Data maintenance --> Reorg & Runstats
Backup / Restore
db cfg
~~~~~ ~~
~~~~~~~
~~~~~ ~~~
~~ ~~~~ ~
auto_db_backup
auto_tbl_maint
auto_reorg
auto_runstats
auto_stats_prof
auto_stmt_stats
auto_prof_upd
AUTO_MAINT
Parent to all other auto_% parameters. Sets auto maintenance at a global level.
Enabled: All recorded values for child parameters take effect.
AUTO_DB_BACKUP
AUTO_TBL_MAINT
AUTO_REORG
AUTO_RUNSTATS
AUTO_STMT_STATS
AUTO_STATS_PROF
Turns on statistical profile generation, designed to improve applications whose workloads include
complex queries, many predicates, joins, and grouping operations over several tables.
Enabled: Recommendations are stored in the opt_feedback_ranking table.
AUTO_PROF_UPD
137
Automatic Maintenance
Location
File System (Disk)
Automatically deletes old copy in chosen directory
Tape
Tivoli Storage Manager
X/Open Backup Services API (XBSA)
Vendor DLL
Mode
Online - Archive log (retain) mode supported
Default maintenance mode for this setting is 24 x 7
Offline Archive log and circular log both supported
Uses QUIESCE DATABASE in DEFER mode to allow transactions to complete
138
Automatic Maintenance
Selected tables
Can use a simple or custom filter to select range of tables to run against
Custom filter can point to a control table which contains only the names of tables you desire
an automatic REORG to be performed on
139
Automatic Maintenance
140
Automatic Maintenance
ASAP!
141
142
DB2 architectures
High Availability
& Disaster Recovery
Appl
DB2
Appl
DB2
DB2
DB2
DB2
disk
disk
disk
disk
Thousands of users
Appl
DB2
DB2
disk
143
144
High Availability
145
Database A
Server 1
Server 2
Primary
Standby
TCP/IP
HADR
HADR
Database A
Database C
Database B
Database D
Standby
Database E
Primary
TCP/IP
HADR
HADR
Database E
146
Primary
Standby
DB2
DB2
DB2 instance A
TCP/IP port
DB2 database
from instance A
memory
nsync
async
Transaction
DB2 database
from instance B
async
TCP
TCP
IP
IP
MAC
MAC
PHY
PHY
Log writer
1
disk2
DB2 instance B
TCP/IP port
1
32
disk
sync
High Availability
& Disaster Recovery
disk
memory
nsync
Log writer
Transaction
disk
Transaction
Log
sync
Transaction
Log
HADR Replication
147
Disaster Recovery
148
Continuous Availability
149
Integrated Cluster
Manager
InfiniBand network & DB2
Cluster Services
Shared Data
150
Address Scalability
Can add nodes whenever needed without stopping applications
Can scale up (on a single member) or out (by adding members)
151
88 Members
87% Scalability
2, 4 and 8
Members
Over 95%
Scalability
64 Members
91% Scalability
32 Members
Over 95%
Scalability
16 Members
Over 95%
Scalability
152
153
154
Data Replication
data
155
Filtering is possible
156
Scenarios
157
Q - Replication
158
Scenarios
159
Data Growth - Data Privacy - Test Data Mgmt - Appl Upgrades - Appl Retirement
Optim
Extract - Store - Port - Protect
Estrazione e
Archiviazione
degli oggetti
applicativi
extract
Data Governance
Database
di
produzione
Storici
mask
archive
Recuperati
Correnti
retrieve
masked
files
Database
di sviluppo
e di test
load
Dati di
riferimento
Archivi
Dati di
reporting
Dati
storici
Applicazione
XML
ODBC/JDBC
160
Data Warehousing
IDMS
DB2
IDMS
Ora
Ora
Ora
Ora
15
Data modelling
Administration
1 Primary ETL
5
Ora
R/3 conn
BW conn
17
3
BW
PSA
ODS
Infocubes
Aggreg.
Transf
Other envir
Mainframe environment
ETL
metadata
ODS DWH
EDW
Enablers
ETL int
14
DMarts
12 Mdim ETL
Mdim
DMarts
DW
DMarts
Query governor
front-end
13
virtualization layer
Appl
16
embedded
analytical
BEX
18
10
161
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
162
SOA
Info
Services
IOD
Analityc Services
BI services (Cognos 8 BI)
On-line analytics, DMining (IWH)
Supporting Tools
(service generation)
IS Service Director
IBM DataStudio
Other IBM tools
(e.g. WS Integration Developer)
2010 IBM Corporation
Service choreography
Content-centric business
processes & workflows
(FileNet P8 BPM)
Other IBM sw
(e.g. WS Process Server)
Data Services
Relational data access (DB2, IDS)
Stored Procedures (DB2)
XML data access (DB2)
Data access (IMS)
163
164
http://www-01.ibm.com/software/data/db2/linux-unix-windows/edition-enterprise.html
165
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp
166
http://www-01.ibm.com/support/docview.wss?rs=71&uid=swg27009474
167
http://www.ibm.com/developerworks/offers/lp/db2cert/db2-cert730.html?S_TACT=105AGX19&S_CMP=db2certlp
168
http://www.ibm.com/developerworks/offers/lp/db2cert/db2-cert731.html?S_TACT=105AGX19&S_CMP=ZHP
169
Questions ?
170