SAP DB2 On DB2 Administration
SAP DB2 On DB2 Administration
Agenda
Table space management Table space concepts and administration Automatic Storage Database administration Log file management Backup / Restore / Recovery Table maintenance (runstats, reorg) DB2 Parameters Problem determination Monitoring and performance tuning Memory Management and STMM Monitoring Tools DB2 Parallelism DB2 / SAP integration SAP DB2 file system and table space layout SAP DB2 Cockpit ...
15 February, 2012
15 February, 2012
Directory 1
...
Directory N
Containers
File 1
...
File N
15 February, 2012
15 February, 2012
15 February, 2012
15 February, 2012
15 February, 2012
15 February, 2012
10
Row ID (RID) 4 Bytes For tables in all table spaces (regular, temporary, DMS, SMS)
15 February, 2012 11
1.1x1012 Rows
15 February, 2012
13
15 February, 2012
14
15 February, 2012
15
15 February, 2012
16
= = = = = = = = = = = = = =
0 SYSCATSPACE Database managed space Any data 0x0000 166400 166398 51408 114990 51408 4096 2 2 1
18
15 February, 2012
19
15 February, 2012
20
15 February, 2012
21
15 February, 2012
22
Rebalancing
When new containers are added to a table space or existing containers are extended, a rebalance of the table space data may occur The process of rebalancing is done in an attempt to keep data evenly distributed across all containers of the table space. Access to the table space is not restricted during rebalancing but there can be a significant impact on performance To avoid rebalancing you may extend all existing containers by the same size or add new containers in a new stripe set
15 February, 2012
23
Rebalancing (Contd)
A rebalancing is done asynchronously after the following ALTER TABLESPACE options: ADD <container> will result in forward rebalancing DROP <container> will result in reverse rebalancing To avoid rebalancing choose the following ALTER TABLESPACE options: RESIZE / EXTEND / REDUCE ALL CONTAINERS BEGIN NEW STRIPE SET to create a new stripe set
15 February, 2012
24
15 February, 2012
26
15 February, 2012
27
15 February, 2012
28
15 February, 2012
29
15 February, 2012
30
Use of Concurrent/Direct IO
Without file system caching DB2 always attempts to use concurrent I/O (CIO) wherever possible: In cases where CIO is not supported (for example, if JFS is used), direct I/O (DIO) will be used instead. NFS file systems usually do not support DIO/CIO (will result in warning messages in db2diag.log) The settings for the table spaces can be retrieved with the GET SNAPSHOT FOR TABLESPACES command Alternatively, use db2pd tab (search for column FSC)
15 February, 2012
31
Automatic Storage
15 February, 2012
32
15 February, 2012
33
15 February, 2012
34
15 February, 2012
35
15 February, 2012
37
15 February, 2012
38
Container ID = 0 Name = /db2/SAT/saptemp1/NODE0000/temp16/PSAPTEMP16.container000 Type = Path Tablespace Containers for Tablespace 6 Container ID = 0 Name = /db2/SAT/sapdata1/db2sat/NODE0000/SAT/T0000006/C0000000.USR Type = File
15 February, 2012 40
15 February, 2012
42
DB2 Database Administration Log file management Backup / Restore / Recovery Table maintenance (runstats, reorg) DB2 Parameters Problem determination
15 February, 2012
43
synchronous write on COMMIT/ ROLLBACK every second when log buffer is full
db2agent
asynchronous write chngpgs_threshold is reached SOFTMAX has been reached No BP pages are available during insert/update
db2loggw
Database Files
44
db2pclnr
15 February, 2012
Primary Logfiles
Default configuration after database creation Not supported for production environments (no online backups possible no point-in-time recovery)
15 February, 2012 45
12
13
14 Online archive: Contains information for committed and externalized transactions Stored in the active log directory
15
Offline archive: Archived from active log subdirectory to disk/ tape/ TSM
15 February, 2012
16
46
Log Dir
Mirror Log
Overflow Log
db2logmgr
Failarch Path
History File
TSM
Vendor
Disk
db2tapemgr
Tape
15 February, 2012
db2tapemgr
Beginning with DB2 Version 8.2 log file management is part of the DB2 engine Supports disk, TSM, vendor library, user exit (db2uext2) Log file location information is stored in history file Configuration via DB configuration parameters
47
15 February, 2012
48
49
15 February, 2012
50
15 February, 2012
51
15 February, 2012
52
15 February, 2012
53
15 February, 2012
54
15 February, 2012
55
DB2 Backup
15 February, 2012
56
15 February, 2012
57
15 February, 2012
58
15 February, 2012
59
15 February, 2012
60
15 February, 2012
61
Log file sequence required for 00001 SYSCATSPACE Operation: Backup 00002 APPL1 rollforward of ONLINE backup 00003 APPL 00004 APPL2 00005 DFACT 00006 APPL0 00007 SYSTOOLSPACE ---------------------------------------------------------------------------Comment: DB2 BACKUP QPT ONLINE Start Time: 20060110182712 End Time: 20060111013737 Status: A ---------------------------------------------------------------------------EID: 32069 Location: /usr/lib/libnsrdb2.so Location: here Legato
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID -- --- ------------------ ---- --- ------------ ------------ -------------B D 20060110182712002 N O S0019095.LOG S0019100.LOG ---------------------------------------------------------------------------Contains 7 tablespace(s): []
15 February, 2012 62
DB2 Restore
15 February, 2012
63
15 February, 2012
64
Cross-platform Restoration
Windows 32-bit Windows 64-bit
Linux 32-bit
Linux 64-bit
Database
Database
1. 2. 3. 4. 5. 6.
Update .rhosts mkfifo <s-pipe> mkfifo <t-pipe> rsh <s-server> "dd if=<s-pipe> bs=8k" | dd of=<t-pipe> db2 restore db <db> from <t-pipe> into <new-db> db2 backup db <db> to <s-pipe>
15 February, 2012
67
DB2 Recovery
15 February, 2012
68
69
15 February, 2012
70
15 February, 2012
71
15 February, 2012
72
15 February, 2012
73
15 February, 2012
75
15 February, 2012
76
15 February, 2012
77
15 February, 2012
78
Table/Index Maintenance
15 February, 2012
79
REBIND
Application Execution
15 February, 2012 80
15 February, 2012
81
15 February, 2012
82
15 February, 2012
83
15 February, 2012
84
15 February, 2012
85
15 February, 2012
86
T IM E
F IL L P A G E R A N G E : M O V E & C L E A N to fill s p a c e
15 February, 2012
87
Index Reorganization
REORG INDEXES supports two different functions: Rebuild: This is the default. Rebuilds the index data into unfragmented, physically contiguous pages. Cleanup only: Indexes will not be rebuild. Removes committed pseudo deleted keys and pseudo empty pages. Online index rebuild mechanism: Shadow index is created during normal transaction processing When index creation is complete, the old index is swapped out and the new index is made available Sufficient temporary space needs to be available to build the new index
15 February, 2012
88
15 February, 2012
89
15 February, 2012
90
15 February, 2012
91
15 February, 2012
92
15 February, 2012
94
DB2 Parameters
15 February, 2012
95
DB2 Environment
Configure the DB2 environment via: DB2 Profile Registry Operating System Environment Variables DB2 Database Manager Configuration Parameters DB2 Database Configuration Parameters
Server machine
OS environment variables Database manager configuration file
Instance
DBM CFG
Database
DB2 registry
New features, platform dependent parameters, special optimizations Database configuration file
DB CFG
15 February, 2012
96
15 February, 2012
97
15 February, 2012
98
15 February, 2012
15 February, 2012
100
101
15 February, 2012
102
15 February, 2012
103
15 February, 2012
104
15 February, 2012
105
15 February, 2012
106
Default query optimization class (DFT_QUERYOPT) Degree of parallelism (DFT_DEGREE) Continue upon arithmetic exceptions (DFT_SQLMATHWARN) Default refresh age (DFT_REFRESH_AGE) Default maintained table types for opt (DFT_MTTB_TYPES) Number of frequent values retained (NUM_FREQVALUES) Number of quantiles retained (NUM_QUANTILES) Backup pending []
= NO
15 February, 2012
107
15 February, 2012
108
Problem Determination
15 February, 2012
109
15 February, 2012
110
15 February, 2012
111
DB2DIAG.LOG
The first and most important source for problem analysis! Contains records about errors, warnings and informational records. Typical locations of DB2DIAG.LOG (values of DIAGPATH) Standard on UNIX: $HOME/sqllib/db2dump Standard SAP Installation on UNIX: /db2/<SID>/db2dump Standard on Windows: \<DB2 installation directory>\<instance>
15 February, 2012
112
DB2DIAG.LOG DIAGLEVEL
DIAGLEVEL 0 No logging 1 Severe errors 2 Severe and non-severe errors 3 Severe and non-severe errors plus warnings 4 Severe and non-severe errors, warnings and Info Default is 3 and acceptable for most of the time Level 4 generates a lot of information - only useful in special situations (e.g. installation, migration)
15 February, 2012
113
2006-04-21-15.26.11.839221+120 E6835E555 LEVEL: Error (OS) PID : 6259 TID : 182968115104PROC : db2med.6158.0 0 INSTANCE: db2a3m NODE : 000 FUNCTION: DB2 UDB, oper system services, sqloLoadModule, probe:190 CALLED : OS, -, dlopen OSERR: EINTR (4) DATA #1 : Library name or path, 21 bytes /usr/lib/libnsrdb2.so DATA #2 : shared library load flags, PD_TYPE_LOAD_FLAGS, 4 bytes Formatted 0 error code DATA #3 : String, 80 bytes /usr/lib/libnsrdb2.so: cannot open shared object file: No such file or directory
OS
15 February, 2012
116
15 February, 2012
117
15 February, 2012
118
15 February, 2012
119
Event log
Notify log
15 February, 2012
120
15 February, 2012
121
15 February, 2012
122
15 February, 2012
123
DB2 Memory
Database Shared Memory Visible to all processes Some restrictions apply for older DB2 releases (e.g. number of shared memory segments is limited on 32 bit plattforms) Private Memory Visible only to the process that allocates it
15 February, 2012
124
Allocated when an application connects to the database Used e.g. for communication between agents that work on the same SQL statement (if intra_parallel is enabled). Allocated when an agent is created Used e.g. for private sort heap Allocated e.g. when a client issues a connect request Used for communication between an agent and an application
125
Agent Private Memory Agent AgentPrivate PrivateMemory Memory Agent/ Application Shared Memory Agent/ Agent/Application ApplicationShared SharedMemory Memory
15 February, 2012
15 February, 2012
126
15 February, 2012
127
15 February, 2012
128
15 February, 2012
129
15 February, 2012
130
Sort Memory
Database Partition 1 Database Partition 0
Sort Heap
Sort
Sort
Sort
Sort memory for one active sort (SORTHEAP defines allowed maximum)
Total sort memory (SHEAPTHRES / SHEAPTHRES_SHR define limit per partition) Allocation of sort memory:
INTRA_PARALLEL=OFF
Sort memory is agent private memory. SHEAPTHRES is a soft limit for total sort memory of each database partition.
INTRA_PARALLEL=ON
Sort memory is shared memory. Sort memory of size SHEAPTHRES_SHR is a hard limit for total sort memory. SHEAPTHRES_SHR can be defined per partition. Recommendations for initial sizing (SORTHEAP,SHEAPTHRES) are described in SAP notes 584952 (DB2 V8) and 899322 (DB2 9): SHEAPTHRES = #wp * sortheap
15 February, 2012 131
Sort Overflow
Sort Heap Real Memory Bufferpool
Sort Sort Sort
Sort
Disk
Tempory TS
Sort
A sort overflow occurs, if a sort requires more memory than defined by SORTHEAP: The sort operation first continues in the Bufferpool. If the Bufferpool is too small, the sort operation uses a temporary tablespace This means sorting on disk!
15 February, 2012
132
15 February, 2012
133
15 February, 2012
134
>>-db2mtrk--+---+--+---+--+---+--+---+------------------------> '-i-' '-d-' '-p-' +-m-+ '-w-' m: maximum value w: high water mark
15 February, 2012
135
Memory for database: AIR utilh 448.0K pckcacheh catcacheh bph(1) bph(S32K) bph(S16K) bph(S8K) 147.5M 47.0M 23.1G 672.0K 416.0K 288.0K lockh 210.6M dbh 38.8M other 0
bph(S4K) 224.0K
15 February, 2012
136
15 February, 2012
137
15 February, 2012
138
15 February, 2012
139
24 2110 0 21 0 21 24 24
= 0 = 27183
140
141
15 February, 2012
142
15 February, 2012
143
15 February, 2012
144
15 February, 2012
145
Bufferpool Statistics for all bufferpools (when BUFFERPOOL monitor switch is ON): BPID DatLRds DatPRds HitRatio TmpDatLRds TmpDatPRds HitRatio IdxLRds HitRatio TmpIdxLRds TmpIdxPRds HitRatio 1 1880491027 6819397 99.64% 1043024 311 99.97% 363097957 99.42% 0 0 00.00% 4096 0 0 00.00% 0 0 00.00% 0 00.00% 0 0 00.00% [] IdxPRds 2113817 0
15 February, 2012
146
15 February, 2012
147
15 February, 2012
148
Recommended for all SAP NW04s usage types, but not for SAP BI single-partition systems. Each SQL-Statement is processed by a single database agent.
INTRA_PARALLEL=ON:
Recommended for small SAP BI systems with a single database partition and at least 2 CPUs. SAP BI specific queries are processed by multiple database agents. Parallel index build. Limited scalability but ease of administration compared to DPF. Shared memory is allocated for sorts (parameter SHEAPTHRES_SHR).
Multiple Database Partitions and INTRA_PARALLEL=OFF:
Recommended for large SAP BI systems with many CPUs. Almost linear scalability for SAP BI queries. Administration overhead because of multiple partitions.
15 February, 2012 149
15 February, 2012
150
DB2 Database
15 February, 2012 152
15 February, 2012
153
15 February, 2012
154
15 February, 2012
155
15 February, 2012
156
Usage DB2 data dictionary Sort, temp tables, reorg Default TS Dev. Environment Loads Dev. Environment Sources Screen and Report Loads Screen and Report Sources ABAP Dictionray Log-like tables (e.g. Spool) Cluster tables Pool tables (e.g. ATAB) Master data Transaction data ODS, PSA tables Dimension tables InfoCube and Aggregate fact tables Tablespaces for Java Stack
157
15 February, 2012
158
Environment variable 'DB2DB6EKEY' is used by SAP for password encryption/decryption (the value of DB2DB6EKEY has to be identical on all SAP servers that belong to the SAP system). SAP connect user is defined by environment variable dbs_db6_schema und SAP profile parameter dbs/db6/schema
15 February, 2012
160
15 February, 2012
161
Database Server
dscdb6.conf
dscdb6up[.exe]
15 February, 2012
162
15 February, 2012
163
15 February, 2012
164
15 February, 2012
165
15 February, 2012
166
All DB Administration Tasks in a SAP/DB2 environment use one common transaction: DB6COCKPIT:
DB02 (Space: History - Overview) DB12 (Backup and Recovery: Overview) DB13 (DBA Planning Calendar) DB20 (Maintain Database Statistics) ST04 (Performance: Database Snapshot) DB6COCKPIT (Diagnostics - System Check)
15 February, 2012
167
15 February, 2012
168
15 February, 2012
169
15 February, 2012
170
15 February, 2012
171
Questions ?
!
?
?
?
? ?
? ! ?
15 February, 2012
173