Professional Documents
Culture Documents
Course Guide
Db2 11.1 Advanced
Database Administration
Course code CL464G ERC 1.0
IBM Training
Preface
June 2018
NOTICES
This information was developed for products and services offered in the USA.
IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for
information on the products and services currently available in your area. Any reference to an IBM product, program, or service is not intended to
state or imply that only that IBM product, program, or service may be used. Any functionally equivalent product, program, or service that does not
infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to evaluate and verify the operation of any
non-IBM product, program, or service. IBM may have patents or pending patent applications covering subject matter described in this document.
The furnishing of this document does not grant you any license to these patents. You can send license inquiries, in writing, to:
IBM Director of Licensing
IBM Corporation
North Castle Drive, MD-NC119
Armonk, NY 10504-1785
United States of America
The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law:
INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied warranties in
certain transactions, therefore, this statement may not apply to you.
This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these
changes will be incorporated in new editions of the publication. IBM may make improvements and/or changes in the product(s) and/or the
program(s) described in this publication at any time without notice.
Any references in this information to non-IBM websites are provided for convenience only and do not in any manner serve as an endorsement of
those websites. The materials at those websites are not part of the materials for this IBM product and use of those websites is at your own risk.
IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligation to you. Information
concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available
sources. IBM has not tested those products and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM
products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products.
This information contains examples of data and reports used in daily business operations. To illustrate them as completely as possible, the
examples include the names of individuals, companies, brands, and products. All of these names are fictitious and any similarity to the names and
addresses used by an actual business enterprise is entirely coincidental.
TRADEMARKS
IBM, the IBM logo, ibm.com, Db2 and pureScale are trademarks or registered trademarks of International Business Machines Corp., registered in
many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is
available on the web at “Copyright and trademark information” at www.ibm.com/legal/copytrade.shtml.
Adobe, and the Adobe logo, are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States, and/or other
countries.
Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or its affiliates.
Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.
Microsoft, Windows, and the Windows logo are trademarks of Microsoft Corporation in the United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other countries.
© Copyright International Business Machines Corporation 2018.
This document may not be reproduced in whole or in part without the prior written permission of IBM.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
Contents
Preface................................................................................................................. P-1
Contents ............................................................................................................. P-3
Course overview................................................................................................. P-9
Document conventions ..................................................................................... P-12
Demonstrations ................................................................................................ P-13
Additional training resources ............................................................................ P-14
IBM product help .............................................................................................. P-15
Advanced monitoring ........................................................................... 1-1
Unit objectives .................................................................................................... 1-3
Characteristics of in-memory metrics
used to support the monitor table functions ................................................... 1-4
Focus areas for in-memory metrics .................................................................... 1-6
In-memory metrics: System ................................................................................ 1-7
In-memory metrics: Data objects ........................................................................ 1-8
In-memory metrics: Activity perspective ............................................................. 1-9
Controls for collecting monitor data .................................................................. 1-10
Monitoring system information using table functions......................................... 1-12
Monitoring time spent waiting for resources...................................................... 1-14
Additional time-related metrics ......................................................................... 1-15
Additional wait times reported........................................................................... 1-16
Example of query using the XML document
returned by MON_GET_CONNECTION_DETAILS ..................................... 1-17
Monitoring administrative views simplify access to important metrics ............... 1-19
Monitoring performance with SQL: Buffer pools ............................................... 1-21
Monitoring performance with SQL: Sorts .......................................................... 1-22
Monitoring performance with SQL: Top dynamic SQL statements .................... 1-23
Monitoring performance with SQL: Long-running SQL ..................................... 1-24
Monitoring performance with SQL application wait times .................................. 1-26
Monitoring performance with SQL: Lock chains................................................ 1-27
Monitoring performance with SQL: Lock memory usage .................................. 1-28
Monitoring performance with SQL: Lock escalations, deadlocks and timeouts . 1-29
Monitoring performance with SQL queries that have a high prep time .............. 1-30
Monitoring performance with SQL: Costly table scans...................................... 1-31
Monitoring prefetch efficiency of applications ................................................... 1-33
Monitoring performance: Database memory usage .......................................... 1-34
Using MONITOR functions with database partitioning ...................................... 1-35
Monitor performance with SQL: Index usage with multiple database partitions 1-36
Monitoring extent movement for when the storage group is altered for a table
space ............................................................................................................... 2-39
Table space growth with Automatic Storage ..................................................... 2-40
Automatic Storage Rebalance to use newly added storage paths .................... 2-41
Dropping storage paths: Example .................................................................... 2-42
Converting a DMS table space to use Automatic Storage ................................ 2-44
Example converting a DMS managed tablespace to use Automatic storage .... 2-46
Unit summary ................................................................................................... 2-70
Db2 Database Memory Management ................................................... 3-1
Unit objectives .................................................................................................... 3-3
Db2 Database and Instance memory configuration ............................................ 3-4
Defining limits for memory usage ....................................................................... 3-7
Database shared memory .................................................................................. 3-9
Db2’s database memory model: Inside the set ................................................. 3-11
Database memory configuration options .......................................................... 3-12
Overflow Buffer can be used for dynamic memory configuration changes ........ 3-14
Overflow Buffer can be used to handle peak memory demands for some heaps . 3-
15
Database buffer pools ...................................................................................... 3-16
db2pd: Buffer Pools report................................................................................ 3-18
Online Memory configuration considerations .................................................... 3-19
Database heap memory ................................................................................... 3-20
Monitoring catalog cache.................................................................................. 3-22
Dynamic and Static SQL caching ..................................................................... 3-24
Check dynamic SQL cache stats with db2pd .................................................... 3-26
Monitoring the package cache .......................................................................... 3-27
Utility Heap memory: Util_Heap_SZ ................................................................. 3-29
Db2 Sorting methods ........................................................................................ 3-31
Database Shared Sort memory management................................................... 3-33
Monitoring sort performance and memory utilization ........................................ 3-34
Monitoring sort processing using SQL .............................................................. 3-36
Monitoring database shared sort memory using SQL ....................................... 3-37
db2mtrk: Memory tracker command ................................................................. 3-38
Database and Instance memory display: db2mtrk ............................................ 3-40
Monitoring the overall memory usage using the MON_GET_MEMORY_SET table
function............................................................................................................. 3-41
How does STMM work? ................................................................................... 3-42
STMM: In each tuning interval .......................................................................... 3-43
Automatic management of selected memory heaps ......................................... 3-45
STMM modes of operation ............................................................................... 3-46
STMM and the buffer pools .............................................................................. 3-48
Course overview
Preface overview
This course provides detailed technical information on the management of Db2
database servers by database administrators. The following database management
skills will be covered:
• Perform advanced monitoring using the Db2 administrative views and routines in
SQL queries.
• Manage the disk space assigned in Database Managed Storage (DMS) and
Automatic Storage table spaces to optimize disk space utilization.
• Use SQL queries and Db2 commands to check the high water mark on table
spaces and to monitor a rebalance operation.
• Utilize the REBUILD option of RESTORE, which can build a database copy with
a subset of the tablespaces using either database or tablespace backup images.
• Plan and execute the TRANSPORT option of RESTORE to copy schemas of
objects between two Db2 databases.
• Create incremental database or tablespace level backups to reduce backup
processing time and backup image storage requirements.
• Implement automatic storage management for table spaces and storage groups
or enable automatic resize options for DMS managed table spaces to reduce
administration requirements and complexity.
• Describe the various types of database memory including buffer pools, sort
memory, lock memory and utility processing memory.
• Adjust database or Db2 instance configuration options to improve application
performance or processing efficiency.
• Implement Db2 Self Tuning Memory management for specific database memory
areas
The lab demonstrations are performed using Db2 11.1.2.2 for Linux.
Intended audience
This is an advanced course for DBAs and technical individuals who plan, implement,
and maintain Db2 11.1 databases.
Topics covered
Topics covered in this course include:
• Advanced Monitoring
• Db2 Table Space Management
• Db2 Database Memory Management
• Database rebuild support
• Db2 database and tablespace relocation
• Db2 Incremental Backup
Course prerequisites
Participants should have the following skills:
• Perform basic database administration tasks for a Db2 database server, including
using Db2 commands like BACKUP and RESTORE
• Utilize Structured Query Language (SQL) and be able to construct DDL, DML,
and authorization statements
• These skills can be developed by taking the course CL207 Db2 11.1
Administration Workshop for Linux
Document conventions
Conventions used in this guide follow Microsoft Windows application standards, where
applicable. As well, the following conventions are observed:
• Bold: Bold style is used in demonstration and exercise step-by-step solutions to
indicate a user interface element that is actively selected or text that must be
typed by the participant.
• Italic: Used to reference book titles.
• CAPITALIZATION: All file names, table names, column names, and folder names
appear in this guide exactly as they appear in the application.
To keep capitalization consistent with this guide, type text exactly as shown.
Demonstrations
Demonstrations format
Demonstrations are designed to provide hands on experience with some of the key
concepts and skills covered by the lecture content.
The demonstrations for this course include the following:
• Using the Db2 monitor functions and views to analyze a series of database
activities including disk space utilization, log space utilization and data access
efficiency.
• Using ALTER TABLESPACE commands to allocate disk space, reduce unused
disk space and convert a DMS managed tablespace to use automatic storage
management and to move a tablespace to new disks without losing access to the
data.
• Execute and measure the performance differences for a SQL workload with two
different database memory configurations.
• Utilize the REBUILD mode of the RESTORE utility to recover a subset of
database tablespaces using a set of tablespace level backup images.
• Run Db2 commands including db2relocatedb and a redirected RESTORE to
alter the files allocated for Db2 tablespaces. Use the TRANSPORT mode of
RESTORE to copy a set of database objects from one database to another.
• Create a set of Db2 backup images using full and incremental backups to
observe the savings in backup processing and backup storage requirements.
Perform an automatic incremental restore of a tablespace.
The demonstrations utilize Db2 11.1.2.2 on Linux.
Task- You are working in the product and IBM Product - Help link
oriented you need specific task-oriented help.
Advanced monitoring
Unit objectives
• Describe the infrastructure used to support monitoring
• Configure a database to collect the activity, request and object metrics
returned by the Monitoring Table functions
• Investigate current application activity that might indicate performance
problems using SQL statements
• Use the Db2-provided views and functions in SQL to evaluate efficient
use of database memory for locks, sorting and database buffer pools
• Check database health indicators, like log space available and table
space utilization using CLP queries using Monitor functions and views
Unit objectives
Many of the monitor table functions provide call parameters that limit the scope of
processing for collecting metrics to a single occurrence. For example, the table function
MON_GET_TABLE can be called for information about one table.
MON_GET_CONNECTION can be used to access the current in-memory metrics for a
database connection.
Workload Workload
Occurrence (UOW) Definition
∑R ∑R
• MON_GET_UNIT_OF_WORK
Request Metrics • MON_GET_UNIT_OF_WORK_DETAILS
• MON_GET_CONNECTION
• MON_GET_CONNECTION_DETAILS
Database Db2 Agent • MON_GET_SERVICE_SUBCLASS
Request Collects Data • MON_GET_SERVICE_SUBCLASS_DETAILS
• MON_GET_WORKLOAD
• MON_GET_WORKLOAD_DETAILS
Legend • MON_GET_DATABASE
ΣR = Accumulation of request metrics collected by agent • MON_GET_DATABASE_DETAILS
Buffer pool
Metrics
Buffer pool
Container
Metrics
Row Data
LOB /Data
Index
Table XML Data
Table • MON_GET_TABLE
Metrics
• MON_GET_INDEX
Database
Db2 Agent
• MON_GET_BUFFERPOOL
Request
Collects Data • MON_GET_TABLESPACE
• MON_GET_CONTAINER
Legend
ΣA = Accumulation of metrics from activity execution portion of request
MON_GET_BUFFERPOOL mon_obj_metrics
MON_GET_TABLESPACE
MON_GET_CONTAINER
Activity level
These monitor elements provide details about activities being performed on the
system (a specific subset of the work being performed on the system). You can
use these elements to understand the behavior and performance of activities.
Monitor-element access points include individual activities, and entries in the
database package cache.
Data object level
These monitoring elements provide details about the work being processed by
the database system within specific database objects such as indexes, tables,
buffer pools, table spaces, and containers, thereby enabling you to quickly
identify issues with particular data objects that might be causing system
problems. Monitor-element access points include buffer pool, container, index,
table, and table space.
This set of table functions enables you to drill down or focus on request monitor
elements at a particular level of aggregation. Table functions are provided in pairs: one
for relational access to monitor data and the other for XML access to the monitor
elements.
The Monitor table functions with names that end with _DETAILS produce XML
documents containing monitor elements. Examples of these table functions include:
• MON_GET_PKG_CACHE_STMT_DETAILS
• MON_GET_WORKLOAD_DETAILS
• MON_GET_CONNECTION_DETAILS
• MON_GET_SERVICE_SUBCLASS_DETAILS
• MON_GET_ACTIVITY_DETAILS
• MON_GET_UNIT_OF_WORK_DETAILS
• MON_GET_DATABASE_DETAILS
The slide shows an example of a query using the
MON_GET_CONNECTION_DETAILS monitor table function. The XMLTABLE function
is used to selectively present a set of monitor elements from the XML document in the
column named DETAILS in the form of a standard tabular result.
• MON_WORKLOAD_SUMMARY
• MON_CONNECTION_SUMMARY
• MON_DB_SUMMARY
For example, the MON_DB_SUMMARY administrative view returns key metrics
aggregated over all service classes in the currently connected database. It is designed
to help monitor the system in a high-level manner by providing a concise summary of
the database. The view includes information like IO_WAIT_TIME_PERCENT, which
shows the percentage of the time spent waiting within the Db2 database server that
was due to I/O operations. This includes time spent performing direct reads or direct
writes, and time spent reading data and index pages from the table space to the
bufferpool or writing them back to disk.
Sort_Overflows Total_Sorts
-------------------- --------------------
14 49
LOG_DISK_WAIT_TIME LOCK_WAIT_TIME
-------------------- --------------------
0 0
73175 897
72975 718
74581 1059
74166 1158
lw.lock_object_type ,
substr(lw.tabname,1,10) as "TabName",
substr(lw.tabschema,1,10) as "Schema",
How long is the wait?
lw.lock_wait_elapsed_time
as "waiting (s)"
FROM
SYSIBMADM.MON_LOCKWAITS lw ;
Hold App Holder Wait App Waiter LOCK_MODE LOCK_OBJECT_TYPE TabName Schema waiting (s)
---------- ---------- ---------- ---------- --------- ------------------ -------- ------- -----------
db2bp INST461 db2bp INST461 X TABLE HIST1 CLPM 61
% Lock List % to Maxlock Number of Cons Avg Lock Mem Per Con (bytes)
----------- ------------ -------------------- ----------------------------
29.9 59.9 3 819072
1 record(s) selected.
PCT_PREP SQL_Text
-------------------- ----------------------------------------
3 SELECT * from clpm.hist1 order by balanc
1 SELECT * from clpm.hist2 order by balanc
0 SELECT hist2.ACCT_ID, hist2.TELLER_ID, h
0 SELECT * from clpm.hist2 where acct_id
Monitoring performance with SQL queries that have a high prep time
You can examine the package cache to see how frequently a query is run as well as
the average execution time for each of these queries.
The MON_GET_PKG_CACHE_STMT table function returns a point-in-time view of
both static and dynamic SQL statements in the database package cache. In the
example, the ‘d’ call parameter limits the results to dynamic statements.
The query sorts the results based on the time required to prepare the statement. It
compares the statement compilation time, prep_time, to a calculated average execution
time.
If the time it takes to compile and optimize a query is almost as long as it takes for the
query to execute, you might want to look at the optimization class that you are using.
Lowering the optimization class might make the query complete optimization more
rapidly and, therefore, return a result sooner.
In some cases, a query might take a significant amount of time to prepare, but it is
executed thousands of times, without being prepared again. For these statements, the
optimization class might not be an issue.
This query returns information that may indicate that applications are performing large
table scans. The column ROWS_READ_PER_ ROWS_RETURNED shows the
average number of rows read from the table per rows returned to the application. If the
selectivity is low, then the application might be performing a table scan (perhaps
unnecessarily, if an index were available).
The result also shows the percentage of the time spent waiting within the Db2 database
server that was due to I/O operations. This includes time spent performing direct reads
or direct writes, and time spent reading data and index pages from the table space to
the bufferpool or writing them back to disk.
To list the activity on all tables accessed since the database was activated,
aggregated across all database members, ordered by highest number of reads.
5 record(s) selected.
Monitor performance with SQL: Index usage with multiple database partitions
The example SQL query uses the MON_GET_INDEX Monitor table function to list the
cumulative statistics for all indexes defined on a specific set of application tables.
Using a ‘-2’ for the third function call parameter causes the table function to include all
database partitions.
The sample result shows that two of the tables have been accessed on database
partition 1, while the TELLER table has been accessed on database partition 0. The
indexes on these tables that exist but have not been utilized yet show an index scan
count of zero.
Total and
int(sec_log_used_top/1024/1024) as "Max Sec. Used (Meg)",
int(sec_logs_allocated) as "Secondaries" secondary logs
from table (MON_GET_TRANSACTION_LOG(-2)) as tlogs ; high water marks
Log Used (Meg) Log Space Free (Meg) Pct Used Max Log Used (Meg) Max Sec. Used (Meg) Secondaries
-------------- -------------------- -------- ------------------ ------------------- -----------
12 3 76 12 10 14
Total Activity time(msec) Total Activity Wait time UOW Start Time
------------------------- ------------------------ --------------------------
770 66 2013-09-17-11.47.32.768302
Tablespace Name Type Status Size (Meg) % Free Space Meg Free Space
----------------- ---------- -------- ----------- ------------- ---------------
SYSCATSPACE DMS NORMAL 96 23.80 23.39
TEMPSPACE1 SMS NORMAL 0 0.00 0.00
USERSPACE1 DMS NORMAL 32 98.83 32.25
TSP01 DMS NORMAL 0 80.00 0.32
TSP07 SMS NORMAL 0 0.00 0.00
SYSTOOLSPACE DMS NORMAL 32 92.13 29.95
USERTEMP SMS NORMAL 0 0.00 0.00
CLPMTSP1 DMS NORMAL 62 78.18 49.98
CLPMTSP2 DMS NORMAL 62 77.88 49.79
TYPE PATH
-------------------- --------------------------------------------------
DBPATH /database/inst461/NODE0000/SQL00001/
DBPATH /database/inst461/NODE0000/SQL00001/MEMBER0000/
DB_STORAGE_PATH /dbauto/path2/
DB_STORAGE_PATH /dbauto/path1/
LOCAL_DB_DIRECTORY /database/inst461/NODE0000/sqldbdir/
LOGPATH /database/inst461/NODE0000/SQL00001/LOGSTREAM0000/
TBSP_CONTAINER /database/inst461/NODE0000/SQL00001/DMSclpm4
TBSP_CONTAINER /database/inst461/NODE0000/SQL00001/DMSclpm3
TBSP_CONTAINER /database/inst461/NODE0000/SQL00001/DMSCLPM2
TBSP_CONTAINER /database/inst461/NODE0000/SQL00001/DMSclpm1
TBSP_CONTAINER /database/inst461/NODE0000/SQL00001/tsp03
TBSP_CONTAINER /database/inst461/NODE0000/SQL00001/tsp02
TBSP_DIRECTORY /database/inst461/NODE0000/SQL00001/sms/sms01/
appls_cur_cons, agents_top
from TABLE (MON_GET_DATABASE(-1)) AS MONDB )
definition only
Demonstration 1
Db2 advanced monitoring with SQL
• Monitor database buffer pool hit ratios using a command line query
• Check free space in DMS table spaces to see if the allocated disk
space needs to be increased or reduced
• Monitor database and application use of active log space with a
command line query
• Check the performance statistics for Dynamic SQL statements in the
database package cache using a query
• Utilize command line queries to investigate lock contention and the
utilization of database lock memory
Demonstration 1:
Db2 advanced monitoring with SQL
Purpose:
This demonstration will show you how to investigate and address several
common problems including lock waits and low buffer pool hit ratios using
command line queries that select from the Db2 monitor functions and views.
Use the Db2 command file, clpmontables.ddl, to create the buffer pools, table
spaces, tables and indexes that will be used for this demonstration. There are
two new buffer pools, CLPBUFFL has 5000 pages, while CLPBUFFS has 100
pages. There are two table spaces, CLPMTSP1 which uses the larger buffer
pool CLPBUFFL and CLPMTSP2 which uses the small buffer pool CLPBUFFS.
The tables CLMP.HIST1 and CLMP.HIST2 will be created to use the two table
spaces. The table CLPM.TELLER will be created in the CLPMTSP2 table
space.
The file contains the following DDL:
-- Create New tablespaceS, tables and indexes
11 record(s) selected.
Note the Percent of free space for the table spaces CLPMTSP1 and
CLPMTSP2.
CLPMTSP1: % Free space: _______
CLPMTSP2: % Free space: _______
Alter the table space CLPMTSP1, reducing the size of the two containers to
3000 pages each. Rerun the Db2 command file, TablespaceSize.clp, to check
the current size and percentage of free pages in each of the table spaces.
11 record(s) selected.
The tablespace CLPMTSP1 percentage free space should have been reduced
compared to the first result.
The summary at the end of the report should look similar to the following:
* Summary Table:
Type Number Repetitions Total Time (s) Min Time (s) Max Time (s)
Arithmetic Mean Geometric Mean Row(s) Fetched Row(s) Output
--------- ----------- ----------- -------------- -------------- -------------- ---
------------ -------------- -------------- -------------
Block 1 20 10.812892 0.485360 1.280374
0.540645 0.525697 3593920 120
* Total Entries: 1
* Total Time: 10.812892 seconds
* Minimum Time: 10.812892 seconds
* Maximum Time: 10.812892 seconds
* Arithmetic Mean Time: 10.812892 seconds
* Geometric Mean Time: 10.812892 seconds
---------------------------------------------
* Timestamp: Wed Nov 09 2016 15:30:26 EST
Notice the minimum and maximum elapsed times for a set of three queries.
These queries use the table CLPM.HIST1. Run a second set of queries that
reference the table CLPM.HIST2 using db2batch.
4. In the application terminal session, issue the command:
• db2batch -d tp1 -f batchq2.sql
The summary at the end of the report should look similar to the following:
* Summary Table:
Type Number Repetitions Total Time (s) Min Time (s) Max Time (s)
Arithmetic Mean Geometric Mean Row(s) Fetched Row(s) Output
--------- ----------- ----------- -------------- -------------- -------------- ---
------------ -------------- -------------- -------------
Block 1 20 77.854982 3.666034 4.262139
3.892749 3.889844 3593920 120
* Total Entries: 1
* Total Time: 77.854982 seconds
* Minimum Time: 77.854982 seconds
* Maximum Time: 77.854982 seconds
* Arithmetic Mean Time: 77.854982 seconds
* Geometric Mean Time: 77.854982 seconds
---------------------------------------------
* Timestamp: Wed Nov 09 2016 15:35:49 EST
Note the minimum and maximum elapsed times for a set of three queries.
Your results might vary from the example, but the use of a small buffer pool
would be expected to show:
• Longer execution times
• Reduced benefit in improved execution times as the queries were repeated.
Use the Db2 command file, Mon_bufferio.clp, to show buffer pool hit ratios for
each buffer pool. Use the UNIX vi editor to review the results.
Mon_bufferio.clp - reports on the buffer pool hit ratios for data and index page
requests.
select substr(bp_name,1,30) as bp_name ,
pool_data_l_reads, pool_data_p_reads,
(100 * (pool_data_l_reads - pool_data_p_reads )) /( pool_data_l_reads ) as
data_hit_pct,
pool_index_l_reads,pool_index_p_reads ,
(100 * (pool_index_l_reads - pool_index_p_reads )) /( pool_index_l_reads ) as
index_hit_pct
from table (mon_get_bufferpool(NULL,-2) ) as tbuff
where bp_name not like 'IBMSYSTEM%' and pool_data_l_reads > 0 and
pool_index_l_reads > 0
5. In the monitor terminal session, issue the commands:
• db2 -tf Mon_bufferio.clp | tee clpm1.txt
The SQL result will look similar to the following:
BP_NAME POOL_DATA_L_READS POOL_DATA_P_READS DATA_HIT_PCT
POOL_INDEX_L_READS POOL_INDEX_P_READS INDEX_HIT_PCT
------------------------------ -------------------- -------------------- -------------------
- -------------------- -------------------- --------------------
IBMDEFAULTBP 1300 260
80 1716 421 75
CLPBUFFL 139567 2760
98 185 21 88
CLPBUFFS 165692 138299
16 353 251 28
3 record(s) selected.
Notice the lower Data and Index hit ratios for the small buffer pool CLPBUFFS.
In the larger buffer pool CLPBUFFL, Db2 was able to keep more high use
pages in memory to improve the performance of the queries. The buffer pool
CLPBUFFS was too small to retain many of the pages that were read by the
repeating queries.
Increase the buffer pool CLPBUFFS to 5000 pages and rerun the second set of
db2batch queries to evaluate the performance improvement with a larger buffer
pool.
6. In the monitor terminal session, issue the command:
• db2 alter bufferpool clpbuffs immediate size 5000
Type Number Repetitions Total Time (s) Min Time (s) Max Time (s)
Arithmetic Mean Geometric Mean Row(s) Fetched Row(s) Output
--------- ----------- ----------- -------------- -------------- -------------- ---
------------ -------------- -------------- -------------
Block 1 20 10.664639 0.484065 1.264318
0.533232 0.518434 3593920 120
* Total Entries: 1
* Total Time: 10.664639 seconds
* Minimum Time: 10.664639 seconds
* Maximum Time: 10.664639 seconds
* Arithmetic Mean Time: 10.664639 seconds
* Geometric Mean Time: 10.664639 seconds
---------------------------------------------
* Timestamp: Wed Nov 09 2016 15:47:25 EST
8. In the monitor terminal session, issue the commands:
• db2 -tf Mon_bufferio.clp | tee clpm2.txt
• more clpm2.txt
The SQL result will look similar to the following:
BP_NAME POOL_DATA_L_READS POOL_DATA_P_READS DATA_HIT_PCT
POOL_INDEX_L_READS POOL_INDEX_P_READS INDEX_HIT_PCT
------------------------------ -------------------- -------------------- -------------------
- -------------------- -------------------- --------------------
IBMDEFAULTBP 1322 264
80 1744 430 75
CLPBUFFL 139567 2760
98 185 21 88
CLPBUFFS 305923 140990
53 524 267 49
3 record(s) selected.
3 record(s) selected.
The Data and Index Hit Ratios should have improved. The calculated
percentage includes all of the physical reads from the first db2batch runs with
the smaller buffer pool size, so the larger buffer pool will gradually produce a
better hit ratio percentage as more queries are run.
Log Used (Meg) Log Space Free (Meg) Pct Used Max Log Used (Meg) Max Sec. Used
(Meg) Secondaries
-------------- -------------------- ----------- ------------------ ---------------
---- -----------
18 2 86 18
16 22
1 record(s) selected.
At this point, a large percentage of the database log space defined has been
consumed by the uncommitted UPDATE statement.
4. In the monitor terminal session, issue the command:
• db2 -tvf OldTransHoldingLog.clp | tee clpm5.txt
The output should look similar to the following:
select substr(uow.workload_occurrence_state,1,20) as "Status",
substr(uow.session_auth_id,1,10) as "Authid", uow.application_handle as "Appl
Handle",
int(uow.UOW_LOG_SPACE_USED/1024/1024) as "Log Used (M)", uow.total_act_time as
"Total Activity time(msec)", uow.total_act_wait_time as "Total Activity Wait
time", uow.uow_start_time as "UOW Start Time"
from table (MON_GET_TRANSACTION_LOG(-1)) as db,
table (MON_GET_UNIT_OF_WORK(NULL,-1)) as uow
where uow.application_handle = db.APPLID_HOLDING_OLDEST_XACT
1 record(s) selected.
--------- ----------- ----------- -------------- -------------- --------------
This report shows several important pieces of information, the amount of log
space being used by the oldest logged transaction and the current application
status.
Since Db2 must hold all of the database changes from the point of the oldest
transaction to the latest change in the active log space, an application that
enters a prolonged wait status might cause a database log full condition.
If a transaction remains uncommitted for an extended period of time, any
database crash recovery that would occur could take a long time to process all
of the changes from the start of the oldest transaction forward.
Now use a COMMIT statement to free up the logged changes by the application
and then recheck the amount of log space used.
5. In the application terminal session, issue the command:
• db2 commit
6. In the monitor terminal session, issue the command:
• db2 -tf OldTransHoldingLog.clp | tee clpm6.txt
The output should look similar to the following:
Status Authid Appl Handle Log Used (M) Total Activity
time(msec) Total Activity Wait time UOW Start Time
-------------------- ---------- -------------------- ------------ ----------------
--------- ------------------------ --------------------------
0 record(s) selected.
The active log space was freed by the application's COMMIT.
There is currently no active transaction holding database log space so the
monitor query does not return any data results.
1 record(s) selected.
This result shows that the second application is waiting for a lock on the table
CLPM.HIST1 and that an exclusive table lock (X) is held by another application.
The exclusive table lock might have been the result of a lock escalation. Use the
Db2 command file, Mon_ConnectLock.clp, to check if any lock escalations
have occurred.
3 record(s) selected.
This result shows that one of the applications has experienced a lock
escalation.
Use the Db2 command file, LockMemoryUsage.clp, to check the current
status of locklist memory for the database.
% Lock List % to Maxlock Number of Cons Avg Lock Mem Per Con (bytes)
----------- ------------ -------------------- ----------------------------
22.6 226.5 3 6186
1 record(s) selected.
You might wonder if there is a lock memory related problem, why is lock
memory utilization low?
The lock escalation process released a large number of row locks freeing a
large portion of the database lock memory by acquiring an exclusive table level
lock.
Use a SQL COMMIT to complete the transactions and release the locks.
8. In the first application terminal session, issue the commands:
• db2 commit
• db2 connect reset
9. In the second application terminal session, issue the commands:
• db2 commit
• db2 connect reset
In order to avoid the lock escalation and prevent the application lock wait,
increase the size of the locklist to 2000 pages and increase the percentage of
the locklist available for one application to 50%.
Run the same update SQL statements and check the lock status with the db2
queries.
1 record(s) selected.
The increased lock memory and maximum lock storage per application allowed
the two update applications to run concurrently. No single application needed
over 50% of the increased locklist memory for its locks.
The MON_GET_LOCKS table function can be used to produce a summary of
the number of each type of lock held by the current database connections. Use
the Db2 command file, Mon_Locks.clp, to produce a summary of locks held by
each application.
4 record(s) selected.
The two application connections are able to hold table and row locks for the
same table and continue to process without lock waits now.
Use a SQL COMMIT to complete the transactions and release the locks.
15. In the first application terminal session, issue the commands:
• db2 commit
• db2 connect reset
16. In the second application terminal session, issue the commands:
• db2 commit
• db2 connect reset
Use the Db2 command file, clpmonend.ddl, to reset the Db2 database
configuration and drop the table spaces, buffer pools and tables used during
this demonstration.
17. In the monitor terminal session, issue the command:
• db2 -tvf clpmonend.ddl
18. Close all terminals and then logout of the Linux operating system.
Results:
You used a set of SQL statements with Db2 monitor table functions and views
to monitor table space utilization, buffer pool efficiency, database log space
usage and application lock contention.
Unit summary
• Describe the infrastructure used to support monitoring
• Configure a database to collect the activity, request and object metrics
returned by the Monitoring Table functions
• Investigate current application activity that might indicate performance
problems using SQL statements
• Use the Db2-provided views and functions in SQL to evaluate efficient
use of database memory for locks, sorting and database buffer pools
• Check database health indicators, like log space available and table
space utilization using CLP queries using Monitor functions and views
Unit summary
Unit objectives
• Monitor tablespace space allocations using SQL with
MON_GET_TABLESPACE and MON_GET_CONTAINERS functions
• ALTER a table space to handle High Water Mark related issues and
reclaim unused space from DMS and Automatic Storage table spaces
• Use the REBALANCE option to control container allocations for
Automatic Storage table spaces when changing storage paths
• Monitor the processing done by the Rebalancer using LIST UTILITIES
and db2pd commands
• Plan and implement changes to disk space allocations using ALTER
TABLESPACE options: ADD, EXTEND, RESIZE, DROP, and BEGIN
NEW STRIPE SET
• Convert a DMS-managed table space to use Automatic Storage
• Move a Tablespace from one storage group to another
Unit Objectives
Background – DMS table spaces What happens on disk after the following:
db2 create tablespace tb2 managed by
Table space (Logical) Address Map database using (file '/db2file1' 1024,
file '/db2file2' 2048)
0 Table space Header
extentsize 4 prefetchsize 8
1 First SMP Extent
db2 create table t1 in tb2
2 Object Table
db2 create table t2 in tb2
3 Extent Map for T1
4 5
First Extent of Data Pages 6 7
7 for T2 8 9
10 11
8 Another Extent of Data 12 13
Pages for T1 14 15
508 509
31968 Second SMP Extent /db2file1
/db2file2
Db2 Table Space Management © Copyright IBM Corporation 2018
EMPs which provide a map to each page of the object that is stored in the logical table
space address map.
For each table object created, two extents are allocated to hold the extent map for that
object and one extent for storing data. Additional extents will be assigned to the tables
as needed.
Extents are never shared among the objects in a DMS table space, so small tables can
contain a number of empty pages, depending on the extent size defined for the table
space. The indexes for each table are treated as a group object, so all of the indexes
for one table will share a common extent map extent, rather than require one for each
index.
The Db2 Backup utility copies the extents in DMS table spaces up to the High Water
Mark to the backup image. Any Redirected RESTORE of the table space must allocate
containers with space equal to or greater than the High Water Mark at the time of the
BACKUP, even though there might be many free extents included.
Free Free
High Water Mark: Offline table REORG with no temporary tablespace (Example 1)
This shows some of the monitor elements returned by MON_GET_TABLESPACE
before and after a REORG utility was used to reorganize the only table in a table space.
This is an offline REORG, with no temporary table space assigned.
For example:
db2 REORG TABLE TABLE1
If no temporary table space is assigned for the REORG, a new copy of the table is built
using additional extents from the table's table space. The original copy of the table
remains intact until the new copy is completed.
In this example, the reorganization was able to reduce the number of extents required
for TABLE1, so the number of used pages decreased from 72 to 64. The number of
free pages increased from 120 to 128. Those pages are now available to create a new
table or to extend TABLE1.
In this case, the original High Water Mark was 72, which was equal to the number of
used pages. The REORG increased the table space High Water Mark from 72 to 112,
because table data was copied to higher numbered extents. The current High Water
Mark is higher than the number of used pages because there are now 6 free extents
(48 pages) below the point of the High Water Mark.
High Water Mark: Offline table REORG With no temporary tablespace (Example 2)
This shows some of the monitor elements returned by MON_GET_TABLESPACE
before and after a REORG utility was used to reorganize the only table in a table space.
This is an offline REORG, with no temporary table space assigned.
For example:
db2 REORG TABLE TABLE1
Like the previous example, no temporary table space is assigned for the REORG, so
the new copy of the table is built using additional extents from the table's table space. In
this case, there were enough free extents below the High Water Mark to make the copy
of the table.
In this example, the reorganization did not reduce the number of extents required for
TABLE1, so the number of used pages remained 56 and the number of free pages
remained 136.
The original High Water Mark was 104 and there were a number of free extents below
that point in the table space. The extent holding the original High Water Mark was freed
by the reorganization so the High Water Mark decreased from 104 to 56, because table
data was copied to lower numbered extents. The current High Water Mark is now equal
to the number of used pages.
In each case, the database manager attempts to reduce the size by moving extents to
the beginning of the table space, which, if sufficient free space is available, will reduce
the high water mark of the table space. Once the movement of extents has completed,
the table space size is reduced to the new high water mark.
If you do not specify an amount by which to reduce the table space, the table space
size is reduced as much as possible without moving extents. The database manager
attempts to reduce the size of the containers by first freeing extents for which deletes
are pending. (It is possible that some pending delete extents cannot be freed for
recoverability reasons, so some of these extents might remain.) If the high water mark
was among those extents freed, then the high water mark is lowered, otherwise no
change to the high water mark takes place. Next, the containers are re-sized such that
total amount of space in the table space is equal to or slightly greater than the high
water mark. This operation is performed using the ALTER TABLESPACE with the
REDUCE clause by itself.
If you only want to lower the High Water Mark, consolidating in-use extents lower in the
table space without performing any container operations, you can use the ALTER
TABLESPACE statement with the LOWER HIGH WATER MARK clause. This option
moves the maximum number of extents in order to lower the high water mark, however,
no container re-sizing operations are performed. This operation is performed using the
ALTER TABLESPACE with the LOWER HIGH WATER MARK clause by itself.
Once a REDUCE or LOWER HIGH WATER MARK operation is under way, you can
stop it by using the REDUCE STOP or LOWER HIGH WATER MARK STOP clause of
the ALTER TABLESPACE statement. Any extents that have been moved will be
committed, the high water mark will be reduced to it's new value and containers will be
re-sized to the new high water mark.
ALTER
DROP Table2 TABLESPACE …
DROP Table3 REDUCE MAX
ALTER
TABLESPACE …
REDUCE 25
DROP Table2
PERCENT
DROP Table3
6 record(s) selected.
Extent 2 Extent 3
Data for objects is balanced across
Extent 4 Extent 5
the containers
Extent 6 Extent 7
................ ................
It is also a fairly straightforward process in the case where there is more than one
container and each of the containers is the same size. The first extent in the table
space (containing pages 0 to (extent size - 1)) will be located in the first container, the
second extent will be located in the second container, and so on. After the last
container, the process repeats in a round-robin fashion, starting back at the first
container.
For table spaces containing containers of different sizes, Db2 can not use a simple
round-robin approach for the entire range of space because some containers can hold
more than others.
The example shows a table space created with the following DDL:
CREATE REGULAR TABLESPACE DMSTS1
MANAGED BY DATABASE USING (FILE 'DMSCONT1' 1000, FILE 'DMSCONT2' 1000)
EXTENTSIZE 8 ;
The two containers are the same size (1000 pages), so there is one range (range 0)
with all extents striped across both containers (numbered 0 and 1). Each stripe,
therefore, has two extents.
There are 2000 total pages, but two extents of 8 pages each were used by Db2 for the
container tags, so there are 1984 pages left (numbered 0 to 1983).
The 1984 pages are in 248 extents (numbered 0 to 247), so the Max Extent shown is
247.
DMSCONT1 DMSCONT2
DMSCONT1 DMSCONT2 DMSCONT3
Container 0 Container 1
Container 0 Container 1 Container 2
1000 pages 1000 pages
1000 pages 1000 pages 1000 pages
Extent 246 Extent 247 Extent 369 Extent 370 Extent 371
• When a new container is added to a DMS managed tablespace using ADD Db2
will rebalance extents automatically
• Rebalance stops at the HWM for the tablespace
• REBALANCE performed asynchronous to ALTER processing
Db2 Table Space Management © Copyright IBM Corporation 2018
The addition of the new container using the ADD option for this current example means
that Db2 needs to rebalance the existing data stored in the first two containers so that
the data is evenly spread across all three containers.
This is done starting at the lowest numbered extents up to the point of the current High
Water Mark for the table space. In the visual, it shows that Extent 2 is moved from
Container 0 to Container 2. Next, Extent 3 is moved from Container 1 to Container 0.
This continues, extent by extent, until the rebalancer reaches the table space High
Water Mark. Empty extents above the High Water Mark do not need to be processed,
but empty extents below the High Water Mark are moved.
Applications can continue to access the data in this table space while the rebalancer is
running.
ALTER TABLESPACE DMSTS1 BEGIN NEW STRIPE SET (FILE 'DMSCONT3' 1000)
DMSCONT1 DMSCONT2
DMSCONT1 DMSCONT2
Container 0 Container 1 Stripe Set 0
Container 0 Container 1
1000 pages 1000 pages
1000 pages 1000 pages
Stripe Set 1
DMSCONT3
Container 2
1000 pages
1 Extent 371
1) 2) Extending C0 results 3)
Adding the new
in a new range being
stripe set here
C0 C1 C0 C1 created that holds C0 C1
results in a new
only that one
range being created
container. Hence,
in the tables space
auto-resize will only
map. Hence, auto-
extend that one C2 C3 resize will only
container.
extend these new
containers from here on.
Two other attributes, MAXSIZE and INCREASESIZE, are associated with autoresize
table spaces.
Maximum size (MAXSIZE)
The MAXSIZE clause on the CREATE TABLESPACE statement defines the maximum
size for the table space. For example, the following statement creates a table space
that can grow to 100 megabytes (per partition if the database has multiple partitions):
CREATE TABLESPACE DMS1 MANAGED BY DATABASE
USING (FILE '/db2files/DMS1' 10 M)
AUTORESIZE YES MAXSIZE 100 M
The MAXSIZE NONE clause specifies that there is no maximum limit for the table
space. The table space can grow until a file system limit or Db2's table space limit has
been reached (see the SQL Limits section in the SQL Reference). No maximum limit is
the default if the MAXSIZE clause is not specified when the AUTORESIZE feature is
enabled.
The ALTER TABLESPACE statement changes the value of MAXSIZE for a table space
that has AUTORESIZE already enabled. For example:
ALTER TABLESPACE DMS1 MAXSIZE 1 G
ALTER TABLESPACE DMS1 MAXSIZE NONE
If a maximum size is specified, the actual value that Db2 enforces might be slightly
smaller than the value provided because Db2 attempts to keep container growth
consistent. It might not be possible to extend the containers by equal amounts and
reach the maximum size exactly.
Increase size (INCREASESIZE)
The INCREASESIZE clause on the CREATE TABLESPACE statement defines the
amount of space used to increase the table space when there are no free extents within
the table space, and a request for one or more extents has been made. The value can
be specified as an explicit size or as a percentage. For example:
CREATE TABLESPACE DMS1 MANAGED BY DATABASE
USING (FILE '/db2files/DMS1' 10 M)
AUTORESIZE YES INCREASESIZE 5 M
Automatic Table Space 14 Table Space 13 Table Space 12 Table Space 11 Table Space 10 Table Space 9 … Table Space 1
Storage …
Table Space
Physical Disk
TOTAL_PATH_MB PATH_FREE_MB
-------------------- --------------------
20940 5649
20940 5649
2 record(s) selected.
Authorization
One of the following authorities is required to execute the routine:
• EXECUTE privilege on the routine
• DATAACCESS authority
• DBADM authority
• SQLADM authority
1. New containers are allocated on the target storage group’s storage paths.
2. All original containers are marked drop pending and new allocation
requests are satisfied from the new containers
3. A reverse rebalance is preformed, moving data off of the containers on the
paths being dropped
4. The containers are physically dropped
Monitoring extent movement for when the storage group is altered for a table space
You can use the MON_GET_REBALANCE_STATUS table function to monitor the
progress of rebalance operations on a database.
This procedure returns data for a table space only if a rebalance operation is in
progress. Otherwise, no data is returned.
To monitor a table space rebalance operation:
Issue the MON_GET_REBALANCE_STATUS table function with the tbsp_name and
dbpartitionnum parameters:
SELECT
VARCHAR(TBSP_NAME, 30) AS TBSP_NAME,
DBPARTITIONNUM,
MEMBER,
REBALANCER_MODE,
REBALANCER_STATUS,
REBALANCER_EXTENTS_REMAINING,
REBALANCER_EXTENTS_PROCESSED,
REBALANCER_START_TIME
FROM TABLE(MON_GET_REBALANCE_STATUS(NULL,-2)) AS TRESULTS
C0 C1 C0 C1 C0 C1
TS grows until New stripe set
C2 C3 C2 can't grow C2 C3 added automatically C2 C3 Note: For
C4 simplicity, we're
just showing one
table space within
the database
Two storage paths One New storage paths REBALANCE causes Db2 If table space is not growing
table space has a not used by the to create equal-sized rapidly, consider REDUCing
container on each path table space containers in new paths, it to make space available
immediately and redistribute extents to for other table spaces
them
p1 p2 p1 p2 p3 p4 p1 p2 p3 p4 p1 p2 p3 p4
C0 C1 C2 C3
C0 C1 C0 C1 C0 C1 C2 C3
p1 p2 p3 p1 p2 p3 p1 p3
ALTER TABLESPACE
TS1 TS1 REBALANCE TS1
C1 C2 C3 C1 C2 C3
C1 C3
C1 C2 C3 TS2 C1 C2 C3
ALTER TABLESPACE
TS2 REBALANCE
C1 C3 TS2
ALTER STOGROUP…
DROP ‘p2’
Drop Pending
• Issue the ALTER TABLESPACE statement again, this time specifying the
REBALANCE option. This option removes the original user-defined containers
so that all table space containers are managed by Automatic Storage. If you
do not specify the REBALANCE option now and issue the ALTER
TABLESPACE statement later with the REDUCE option, your Automatic
Storage containers will be removed. To recover from this problem, issue the
ALTER TABLESPACE statement, specifying the REBALANCE option.
• Use a redirected restore operation. If you are converting a single table space
with this method, you cannot access the table space while the operation is in
progress. If you are converting multiple table spaces, you cannot access the
entire database while the operation is in progress.
• Run the RESTORE DATABASE command, specifying the REDIRECT
parameter. If you want to convert a single table space, also specify the
TABLESPACE parameter:
RESTORE DATABASE database_name TABLESPACE table_space_name
REDIRECT
• Run the SET TABLESPACE CONTAINERS command, specifying the USING
AUTOMATIC STORAGE parameter, for each table space that you want to
convert:
SET TABLESPACE CONTAINERS FOR tablespace_id USING AUTOMATIC
STORAGE
• Run the RESTORE DATABASE command again, this time specifying the
CONTINUE parameter:
RESTORE DATABASE database_name CONTINUE
• Run the ROLLFORWARD DATABASE command, specifying the TO END
OF LOGS and AND STOP parameters: ROLLFORWARD DATABASE
database_name TO END OF LOGS AND STOP
Demonstration 1
• Db2 Tablespace Management
• Monitor the process of the DB2 rebalancer utility using the LIST UTILITIES command
• Enable the AUTORESIZE option for a DMS table space to grow the table space size based
on application demand
• Use SQL table functions to monitor tablespace space utilization
• Implement storage groups for automatic storage tablespaces and move a tablespace
between storage groups without losing access to the tables
• Compare management of DMS managed and Automatic storage managed tablespaces
• Use the ALTER TABLESPACE option BEGIN NEW STRIPE SET to add space to a DMS
table space without rebalancing the existing data extents
• Convert a DMS managed table space to utilize automatic storage management
• Use ALTER tablespace commands to reduce unused space in DMS and Automatic Storage
managed tablespaces.
• Adjust the space allocation for a DMS table space using the DROP and RESIZE options of
ALTER TABLESPACE
Demonstration 1
Db2 Tablespace Management
This demonstration allows you to manage the disk space allocated for tables
in a DMS managed and Automatic Storage managed table spaces.
4. Use a db2pd command to list the storage groups, including the system default
storage group.
• db2pd -db tp1-storage
The output from this command will look similar to the following:
Database Member 0 -- Database TP1 -- Active -- Up 0 days 00:03:07 -- Date 2018-03-
08-09.19.09.574455
First, you will create the DMS managed tablespace named DMSMTSPD, and
create two new tables DMSM.HIST1 and DMSM.HIST2 with indexes.
You will use the file dmstables.ddl to create the database objects.
dmstables.ddl
-- Create New DMS tablespace FOR DMS MANAGEMENT
DMSMTSPD 1 0 FILE_EXTENT_TAG
4000 3992 /database/inst464/NODE0000/SQL00001/DMSCONT2
4 record(s) selected.
2 record(s) selected.
Use the LOAD utility to load data into the two tables, DMSM.HIST1 and
DMSM.HIST2 in the DMS managed tablespace and the tables ASM.HIST1 and
ASM.HIST2 in the automatic storage managed tablespace. Query the space
consumed by loading the tables using the query file mon_space.sql.
8. In the terminal session, issue the following commands:
• db2 -tvf dmsloads.ddl
• db2 -tvf asmloads.ddl
• db2 -tvf mon_space.sql
The output from this command will look similar to the following:
select varchar(TBSP_NAME,10) As TBSP_NAME, container_id, stripe_set ,
container_type, total_pages, usable_pages from table(mon_get_container(NULL,-1))
AS cont where TBSP_NAME IN ('DMSMTSPD','ASMTSPD') order by TBSP_NAME,container_id
4 record(s) selected.
2 record(s) selected.
Notice that the automatic storage tablespace, ASMTSPD has automatically
increased in size to 7472 pages from 5120 pages.
The DMS tablespace, DMSMTSPD was not defined with AUTORESIZE
enabled, but the initial allocation was large enough to hold the data loaded.
You will use the ALTER STOGROUP command to add a third path to the first
storage group named SG1. As the tablespace ASMTSPD grows, this new path
will not be used unless space on the current paths is unavailable. This avoids
the need to rebalance extents. Use the command in the file altergroup1.ddl to
add the new path.
altergroup1.ddl
alter stogroup sg1
add '/home/inst464/dmsts/sg1path3' ;
SQL3107W At least one warning message was encountered during LOAD processing.
2 record(s) selected.
The tablespace ASMTSPD has increased in size to hold the additional data.
The tablespace DMSMTSPD is not enabled for AUTORESIZE so the load
processing could not complete.
The load processing can be restarted once the space allocation problem is
addressed.
You could just enable AUTORESIZE for the tablespace DMSMTSPD, but we
will first add a new container to manually increase the allocated space.
Use the Db2 command in the file dmsalter1.ddl to add a new container to the
DMSMTSPD tablespace. The container is the same size as the original
containers, so the total allocation is increased by 50 percent. The file also
includes the LIST UTILITIES command that can be used to show the rebalance
operation that is triggered by the addition of the new container.
12. In the terminal session, issue the following command:
• db2 -tvf dmsalter1.ddl
The output from this command will look similar to the following:
alter tablespace dmsmtspd add (file 'DMSCONT3' 4000)
DB20000I The SQL command completed successfully.
ID = 78
Type = REBALANCE
Database Name = TP1
Member Number = 0
Description = Tablespace ID: 8
Start Time = 03/08/2018 12:16:48.917673
State = Executing
Invocation Type = User
Throttling:
Priority = Unthrottled
Progress Monitoring:
Estimated Percentage Complete = 0
Total Work = 998 extents
Completed Work = 3 extents
Start Time = 03/08/2018 12:16:48.917689
The LIST UTILITIES command sample output shows 998 extents, each with 8
pages, or 7984 pages need to be moved. This is the number of currently used
pages in the tablespace.
It is possible that in your test, the LIST UTILITIES starts before the
REBALANCE begins processing. You can run the command ‘db2 list utilities
show detail’ manually.
You will enable AUTORESIZE for the tablespace DMSMTSPD to handle
additional growth requirements automatically.
13. In the terminal session, issue the following command:
• db2 alter tablespace dmsmtspd autoresize yes
You can restart the failed load by running the command file dmsload4.ddl,
which includes the RESTART option of the LOAD utility to complete the
previously started load utility.
Use the SQL in the file mon_tsfree.sql to show the current table space
utilization.
14. In the terminal session, issue the following commands:
• db2 -tvf dmsload4.ddl
• db2 -tvf mon_tsfree.sql
The output from this command will look similar to the following:
select varchar(TBSP_NAME,20) As TBSP_NAME, TBSP_TOTAL_PAGES as Total_pages,
TBSP_USED_PAGES as Used_pages , (100 * TBSP_USED_PAGES / TBSP_TOTAL_PAGES ) as
PCT_USED, TBSP_PAGE_TOP as High_water_MARK, (100 * TBSP_PAGE_TOP /
TBSP_TOTAL_PAGES ) as PCT_HWM from table (mon_get_tablespace(NULL,-1)) AS TBSP
where TBSP_NAME IN ('DMSMTSPD','ASMTSPD') order by TBSP_NAME
2 record(s) selected.
The tablespace DMSMTSPD was able to handle the load processing with the
addition of the third container and is currently 70 percent utilized.
The rebalancer process triggered by adding a new container can generate a
large number of disk I/Os during its processing. If additional space is needed as
soon as possible, and the overhead of rebalancing needs to be avoided, a new
container can be added using the BEGIN NEW STRIPE SET option.
Use the Db2 command in the file dmsalter2.ddl to add a fourth container as a
new stripe set to avoid the rebalance processing.
ID = 80
Type = REBALANCE
Database Name = TP1
Member Number = 0
Description = Tablespace ID: 9
Start Time = 03/08/2018 12:35:59.863092
State = Executing
Invocation Type = User
Throttling:
Priority = Unthrottled
Progress Monitoring:
Estimated Percentage Complete = 0
Total Work = 1054 extents
Completed Work = 3 extents
Start Time = 03/08/2018 12:35:59.863105
The LIST UTILITIES output shows 1054 extents, all 8,432 pages will be moved.
Use the SQL query in the file mon_cont1.sql to show the current containers and
space allocations.
7 record(s) selected.
2 record(s) selected.
The tablespace ASMTSPD was assigned a third container with a size equal to
the other two containers, so it is now about 60 percent utilized.
You could use ALTER TABLESPACE REDUCE to free some extra disk space,
but leave the space allocated for now, in order to provide space for planned
table reorganizations.
If a REORG utility is run offline and no temporary table space is requested, the
reorganization will allocate additional pages from the table's table space.
Use the Db2 command file reorgs.ddl to reorganize two tables DMSM.HIST1
and ASM.HIST1.
Use the SQL in the file mon_tsfree.sql to show the current table space
utilization.
18. In the terminal session, issue the following commands:
• db2 -tvf reorgs.ddl
• db2 -tvf mon_tsfree.sql
The output from this command will look similar to the following:
select varchar(TBSP_NAME,20) As TBSP_NAME, TBSP_TOTAL_PAGES as Total_pages,
TBSP_USED_PAGES as Used_pages , (100 * TBSP_USED_PAGES / TBSP_TOTAL_PAGES ) as
PCT_USED, TBSP_PAGE_TOP as High_water_MARK, (100 * TBSP_PAGE_TOP /
TBSP_TOTAL_PAGES ) as PCT_HWM from table (mon_get_tablespace(NULL,-1)) AS TBSP
where TBSP_NAME IN ('DMSMTSPD','ASMTSPD') order by TBSP_NAME
2 record(s) selected.
Running the REORG utilities decreased the number of used pages because the
tables were loaded with extra free space. The table space high water marks are
now much higher because new, higher numbered extents were allocated during
the REORG.
Drop two of the tables, DMSM.HIST2 and ASM.HIST2 using the statements in
the file droptables.ddl, and check the status of the table space using
mon_tsfree.sql command file.
2 record(s) selected.
Dropping the two tables decreased the number of used pages in each of the
tablespaces.
The table space high water marks did not change because the highest allocated
extent is still used by another object in the table space.
Having the high water mark for these tablespaces is not always a matter of
concern. If you plan to use the free space for expanding existing objects or
adding new objects you do not need to do anything.
If you need to reclaim the space and reduce the size of the tablespace
containers, then the position of the high water marks does need to be
considered.
Task 2. Lowering the table space high water mark.
Remove two of the two containers that were previously allocated to the
tablespace DMSMTSPD, using the ALTER TABLESPACE DROP command.
The file dmsalter3.ddl contains the statement to drop two of the containers.
1. In the Linux terminal session, issue the commands:
• db2 -tvf dmsalter3.ddl
The output from this command will look similar to the following:
alter tablespace dmsmtspd drop (file 'DMSCONT2', file 'DMSCONT3')
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL20170N There is not enough space in the table space "DMSMTSPD" for the
The current high water mark for the table space will not allow both containers to
be dropped.
You can use the LOWER HIGH WATER MARK option of the ALTER
TABLESPACE command to reduce the high water mark for the DMSMTSPD
table space. Use the dmsalter4.ddl command file to lower the high water mark
for the DMS tablespace and check the status of the table space using
mon_tsfree.sql command file.
2. In the Linux terminal session, issue the commands:
• db2 -tvf dmsalter4.ddl
• db2 -tvf mon_tsfree.sql
The output from this command will look similar to the following:
select varchar(TBSP_NAME,20) As TBSP_NAME, TBSP_TOTAL_PAGES as Total_pages,
TBSP_USED_PAGES as Used_pages , (100 * TBSP_USED_PAGES / TBSP_TOTAL_PAGES ) as
PCT_USED, TBSP_PAGE_TOP as High_water_MARK, (100 * TBSP_PAGE_TOP /
TBSP_TOTAL_PAGES ) as PCT_HWM from table (mon_get_tablespace(NULL,-1)) AS TBSP
where TBSP_NAME IN ('DMSMTSPD','ASMTSPD') order by TBSP_NAME
2 record(s) selected.
The ALTER TABLESPACE has reduced the High Water Mark for the
DMSMTSP table space by allocating lower numbered free extents and
releasing the higher numbered extents.
Now the ALTER TABLESPACE command that removes the two containers that
were previously added can be tried again. Use the file dmsalter3.ddl to drop the
containers and issue the LIST UTILITIES to monitor the rebalancer processing.
ID = 83
Type = REBALANCE
Database Name = TP1
Member Number = 0
Description = Tablespace ID: 8
Start Time = 03/08/2018 13:47:35.387924
State = Executing
Invocation Type = User
Throttling:
Priority = Unthrottled
Progress Monitoring:
Estimated Percentage Complete = 0
Total Work = 407 extents
Completed Work = 0 extents
Start Time = 03/08/2018 13:47:35.387938
ASMTSPD 2 0 FILE_EXTENT_TAG
4512 4504
/home/inst464/dmsts/sg1path3/inst464/NODE0000/TP1/T0000009/C0000002.USR
DMSMTSPD 0 0 FILE_EXTENT_TAG
4000 3992 /database/inst464/NODE0000/SQL00001/DMSCONT1
DMSMTSPD 1 1 FILE_EXTENT_TAG
2000 1992 /database/inst464/NODE0000/SQL00001/DMSCONT4
5 record(s) selected.
2 record(s) selected.
The DMSMTSPD tablespace now has two remaining containers, in two stripe
sets.
The DMSMTSPD table space status shows that almost 50% of the remaining
pages are free and the high water mark is not an issue.
DMSMTSPD 2 2 FILE_EXTENT_TAG
2728 2720
/home/inst464/dmsts/sg1path1/inst464/NODE0000/TP1/T0000008/C0000000.USR
DMSMTSPD 3 2 FILE_EXTENT_TAG
2728 2720
/home/inst464/dmsts/sg1path2/inst464/NODE0000/TP1/T0000008/C0000001.USR
DMSMTSPD 4 2 FILE_EXTENT_TAG
2728 2720
/home/inst464/dmsts/sg1path3/inst464/NODE0000/TP1/T0000008/C0000002.USR
8 record(s) selected.
2 record(s) selected.
The DMSMTSPD tablespace now has five containers in three stripe sets. The
original two containers are still allocated, and three new containers have been
added, one for each path of the storage group SG1.
Next you will use the ALTER TABLESPACE REBALANCE command to release
the original DMS containers. The file dmsalter6.ddl contains the ALTER
TABLESPACE REBALANCE command and a LIST UTILITIES command to
show the rebalance processing that is triggered.
3. In the Linux terminal session, issue the commands:
• db2 -tvf dmsalter6.ddl
The output from this command will look similar to the following:
alter tablespace dmsmtspd rebalance
DB20000I The SQL command completed successfully.
ID = 84
Type = REBALANCE
ID = 85
Type = REBALANCE
Database Name = TP1
Member Number = 0
Description = Tablespace ID: 9
Start Time = 03/12/2018 07:50:05.334760
State = Executing
Invocation Type = User
Throttling:
Priority = Unthrottled
Progress Monitoring:
4 record(s) selected.
2 record(s) selected.
The ASMTSPD tablespace now has one container, since the new storage
group, SG2 has only one path defined. This ALTER command assigned the
new container and released the containers from the original storage group.
No manual REBALANCE is required, but the high water mark has not changed,
so the allocation exceeds the current space required which is about 30 percent
of the allocated space.
Next you will use the ALTER TABLESPACE REDUCE MAX command to
release all unused space from the tablespace ASMTSPD. The file asalter2.ddl
contains the ALTER TABLESPACE command and a LIST UTILITIES command
to show if a rebalance is triggered.
3. In the Linux terminal session, issue the commands:
• db2 -tvf asalter2.ddl
The output from this command will look similar to the following:
alter tablespace asmtspd reduce max
DB20000I The SQL command completed successfully.
Use the SQL query in mon_cont1.sql to show the containers assigned and
tablespace usage statistics.
4. In the Linux terminal session, issue the commands:
• db2 -tf mon_cont1.sql
The SQL result will look similar to the following:
TBSP_NAME CONTAINER_ID STRIPE_SET CONTAINER_TYPE
TOTAL_PAGES USABLE_PAGES CONTAINER_NAME
-------------------- -------------------- -------------------- ---------------- --
------------------ -------------------- ------------------------------------------
------------------------------------------------
ASMTSPD 0 0 FILE_EXTENT_TAG
3264 3256
/home/inst464/dmsts/sg2path1/inst464/NODE0000/TP1/T0000009/C0000003.USR
DMSMTSPD 0 0 FILE_EXTENT_TAG
2728 2720
/home/inst464/dmsts/sg1path1/inst464/NODE0000/TP1/T0000008/C0000000.USR
DMSMTSPD 1 0 FILE_EXTENT_TAG
2728 2720
/home/inst464/dmsts/sg1path2/inst464/NODE0000/TP1/T0000008/C0000001.USR
DMSMTSPD 2 0 FILE_EXTENT_TAG
2728 2720
/home/inst464/dmsts/sg1path3/inst464/NODE0000/TP1/T0000008/C0000002.USR
4 record(s) selected.
2 record(s) selected.
The ASMTSPD tablespace now has one container that is just large enough to
hold the currently used space, and is 99 percent full, but since AUTORESIZE is
enabled, the tablespace can grow easily to handle increased storage
requirements.
Drop the table spaces DMSMTSPD and ASMTSPD and the STOGROUPs SG1
and SG2 using the command file dmsend.ddl.
Unit summary
• Monitor tablespace space allocations using SQL with
MON_GET_TABLESPACE and MON_GET_CONTAINERS functions
• ALTER a table space to handle High Water Mark related issues and
reclaim unused space from DMS and Automatic Storage table spaces
• Use the REBALANCE option to control container allocations for
Automatic Storage table spaces when changing storage paths
• Monitor the processing done by the Rebalancer using LIST UTILITIES
and db2pd commands
• Plan and implement changes to disk space allocations using ALTER
TABLESPACE options: ADD, EXTEND, RESIZE, DROP, and BEGIN
NEW STRIPE SET
• Convert a DMS-managed table space to use Automatic Storage
• Move a Tablespace from one storage group to another
Unit summary
Unit objectives
• Describe memory heap usage for instance memory, database shared
memory and application memory
• Explain the management of database shared memory based on setting
the configuration option DATABASE_MEMORY to AUTOMATIC or a
specific number of pages
• Select the mode for managing data sort memory using SORTHEAP,
and SHEAPTHRES_SHR
• Monitor Db2 memory usage using the db2mtrk commands and SQL
statements
• Utilize the db2pd command for monitoring current database memory
usage
• Describe how STMM can be used to automatically manage database
shared memory heaps
• Implement Db2 Self Tuning Memory Management (STMM) for all or
selected database memory heaps
Db2 Database Memory Management © Copyright IBM Corporation 2018
Unit objectives
• FMP -Fenced mode process memory set. Memory allocated from this set is used
for communications between agents and fenced mode processes. Memory
allocations from this set can be configured with the DB2_FMP_COMM_HEAPSZ
registry variable and the aslheapsz configuration parameter.
• FCM - Fast communication manager memory set. Memory allocated from this set
is used exclusively by the fast communications manager. Memory from this set
can be configured with the fcm_num_buffers and the fcm_num_channels
database manager configuration parameters.
The memory in a given memory set shares common attributes, such as the general
purpose for which the memory is used, its expected volatility, and what, if any
constraints there might be on its growth. For example, buffer pools are allocated from
the database memory set, and are allocated as long as the database is active.
Statement heaps are allocated from the application memory set on behalf of specific
SQL preparation requests from an application, and last only as long as the statement
compilation operation.
Within each memory set, specific areas of memory get assigned for purposes that are
generally related to the specific memory set type. For example, certain types of
database-level processing use memory from the database memory set; memory
required for the fast communications manager is allocated from the FCM memory set.
Some areas of database shared memory are not supported for management by STMM.
The database utility heap, defined by util_heap_sz, is critical to the performance of
Db2 utilities like Backup, Restore and the LOAD utility. Since these utilities do not run
continuously it would be difficult for STMM to predict the correct amount of memory
needed for the utilities. The LOAD utility was designed to self-optimize its performance
by acquiring a percentage of the currently available memory in the utility heap when it
starts processing. A similar automatic buffer calculation was also added for Backup and
Restore utilities. Since STMM cannot know when these utilities are scheduled to run, it
will be necessary for a DBA to configure the size of the utility heap, which can be
changed using Db2 commands. A DBA might decide to take memory from a large
buffer pool and assign it to the utility heap just before the scheduled LOAD processing
starts.
The database heap can be configured as AUTOMATIC, but this simply means that Db2
will grow this heap as needed to support the current workload, but STMM will take
memory from the database heap and use it to increase another heap.
BP 1 BP 2 BP 3 BP 4
New Allocation
New Allocation
Catalog Cache Heap (CATALOGCACHE_SZ) Database Heap (DBHEAP)
Lock Manager storage and Buffer Pools do not expand on demand but
these could be Managed by STMM
Db2 Database Memory Management © Copyright IBM Corporation 2018
Overflow Buffer can be used to handle peak memory demands for some heaps
Db2 can use the database shared memory associated with the overflow buffer to
handle some unexpected demands for some of the database heaps. Db2 can use this
available database shared memory to extent the shared sort memory, the utility heap,
the package cache, catalog cache and the database heap. For example, if a Db2 LOAD
utility was started with a large DATA BUFFER defined and the utility heap did not have
enough free memory to satisfy the request size, the additional memory could be taken
from the overflow buffer.
Db2 will not extend buffer pools or the lock list memory in the same way, both of these
areas can be managed by self-tuning memory management if they are configured as
AUTOMATIC which allows their size to be adjusted gradually based on the current
workload.
In the example, if the current applications required larger amounts Package Cache
memory, Db2 would use pages from the overflow buffer, defined by
DATABASE_MEMORY to meet that demand. Extending the number of pages assigned
to those areas which might reduce the memory available to other parts of database
global memory.
All buffer pools are allocated when the first application connects to the database, or
when the database is explicitly activated. As an application requests data out of the
database, pages containing that data are transferred to one of the buffer pools from
disk. Pages are not written back to disk until the page is changed and one of the
following occurs:
• All applications disconnect from the database
• The database is explicitly deactivated
• The database quiesces (that is, all connected applications have committed)
• Its space is required for another page that needs to be read into the buffer pool
• A page cleaner is available (num_iocleaners) and is activated by Db2.
Buffer pool size is significant both in Warehouse as well as in an OLTP environment. In
Warehouse environments there is a significant dependence on prefetch. In an OLTP
environment there is typically repetitive access to indexes, and often also to data
pages. There is minimal overhead associated with each I/O server. This means that a
large buffer pool size can reduce disk activity, improving response time and throughput.
A rule of thumb is to strive for a sufficiently large buffer pool size for all important and
highly used objects (such as index pages) to remain in memory.
Database Member 0 -- Database TP1 -- Active -- Up 0 days 00:28:44 -- Date 02/06/2013 15:45:43
Bufferpools:
First Active Pool ID 1
Max Bufferpool ID 4
Max Bufferpool ID on Disk 4
Num Bufferpools 8
The dbheap value that you configure represents only a portion of the database heap
that is allocated. The database heap is the main memory area used to satisfy global
database memory requirements. It is sized to include basic allocations needed for the
startup of a database in addition to the dbheap value. Tools which report memory
usage such as Memory Tracker, Snapshot Monitor, and db2pd report the statistics of
this larger database heap. There is no separate tracking of the allocations that are
represented by the dbheap configuration parameter. Therefore, it is normal for the
statistics on database heap memory usage reported from these tools to exceed the
configured value for the dbheap parameter.
Table A-descriptor
Catalog Cache Lookups
catalogcache_sz Table B-descriptor (successful and unsuccessful)
View A-descriptor
Alias A-descriptor
• Catalog Cache Overflows: The number of times that the catalog cache
overflowed the bounds of its allocated memory. Usage: Use this element with
cat_cache_size_top to determine whether the size of the catalog cache needs to
be increased to avoid overflowing.
Catalog cache space is reclaimed by evicting table descriptor information for
tables, views, or aliases, or authorization information that is not currently in use by
any transaction.
If cat_cache_overflows is large, the catalog cache might be too small for the
workload. Enlarging the catalog cache might improve its performance. If the
workload includes transactions which compile a large number of SQL statements
referencing many tables, views, aliases, user-defined functions, or stored
procedures in a single unit of work, then compiling fewer SQL statements in a
single transaction might improve the performance of the catalog cache. Or if the
workload includes binding of packages containing many SQL statements
referencing many tables, views, aliases, user-defined functions, or stored
procedures, you can try splitting packages so that they include fewer SQL
statements to improve performance.
• Catalog Cache High Water Mark: The largest size reached by the catalog cache.
This element indicates the maximum number of bytes the catalog cache required
for the workload run against the database since it was activated. If the catalog
cache overflowed, then this element contains the largest size reached by the
catalog cache during the overflow. Check Catalog Cache Overflows to determine
if such a condition occurred.
User 3
The total amount of memory available for the global SQL cache is determined by the
value of the PCKCACHESZ configuration parameter. Sections of packages in the
global SQL cache reflect the status of the database. If objects (tables, indexes, aliases,
and so forth) in the database are changed, access plans might be invalidated. If this
happens, then all sections of the invalidated access plans residing in the cache are
flushed from memory.
The benefits of package caching are:
• Maximum reuse potential
• Preparation time is bypassed
• Reuse of loaded packages
Database Member 0 -- Database TP1 -- Active -- Up 0 days 00:10:09 -- Date 12/06/2012 08:13:52
Dynamic Cache:
Current Memory Used 377694
Total Heap Size 2582528
Cache Overflow Flag 0
Number of References 18270
Number of Statement Inserts 14
Number of Statement Deletes 2
Number of Variation Inserts 6
Number of Statements 12
Package cache
Overflows
DATABASE_MEMORY
Overflow Buffer
You might want to use this information at the database level to calculate the
average package cache hit ratio for all applications. You can also look at this
information at an application level to find out the exact package cache hit ratio for
a given application. It might not be worthwhile to increase the size of the package
cache in order to satisfy the cache requirements of an application that only
executes infrequently.
The static_sql_stmts and dynamic_sql_stmts counts can be used to help provide
information on the quantity and type of sections being cached.
• Package Cache Inserts: The total number of times that a requested section was
not available for use and had to be loaded into the package cache. This count
includes any implicit prepares performed by the system. In conjunction with
Package Cache Lookups, you can calculate the package cache hit ratio using the
following formula:
1 - (Package Cache Inserts / Package Cache Lookups)
• Section Lookups: Each agent has access to a shared SQL workspace where the
working copy of any executable section is kept. This counter indicates how many
times the SQL work area was accessed by agents for an application.
• Section Inserts: The working copy of any executable section is stored in a shared
SQL workspace. This is a count of when a copy was not available and had to be
inserted.
• Package Cache High Water Mark: The largest size reached by the package
cache.
This element indicates the maximum number of bytes the package cache
required for the workload run against the database since it was activated. If the
package cache overflowed, then this element contains the largest size reached
by the package cache during the overflow. Check Package Cache Overflows to
determine if such a condition occurred.
The default value for util_heap_sz is subject to change by the Db2 Configuration
Advisor as part of database creation, which is run by default in a nonpartitioned
database environment. The Db2 Configuration Advisor sets the UTIL_HEAP_SZ
parameter to AUTOMATIC (minimum value of 5000) unless the registry variable
DB2_WORKLOAD=ANALYTICS, in which case it is set to AUTOMATIC (minimum
value of 1000000).
By default, the util_heap_sz parameter is set to AUTOMATIC. This AUTOMATIC
setting allows utilities to consider database memory overflow as part of the available
utility heap in addition to the underlying configured value. The underlying configured
value represents a reservation of database memory. When the reserved amount is fully
used, more utility heap memory is taken from database memory overflow.
When the util_heap_sz parameter is set to a fixed value, utilities do not consider
database memory overflow as part of the available utility heap. The fixed value
represents a reservation of database memory and normally guides the maximum
amount of memory that is used by utilities, but does not represent a hard limit. When
the reserved amount is fully used, more utility heap memory is taken from the database
memory overflow. Typically the reserved amount is never fully used unless the default
behavior of utilities is overridden.
Piped Sort
Overflow
Temp. Table
Non-piped Sort
(Degree 4) (Degree 2)
App 1
db2agent (Degree 1)
db2agent
db2agntp db2agntp db2agent
db2agntp
Database
db2agntp Shared sortheap sortheap sortheap sortheap
Memory
db2agntp sortheap Shared Sort Memory
sheapthres_shr (soft limit )
db2agntp
Other DB Buffer Pools
Shared Memory
Other DB
Shared Memory
• sort_overflows - the total number of sorts that ran out of sort heap and may have
required disk space for temporary storage.
• post_shrthreshold_sorts - The total number of sorts that were throttled back by
the sort memory throttling algorithm. A throttled sort is a sort that was granted
less memory than requested by the sort memory manager.
These statistics can be examined for current activities, statements in package cache,
active connections and units of work or the accumulated numbers for workloads and
service classes.
You may also want to monitor buffer pool activity for temporary table pages to see if the
accesses to the temporary tables used to perform sorts are effectively using the buffer
pool memory to avoid excessive disk reads and writes.
1 record(s) selected.
>>-db2mtrk--+-----+--+-----+--+-----+--+-----+--+-----+--------->
'- -i-' '- -d-' '- -p-' +- -m-+ '- -a-'
'- -w-'
>--+--------------------------+--+-----+--+-----+--------------><
'- -r--interval--+-------+-' '- -v-' '- -h-'
'-count-'
Example
The following call returns database and instance normal values and repeats every 10
seconds:
db2mtrk -i -d -v -r 10
5 record(s) selected.
STMM will also decide on an appropriate interval to wait for the next evaluation. A
typical STMM interval is about 60 seconds, but can be shorter or longer depending on
the stability of the workload.
Automatic Static
Sort
Package Memory Package Sort
Cache Locklist Cache Memory
Locklist
BP 1 BP 2 BP 3 BP 4 BP 1 BP 2 BP 3 BP 4
20000000
18000000
Phase 1 Phase 2 Phase 3
16000000
14000000
BP Size in pages
12000000
80 GB
10000000
8000000
6000000
4000000
2000000
0
23 :5 1
23 :3 1
23 :4 4
23 :5 5
0: 0
0: 0
0: 0
0: 0
1: 6
1: 3
2: 4
2: 2
3: 8
3: 3
3: 2
3: 9
3: 2
4: 2
4: 2
4: 2
4: 1
4: 6
5: 0
5: 8
5: 9
5: 8
5: 3
5: 8
2
:1
:0
:0
:5
:2
:1
:1
:5
:1
:2
:0
:2
:0
:1
:5
:4
:0
:1
:4
:4
:5
:4
:2
:0
:2
01
09
24
35
04
52
30
47
02
16
33
50
59
13
27
39
49
57
06
14
24
33
40
47
4
9
:2
:2
:3
:3
:4
23
Time
7000000
Second
database
6000000
stopped
5000000
Second
Memory (in 4K Pages)
4000000 database
started
3000000
2000000
1000000
0
0 10000 20000 30000 40000 50000 60000 70000
Time (in seconds)
150000
140000
130000
120000
110000
100000 300%
Transactions Per Minute
90000
80000
70000
60000
50000
40000
30000
20000
10000
1.5 hours 3.5 hours
0
22:54:42
23:07:14
23:19:44
23:32:14
23:44:44
23:57:14
0:09:44
0:22:15
0:34:45
0:47:15
0:59:45
1:12:15
1:24:45
1:37:16
1:49:46
2:02:16
2:14:48
2:27:18
2:39:49
2:52:19
3:04:49
3:17:19
3:29:49
3:42:19
3:54:50
4:07:20
4:19:50
4:32:20
4:44:50
4:57:20
5:09:50
5:22:20
5:34:51
Time
The setting of a buffer pool size or memory heap size to MANUAL implies that you want
the buffer pool or memory heap to remain at its current size and STMM tuning should
stop. This provides a convenient way to stop tuning a heap once the performance
results are acceptable.
In some cases, a SQLCODE 1363 might be returned indicating that the change could
not be accomplished and has been deferred until the next database activate. In most
cases, this is because an attempt was made to set a buffer pool or memory heap to a
larger size and that memory could not be acquired by Db2. In the case of locklist, the
code might be returned because there are too many current locks being used to reduce
the locklist to the requested size.
If all of the memory areas being tuned by STMM are set to a value or manual, then
STMM will not have additional tuning to perform.
Demonstration 1
Db2 database memory configuration
Demonstration 1:
Db2 database memory configuration
Purpose:
This demonstration will look at the utilization of database memory and the
efficiency of processing both read and write SQL workloads with different
database memory configurations. You will also look at the memory used for
data loading for row organized and column organized tables.
13 record(s) selected.
You will create two test tables using the file memtables.ddl. One table uses row
organization, while the other is column organized.
Use the two files, loadrows.ddl and loadcols.ddl to execute the LOAD utility to
process the same input. Each load process will allocate database utility heap
memory for processing the input.
1 record(s) selected.
The sample output shows about 20MB of utility heap memory was used to
process the row organized table by the LOAD command.
6. In the terminal session, issue the following command:
• db2 -tvf loadcols.ddl
The output from this command will look similar to the following:
load from hist200k.del of del messages rowload1.msg replace into MEM.COLHIST
nonrecoverable
1 record(s) selected.
Notice that the LOAD processing for the column organized table used more
than twice the memory in the utility heap. This is used by the ANALYZE phase
for loading a column organized table to build the column dictionary data.
Task 2. Run some SQL based workloads to collect various
performance metrics with different database memory
allocations.
Next you will run some SQL based workloads using the minimal memory allocations for
the buffer pools and sort memory.
The file ingestsamp.ddl uses the Db2 INGEST command to process inserts and
updates to a set of tables. This is a write intensive type of processing. The file
batch1.sql contains a set of SQL SELECT statements and db2batch utility control
statements that will be used to create a read-only workload for test purposes.
1. Enter the following commands in the Linux terminal session:
• db2 terminate
• db2 deactivate db tp1
• db2 activate db tp1
• db2 connect to tp1
• db2 -tvf ingestsamp.ddl
The output from this command will look similar to the following:
truncate table history drop storage immediate
DB20000I The SQL command completed successfully.
2. In the terminal session, issue the following command (results will take time):
• db2batch -d tp1 -f batch1.sql | more
Look at the summary report at the end of the db2batch output.
The output from this command will look similar to the following:
* Summary Table:
Type Number Repetitions Total Time (s) Min Time (s) Max Time (s)
Arithmetic Mean Geometric Mean Row(s) Fetched Row(s) Output
--------- ----------- ----------- -------------- -------------- -------------- ---
------------ -------------- -------------- -------------
Block 1 10 82.064361 7.379350 9.014193
8.206436 8.189336 1124740 250
* Total Entries: 1
* Total Time: 82.064361 seconds
* Minimum Time: 82.064361 seconds
* Maximum Time: 82.064361 seconds
* Arithmetic Mean Time: 82.064361 seconds
* Geometric Mean Time: 82.064361 seconds
---------------------------------------------
* Timestamp: Tue Apr 17 2018 08:52:54 EDT
The sample output show a total elapsed time of 82 seconds for the read-only
processing.
Use the file mon_bpios.sql to return some buffer pool read and write statistics
for the INGEST and db2batch workloads.
3. In the terminal session, issue the following command:
• db2 -tvf mon_bpios.sql
The output from this command will look similar to the following:
select substr(bp_name,1,15) as bp_name, total_physical_reads, data_physical_reads,
index_physical_reads from sysibmadm.mon_bp_utilization where bp_name not like
'IBMSYSTEM%'
2 record(s) selected.
2 record(s) selected.
The query results show physical read and write statistics for the two buffer
pools.
Use the file dbmemory.sql to show current database memory allocations.
4. In the terminal session, issue the following command:
• db2 -tvf dbmemory.sql
The output from this command will look similar to the following:
select varchar(memory_pool_type,25) as memory_pool, memory_pool_id, memory_pool_used ,
memory_pool_used_hwm from table (mon_get_memory_pool('DATABASE','TP1',-1)) as m1 order by
memory_pool_id
13 record(s) selected.
The buffer pools will remain a constant size. The shared sort memory in the
sample report used a maximum size of 4MB.
Next you will adjust the memory configuration for the two buffer pools and sort
memory and then rerun the SQL processing.
Type Number Repetitions Total Time (s) Min Time (s) Max Time (s)
Arithmetic Mean Geometric Mean Row(s) Fetched Row(s) Output
--------- ----------- ----------- -------------- -------------- -------------- ---
------------ -------------- -------------- -------------
Block 1 10 21.113119 2.009236 2.648720
2.111312 2.104445 1124740 250
* Total Entries: 1
* Total Time: 21.113119 seconds
* Minimum Time: 21.113119 seconds
* Maximum Time: 21.113119 seconds
* Arithmetic Mean Time: 21.113119 seconds
* Geometric Mean Time: 21.113119 seconds
---------------------------------------------
* Timestamp: Tue Apr 17 2018 09:09:49 EDT
The sample output show a total elapsed time of 21 seconds for the read-only
processing. The additional database memory should have reduced processing
time.
Use the file mon_bpios.sql to return some buffer pool read and write statistics
for the INGEST and db2batch workloads.
2 record(s) selected.
2 record(s) selected.
The sample report shows significant reductions in buffer pool read and write
activity to perform the same application processing.
Use the file dbmemory.sql to show current database memory allocations.
13 record(s) selected.
Use the SQL in the file dropmemtables.ddl to drop the test tables used for this
demonstration and free the allocated space.
8. In the terminal session, issue the following commands:
• db2 -tvf dropmemtables.ddl
• db2 terminate
• db2 deactivate db tp1
Results:
You used a set of SQL statements with Db2 monitor table functions and views
to monitor table space utilization, buffer pool efficiency, database log space
usage and application lock contention.
Unit summary
• Describe memory heap usage for instance memory, database shared
memory and application memory
• Explain the management of database shared memory based on setting
the configuration option DATABASE_MEMORY to AUTOMATIC or a
specific number of pages
• Select the mode for managing data sort memory using SORTHEAP,
and SHEAPTHRES_SHR
• Monitor Db2 memory usage using the db2mtrk commands and SQL
statements
• Utilize the db2pd command for monitoring current database memory
usage
• Describe how STMM can be used to automatically manage database
shared memory heaps
• Implement Db2 Self Tuning Memory Management (STMM) for all or
selected database memory heaps
Db2 Database Memory Management © Copyright IBM Corporation 2018
Unit summary
Unit objectives
• Review the considerations of using standard Db2 database recovery
options
• Explain the capabilities of the REBUILD option for the RESTORE
command
• List the types of information included in each Db2 backup image and
describe how it is used to support rebuilding a database
• Plan for supporting database and disaster recovery scenarios using
Db2 database and table space backups using the RESTORE
command with a REBUILD option
• Utilize LIST UTILITIES SHOW DETAIL to monitor progress of a
RESTORE utility during database rebuilding
Unit objectives
In order to recover a database completely to the most current transactions, all Db2
system logs from the time stamp of the database backup image forward to the most
current log file would be needed. In order to maintain database recoverability, regular
database level backups would need to be scheduled.
Partial Database Restore for testing or other special recovery needs
There are several recovery scenarios where it might be useful to recover a subset of
a Db2 database:
• Dropped Table Space: Once a table space is dropped, it cannot be restored
using a table space level restore. Prior to the RESTORE REBUILD option, the
only way to recover the table space would be to restore the entire database to a
point in time prior to the beginning of the transaction that dropped the table
space.
• Dropped Tables: Db2 has a dropped table recovery facility, but the process only
handles a single dropped table. If many tables are dropped by mistake a table
space level point in time recovery cannot be used to regain access to the data. A
database level recovery to a point in time can be used to recover the dropped
tables, but without a REBUILD option the recovery could be a lengthy process for
a large database.
• Application Recovery to a PIT before the current table space Minimum
Recovery time: Create, Alter, and Drop SQL statements change the minimum
recovery time stamp for the table spaces effected by the DDL. This insures that a
table space must be recovered to a point in time that keeps catalog definitions in
synch with the table space objects. There might be cases where an application
causes table changes in error and a point in time recovery for several table
spaces might be needed but more recent applications might have updated the
minimum recovery times for one or more table spaces past the point where
recovery is needed. In this case, a point in time recovery at the database level
must be used to get the table spaces back to the time stamp needed to correct
the data problems. Without the REBUILD option of the Db2 RESTORE utility, all
of the table spaces in the database would be recovered to the same time stamp.
AUTOTS1 SalesDB
SalesDB
SYSCATSPACE SYSCATSPACE
DMS02
Backup
Database Backup Backup Backup
Copy for
SALESDB TS DMS01 TS DMS02 TS DMS01 testing
SUN MON TUE WED THU FRI SAT
>>-RESTORE--+-DATABASE-+--source-database-alias------------>
+-REBUILD WITH--+-+-ALL TABLESPACES IN DATABASE-+--+---------+-+-+ |
'-ALL TABLESPACES IN IMAGE----‘ '-EXCEPT—
+-TABLESPACE--+--- (----tablespace-name-+--)-'
• List of all table spaces in database at time of backup: This includes the table
space and container information for every table space in the database at the time
of the backup. This is used for the ALL TABLESPACES IN DATABASE option to
establish a complete list for REBUILD, even though the target image might be a
table space backup.
• Database Configuration (DB CFG): The database configuration settings at the
time the backup was created are saved in the backup image. If a new database is
being created by the restore command or if an existing database with a different
database seed is being overlaid, this will be used to set the new database
configuration. If the restore is going to overlay a database with the same seed,
the current database configuration will be retained.
DMS01 DMS02
2
3 1
Backup Database
Database Backup Backup Backup
SALESDB TS DMS01 TS DMS02 TS DMS01 Fails!
SUN MON TUE WED THU FRI SAT
1. RESTORE DB SALESDB
REBUILD WITH ALL TABLESPACES IN DATABASE TAKEN AT Friday
(Db2 Restores Friday, Sunday and Thursday)
Recovery
SYSCATSPACE SalesDB History File
DMS01 DMS02
2 3 1
Backup
Backup
Backup
Database
TS AUTOTS1
TS DMS02
SYSCATSPACE
TS DMS02 Backup Fails !
DMS01 DMS01 TS DMS01
1. RESTORE DB SALESDB
REBUILD WITH ALL TABLESPACES IN DATABASE TAKEN AT Friday
(Db2 Restores Friday, Tuesday and Thursday)
Using the target backup image, the data for the table space DMS01 would be
restored. The recovery history file would be scanned to locate the most recent
backup image for each of the other table spaces.
The table spaces SYSCATSPACE and AUTOTS1 would be automatically
restored using the table space backup image from Tuesday. Next the table
space DMS02 would be restored automatically using the table space backup
from Thursday.
Now that all of the table spaces have been restored from some backup, the
Restore Utility is considered complete.
2. Again, a single database rollforward can be used to apply the logged changes
from Tuesday to Friday for ALL table spaces. Having the table space backup
of SYSCATSPACE and AUTOTS1 from Tuesday would reduce the number of
logs needed compared to the previous example.
ROLLFORWARD DB SALESDB TO END OF LOGS AND STOP
When the command completes, all table spaces will be available for
application access.
So a complete database recovery has been performed using a single RESTORE
command and no database level backup image was used.
SYSCATSPACE SYSCATSPACE
2
1
Copy for
Backup testing
Database Backup Backup Backup
SALESDB TS DMS01 TS DMS02 TS DMS01
The Restore utility would use the supplied list of table spaces provided in the
command to rebuild the database. SYSCATSPACE must always be included
for a partial database rebuild.
Using the target backup image, the data for the table space DMS01 would be
restored. The recovery history file would be scanned to locate the most recent
backup image for the SYSCATSPACE.
The table space SYSCATSPACE would be automatically restored using the
database backup image taken on Sunday.
Now that all of the table spaces requested have been restored from some
backup, the Restore utility is considered complete. The table spaces SMS01
and DMS02 are in a restore pending status and the containers for those table
spaces have not been allocated.
2. A single database rollforward can be used to apply the logged changes from
Sunday to Friday for the SYSCATSPACE table space. The rollforward would
only need to apply changes to DMS01 from Friday forward.
ROLLFORWARD DB SALESDB TO END OF LOGS AND STOP
When the command completes, the table spaces SYSCATSPACE and DMS01
will be available for application access.
This is a much simpler sequence of commands than those needed to perform a
similar recovery without the REBUILD option. The time required to restore and apply
the logs to the table spaces that are not required has been eliminated and the disk
space required might be significantly reduced as well.
SYSCATSPACE
Backup AUTOTS1
TS DMS01
SalesDB SalesDB
SYSCATSPACE
SYSCATSPACE
Backup Backup
Database Backup Backup TS DMS01
Copy for
SALESDB TS DMS01 TS DMS02 SYSCATSPACE testing
SUN MON TUE WED THU FRI SAT
Using the target backup image the data for both table spaces DMS01 and
SYSCATSPACE would be restored. No additional automatic restores would be
necessary.
Now that the table spaces requested have been restored using the single
backup image, the Restore Utility is considered complete. The table spaces
AUTOTS1 and DMS02 would actually be listed in a query result using
MON_GET_TABLESPACE but they would be in a restore pending status and
the containers for those table spaces have not been allocated.
2. A database rollforward would be used to apply the logged changes starting on
Friday for the two table spaces, SYSCATSPACE and DMS01. Changes to the
other table spaces would be ignored.
ROLLFORWARD DB SALESDB TO END OF LOGS AND STOP
When the command completes, the table spaces SYSCATSPACE and DMS01
will be available for application access.
This technique would have two advantages:
1. The restore would take less time because only a single table space backup
needs to be restored. In the previous example, SYSCATSPACE was restored
by reading a full database backup image that might be very large.
2. The rollforward processing would be minimal, because only log files starting at
the time stamp of the table space backup on Friday would need to be
processed.
SalesDB SalesDB
SYSCATSPACE SYSCATSPACE
2 1
Database is now available, AUTOTS1 AND DMS02, are in DROP PENDING status
If an application test needs a database copy of SALESDB, but only needs tables in
the table space DMS01, a partial database rebuild can be performed using the
existing Db2 incremental backup images. The database for testing will be restored
on Friday evening. A Restore command with the rebuild option will be used. The
steps would be:
1. Issue a single Restore command with the REBUILD option using a target of
the incremental database backup taken on Thursday. The command will
include options to specify that the database should only include the table
spaces SYSCATSPACE and DMS01.
The following command could be used:
RESTORE DB SALESDB REBUILD WITH ALL TABLESPACES IN
DATABASE EXCEPT TABLESPACE(AUTOTS1,DMS02) TAKEN AT
Thursday
The Restore utility would read the target backup image and find that it was an
Incremental database backup. Db2 would perform an automatic incremental
restore process. This would scan the recovery history to locate the necessary
backup images, which in this case would include the full database backup
taken on Sunday. The two backup images would be restored to bring the
database up to the point of the offline backup from Thursday, but only copy the
data from the selected table spaces, SYSCATSPACE and DMS01 to disk.
Now that the table spaces requested have been restored, the Restore utility is
considered complete. No rollforward is possible for a nonrecoverable
database, so the database is now available for access.
The table spaces AUTOTS1 and DMS02 would be listed in a query result
using the MON_GET_TABLESPACE function, but they would be in a drop
pending status and the containers for those table spaces have not been
allocated. Since nonrecoverable databases do not allow table space level
restores, there is no way to restore AUTOTS1 or DMS02. The DROP
TABLESPACE statement can be used to remove the table spaces from this
database copy. Having table spaces in drop pending status would not prevent
testing using tables in the DMS01 table space.
1. RESTORE DB SALESDB
REBUILD WITH TABLESPACE(SYSCATSPACE,DMS01) TAKEN AT Tuesday
(Db2 Restores Tuesday, and Sunday (just SYSCATSPACE TS)
In the example shown, an application error caused the tables in DMS01 to contain
invalid data some time on Tuesday. There is a need to get a copy of the
application's tables from the time just before the application started processing on
Tuesday. Applications have altered the objects in the DMS01 table space since
Tuesday so its current minimum recovery time is a timestamp with a date of Friday.
A Restore command with the rebuild option will be used. The steps would be:
1. Issue the Restore command with the REBUILD option using a target of a table
space backup of DMS01 taken on Tuesday, some time before the application
began processing. The command will include options to specify that the
database should only include the table spaces SYSCATSPACE and DMS01.
The following command could be used:
RESTORE DB SALESDB REBUILD WITH
TABLESPACE(SYSCATSPACE,DMS01) TAKEN AT Tuesday
Using the target backup image the data for the DMS01 table space would be
restored. The recovery history records would be used to locate the database
backup image taken on Sunday as the source for restoring the
SYSCATSPACE table space, which would be also be restored.
Now that the table spaces requested have been restored the Restore Utility is
considered complete. The table spaces AUTOTS1 and DMS02 would be listed
in a query result using MON_GET_TABESPACE, but they would be in a
restore pending status and the containers for those table spaces have not
been allocated.
2. A database roll forward would be used to apply the logged changes to the
SYSCATSPACE and DMS01 table spaces as needed up to a specified time
stamp. Changes to the other table spaces would be ignored. The point in time
specified would need to be at least to the end of the target backup image
specified in the RESTORE command.
ROLLFORWARD DB SALESDB TO Tuesday AND STOP
When the command completes, the table spaces SYSCATSPACE and DMS01
will be available for application access in the rebuilt database.
• When the processing for the RESTORE command with the REBUILD option
completes, the database is considered to be in a special Rebuild Phase. This
means that additional manual restores could be performed prior to starting the
rollforward. These might be necessary if one or more backup images could not be
located based on information in the recovery history. As long as the backup
images were from time stamps prior to the time stamp of the target backup, the
table spaces could still be recovered using a single database rollforward
command. If any of the manual backups had a time stamp greater than the target
time stamp, these table spaces would not be processed during the database
rollforward, but could be recovered using a table space level rollforward.
• Once the database rollforward command is issued, the Rebuild Phase is
considered complete. Any subsequent table space restores would require a table
space rollforward for recovery.
The target image can be an Incremental or Delta backup image. Db2 might restore
other incremental or delta backup images found in the recovery history file
automatically if they are the most recent copy of one of the required table spaces.
This will help to reduce rollforward processing. It is not necessary to include the
INCREMENTAL AUTOMATIC option on the RESTORE command if the target image
is an incremental or delta backup. If the INCREMENTAL option is specified without
AUTO or AUTOMATIC, it is assumed that a manual incremental restore is desired
for some reason. Since this might add considerable complexity, this is not
recommended.
The table space for the Db2 system catalogs, SYSCATSPACE table space must
always be included for partial database rebuilding.
When the RESTORE utility is used to rebuild a partial database, the database will
have a table space list equal to the table spaces contained in the database at the
time of the target backup image. Any table spaces excluded during the rebuilding of
the database will be in a Restore Pending status. These table spaces could be
restored once the database is available using online table space restores. If there is
not a need for the table spaces in the rebuilt copy of the database, those table
spaces could be dropped. If the database rebuild was done using a non-recoverable
database, the excluded table spaces will be left in a Drop Pending status and the
only option is to drop the table spaces. A database backup of the new database
cannot be made with any table space in a Restore Pending or Drop pending status.
A Db2 database that uses the Database Partitioning option DPF can also be
partially or fully rebuilt using the REBUILD option. In this case, there would be one
Restore Utility per database partition with the REBUILD option to get the database
to the point where the database rollforward processing could begin. Any partial
database rebuild would require the SYSCATSPACE table space to be included
when the catalog partition is rebuilt. Non-catalog partitions do not have the
SYSCATSPACE table space. There is one recovery history file for each database
partition, so the rebuild processing at each partition would be based on its recovery
history contents.
The RESTORE command with a REBUILD option can also include the REDIRECT
option to modify some or all of the container definitions in the rebuilt database. The
SET TABLESPACE CONTAINERS commands would only need to be run to assign
valid containers for the table spaces that will be included in a partial database
rebuild. The table space list for the database would be those table spaces that
existed at the time of the 'target' backup image. Any automatic storage table spaces
included would be automatically assigned new containers unless the table space
was excluded. For Automatic Storage group managed table spaces, SET
STOGROUP PATHS statements can adjust disk paths for automatic storage
containers.
A RESTORE command with the REDIRECT GENERATE SCRIPT option can be
used to create a file that would have a complete set of SET TABLESPACE
CONTAINERS commands, which can be easily edited to make sure all required
table spaces have valid containers.
-------------------------------------------------------------------
---------
Comment: RESTORE TP1 WITH RF
Start Time: 20060803144554
End Time: 20060803144604
Status: A
--------------------------------------------------------------
--------------
There will also be one record written that lists all of the table spaces restored during
the rebuilding of the database.
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log
Backup ID
-- --- ------------------ ---- --- ------------ ------------ ------
--------
R D 20060803144424 R S0000171.LOG S0000184.LOG
20060803143742
-------------------------------------------------------------------
---------
Contains 6 tablespace(s):
00001 TP1ACCTI
00002 TP1ACCTD
00003 TP1HIST
00004 TP1SMS
00005 USERSPACE1
00006 SYSCATSPACE
-------------------------------------------------------------------
---------
Comment: REBUILD TP1 WITH RF
Start Time: 20060803144424
End Time: 20060803144605
Status: A
-------------------------------------------------------------------
---------
Demonstration 1
Rebuilding a database
Demonstration 1:
Rebuilding a database
Purpose:
This demonstration will show you how to restore a database using a series of
table space level backup images. You will use the Db2 command line
processor to run BACKUP, RESTORE, and ROLLFORWARD commands that
initially recover a subset of a Db2 database. The remaining table space is later
recovered using a table space level restore.
8 record(s) selected.
First, you will create a table space backup of the catalog table space,
SYSCATSPACE, the default user table space, USERSPACE1 and the system
utility table space SYSTOOLSPACE. Use the $HOME/backups/u4 directory for
this backup.
4. In the terminal session, issue the following command:
• db2 " backup db tp1
tablespace(syscatspace,userspace1,systoolspace) online to
$HOME/backups/u4 compress "
Record the date and time stamp returned by the Backup utility.
Run the command file newtab.ddl to create a new table named histcopy in the
USERSPACE1 table space and load some rows using INGEST. This will add a
new object, a table named histcopy, to the USERSPACE1 table space and
update the catalog tables in the SYSCATSPACE table space.
HISTCOPY_ROW_COUNT
------------------
200000
1 record(s) selected.
Next create a backup for the table spaces that hold the ACCT table,
TP1ACCTD and TP1ACCTI. Also include the table space TP1SMALL that
holds the BRANCH and TELLER tables. Use the $HOME/backups/u4 directory
for this backup.
6. In the terminal session, issue the following command:
• db2 " backup db tp1 tablespace(tp1acctd,tp1accti,tp1small) online to
$HOME/backups/u4 compress "
Record the date and time stamp returned by the Backup utility.
Next, you will use the command file ingestsamp.ddl to perform updates to the
ACCT, BRANCH, and TELLER tables using a set of transactions with the
INGEST utility.
8 record(s) selected.
The RESTORE utility progress can be monitored using the LIST UTILITIES
command. A second terminal session will be needed to run the command while
the RESTORE UTILITY is processing.
Start a second terminal session and run the following command once. No
output is expected since there are no active utilities.
2. Open a second terminal session, and issue the following command:
• db2 list utilities show detail
The last table space backup image will be used as the target for the database
rebuild function of the RESTORE utility. The file lastbackupid.sql can be used
to list the most recent backup, using the SYSIBMADM.DB_HISTORY view. The
table space, USERSPACE1, will be excluded from the REBUILD operation to
demonstrate the option to restore a subset of the table spaces for a database.
The database will need to be deactivated before the RESTORE utility can be
started.
3. In the first terminal session, issue the following commands:
• db2 connect to tp1
• db2 -tvf lastbackupid.sql
The output from this command will look similar to the following:
select start_time as backup_taken_at ,
substr(location,1,40) as backup_location , substr(tbspnames,1,80) as
table_spaces_in_backup
from sysibmadm.db_history
where operation = 'B' order by start_time desc fetch first 1 row only
1 record(s) selected.
While the restore command is processing, switch to the other terminal session
and run the LIST UTILITIES command several times until you get information
returned.
4. In the second terminal session, issue the following command:
• db2 list utilities show detail
NOTE: If the restore has already been completed before you have entered the
db2 list utilities show detail command, you will not be able to see the following
output.
The output from this command will look similar to the following:
inst464@ibmclass:~/Desktop> db2 list utilities show detail
ID = 20
Type = RESTORE
Database Name = TP1
Member Number = 0
Description = automatic db rebuild USERSPACE1...
Start Time = 10/31/2016 15:35:58.004647
State = Executing
Invocation Type = User
Progress Monitoring:
Phase Number = 1
Total Work = 66109440 bytes
Completed Work = 66109440 bytes
Start Time = 10/31/2016 15:35:58.004652
Phase Number = 3
Description = 20161031150242
Completed Work = 0 bytes
Start Time = Not Started
Notice that the descriptions show the backup timestamps for the backup images
that were selected by Db2 for the database rebuild.
The database TP1 is now in a rollforward pending status. Issue a rollforward
command to apply all of the logged changes to the TP1 database and allow
applications to gain access to the restored database.
7 record(s) selected.
Notice that no containers are listed for the USERSPACE1 table space, so no
disk space is currently allocated.
Use the LIST HISTORY command to show the records generated by the
rebuilding of the database by the previous RESTORE command. The records
will be at the end of the report with a operation type (Op) of R.
00001 TP1SMALL
00002 TP1HIST
----------------------------------------------------------------------------
Comment: RESTORE TP1 WITH RF
Start Time: 20170824124856
End Time: 20170824124903
Status: A
----------------------------------------------------------------------------
EID: 24 Location:
00001 SYSTOOLSPACE
00002 SYSCATSPACE
----------------------------------------------------------------------------
Comment: RESTORE TP1 WITH RF
Start Time: 20170824124903
End Time: 20170824124907
Status: A
----------------------------------------------------------------------------
EID: 25 Location:
00001 TP1ACCTI
00002 TP1ACCTD
----------------------------------------------------------------------------
Comment: RESTORE TP1 WITH RF
Start Time: 20170824124907
End Time: 20170824124908
Status: A
----------------------------------------------------------------------------
EID: 26 Location:
00001 SYSTOOLSPACE
00002 TP1ACCTI
00003 TP1ACCTD
00004 TP1HIST
00005 TP1SMALL
00006 SYSCATSPACE
----------------------------------------------------------------------------
Comment: REBUILD TP1 WITH RF
Start Time: 20170824124856
End Time: 20170824124908
Status: A
----------------------------------------------------------------------------
EID: 27 Location:
There are four records at the end in the LIST HISTORY report that were
generated by the single RESTORE command with the REBUILD option. The
records all have R for restore in the Op column.
• The first record has an Obj type of D for database. This shows the two table
spaces, TP1SMALL and TP1HIST, being restored from the target backup
image.
• The next record has an Obj type of P for table space. This shows the
SYSCATSPACE and SYSTOOLSPACE table spaces being restored. Notice
that the table space USERSPACE1, which was included in that backup
image, was not restored.
• The next record also has an Obj type of P for table space. This shows the
TP1ACCTI and TP1ACCTD table spaces being restored. The backup image
selected was the most recent table space backup.
• The next record also has an Obj type of D for database, with an R in the
Type column, indicating a Database Rebuild type of restore. This shows all
of the table space names were included during the database rebuild. The
USERSPACE1 table space was not included.
Task 3. Complete the database recovery by restoring the
excluded table space, USERSPACE1.
The table space, USERSPACE1, was excluded during the database rebuild operation.
We could drop the table space now if the data is no longer needed. This might be done
if the rebuilt TP1 database was being used to test with a subset of the tables. The table
space, USERSPACE1, is currently in a Restore Pending status.
Use the RESTORE utility to recover the table space USERSPACE1 from the backup
image created in Task 1, Step 4. The SQL query in the file checktspu.sql can be used
to display the current table space status of USERSPACE1.
1. In the terminal session, issue the following commands:
• db2 connect to tp1
• db2 -tvf checktspu.sql
The output from this command will look similar to the following:
select substr(tbsp_name,1,14) as tbsp_name, tbsp_id,
substr(tbsp_state,1,40) as tbsp_state
from table( MON_GET_TABLESPACE('USERSPACE1',-2)) as montbsp
1 record(s) selected.
2. In the terminal session, issue the following command:
• db2 " restore database tp1 tablespace(userspace1) online from
$HOME/backups/u4 taken at timestamp "
(Use the timestamp recorded in Section 1, Step 4)
3. In the terminal session, issue the following commands:
• db2 connect to tp1
• db2 -tvf checktspu.sql
The output from this command will look similar to the following:
select substr(tbsp_name,1,14) as tbsp_name, tbsp_id,
substr(tbsp_state,1,40) as tbsp_state
from table( MON_GET_TABLESPACE('USERSPACE1',-2)) as montbsp
1 record(s) selected.
Now complete the recovery by applying the logged changes to the
USERSPACE1 table space using a ROLLFORWARD command. Make sure
that all table spaces in the database are in a normal status.
8 record(s) selected.
You can now drop the table HISTCOPY that was created at the beginning of
this demonstration.
5. In the terminal session, issue the following commands:
• db2 connect to tp1
• db2 drop table histcopy
6. Close both terminal windows and then logout of the Linux operating system.
Results:
You created a series of table space level backups and used them to rebuild a
database copy with one table space excluded. You were able to recover the
excluded table space using a table space level restore.
Unit summary
• Review the considerations of using standard Db2 database recovery
options
• Explain the capabilities of the REBUILD option for the RESTORE
command
• List the types of information included in each Db2 backup image and
describe how it is used to support rebuilding a database
• Plan for supporting database and disaster recovery scenarios using
Db2 database and table space backups using the RESTORE
command with a REBUILD option
• Utilize LIST UTILITIES SHOW DETAIL to monitor progress of a
RESTORE utility during database rebuilding
Unit summary
Unit objectives
• Explain the facility of the Db2 RESTORE command to recover table
spaces to different containers
• Use the SET TABLESPACE CONTAINERS command to define new
containers during a redirected restore
• Utilize the SET STOGROUP PATHS command to change the storage
paths for automatic storage tablespaces in storage groups
• Plan the use of redirected restore as part of a disaster recovery
• Describe two methods that can be used to convert a DMS table space to
utilize Automatic Storage
• Use the GENERATE SCRIPT option of RESTORE to set up a command
script for a redirected restore operation
• Copy schemas from one database to another using the TRANSPORT
option of the RESTORE utility
• Use db2relocatedb when moving or copying Db2 databases with non-Db2
utilities
Db2 database and tablespace relocation © Copyright IBM Corporation 2018
Unit objectives
Db2 Backup
Next is the data from the table spaces that were backed up.
At the end of the backup image is another control file, the Log File Header, or log
control files. It is used to place this backup in the sequence of database log files, and it
is used to set the starting point in the logs where a roll forward process must begin.
ID: 4
.................................
Container CB
Type: 6
TotalPages: 5000
UsablePages: 4992
# of OS rsvd bytes: 512
Page 0 offset: 131072
Tag offset: 512
Extent offset: 0
Name: /database/inst481/tp1hist
.................................
TP1ACCTD
tbspInImage: F
ID: 5
.................................
Container CB
Type: 6
TotalPages: 30000
UsablePages: 29888
# of OS rsvd bytes: 512
Page 0 offset: 262144
Tag offset: 512
Extent offset: 0
Name: /database/inst481/tp1acctd
.................................
IBMSTOGROUP IBMSTOGROUP
SYSCATSPACE
SYSCATSPACE
TEMPSPACE1
TEMPSPACE1
DB2
Db2 Database Db2 Database
TP1HIST TP1HIST
X
/DBfs1/cont1 /DBfs2/cont2
/DBfs2/cont2 /DBfs1/cont1
file file
file file
APSTOGRP1 APSTOGRP1
Table space
Table space TSAP1
TSAP1
Containers
Containers TSAP2
TSAP2
SYSCATSPACE
(file '/database/inst491/testhist2' 5000)
Db2 Database
TS id = 0
TEMPSPACE1
3) restore database tp1
TS id =1
continue
USERSPACE1 TP1HIST TS id =4
TS id =2
APSTOGRP1
DAMAGED
Tablespace ID = 0
Name = SYSCATSPACE
Type = Database managed space
Contents = All permanent data. Regular table space.
State = 0x0000
Detailed explanation:
Normal
. . . . . .
Tablespace ID = 4
Name = TP1HIST
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x2003100
Detailed explanation:
Restore pending
Storage must be defined
Restore in progress
Storage may be defined
Container ID = 0
Name = /database/inst491/testhist
Type = File
Total pages = 5000
Useable pages = 4928
Accessible = Yes
Member ID = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = -
Last committed transaction = 2016-05-15-13.57.30.000000 UTC
The example output includes SET STOGROUP PATHS statements for any automatic
storage groups in the database at the time of the backup.
These statements are marked as comments. The SET STOGROUP PATHS could only
be utilized if you perform a database level redirected restore.
The example output shows some of the information provided in comments for a table
space, including, the total number of pages, the high water mark and whether the table
space is managed by automatic storage.
Automatic Storage table space containers cannot be changed during a redirected
restore using the SET TABLESPACE CONTAINERS commands.
SYSCATSPACE
/DBfs1/cont1 /DBfs2/cont2 TEMPSPACE1
file file
/DBfs2/cont1
APSTOGRP1
file
APSTOGRP1 TSAP1
TSAP1
TSAP2
TSAP2
• Next, the ALTER TABLESPACE STATEMENT with the REBALANCE option can
be used to rearrange the extents in a way that releases the original non-
Automatic Storage containers. For example:
ALTER TABLESPCE TSP12 REBALANCE
DMS-managed table spaces can be converted to Automatic Storage management
using a a database or table space redirected restore. The SET TABLESPACE
CONTAINERS statement specifies USING AUTOMATIC STORAGE rather than listing
user assigned containers. The table space will be assigned to the default storage group
for the database.
SET TABLESPACE CONTAINERS FOR 6 USING AUTOMATIC STORAGE
There is no supported method to convert an Automatic Storage managed table space
to DMS management.
DMS01 DMS01
DMS01
X X
/DBfs1/cont1 /DBfs1/cont1
/DBfs1/cont1
file file
file
/DBfs1/cont2 /DBfs1/cont2
file file
X
S0000021.log S0000022.log S0000023.log S0000024.log
/DBfs1/cont1
3) restore database tp1 continue
file /DBfs2/cont1
4) rollforward database tp1
/DBfs1/cont2 file
to end of logs
file tablespace(dms01) online
Db2 database and tablespace relocation © Copyright IBM Corporation 2018
Since a table space container was added after the last backup image was created, the
roll forward process would normally redo the container definition. The loss of access to
the disk with both containers would prevent the roll forward from completing
successfully.
The SET CONTAINERS command has an option that will direct Db2 to either REPLAY
or IGNORE the container changes during the roll forward process. This option would
apply to the single table space defined in the command, new containers could still be
added to other table spaces during the roll forward.
In the example, the IGNORE ROLLFORWARD CONTAINER OPERATIONS option is
used to define a single container to be used for the restore and roll forward processing
and to bypass the container addition that was logged. This allows the redirected restore
process to complete recovery of the table space including all of the current log files.
The command syntax is:
>>-SET TABLESPACE CONTAINERS FOR--tablespace-id------->
>-----+----------------------------------------+------>
| .-REPLAY--. |
'--+-IGNORE--+---ROLLFORWARD CONTAINER OPERATIONS--'
• View hierarchies
• Object privileges (All new objects are created with default authorizations)
• Statistics (New objects do not contain statistics information)
• Index extensions (user-defined structured type related)
• User-defined structured types and their transform functions
Copying schemas of objects from one database to another using RESTORE with
TRANSPORT
Table spaces and SQL schemas can be restored as a set from one database to
another using transportable sets.
By using the RESTORE command with the TRANSPORT option, you can restore data
in a set of table spaces from a backup image into another existing database. You can
re-create database objects in the SQL schemas that reference the data in the restored
table spaces. The restored table spaces and SQL schemas can function as part of the
new database.
The objects being transported cannot duplicate any existing database objects in the
target database.
The list of table spaces must be specified in a TABLESPACE option when using the
TRANSPORT option. You must also list the schemas using the SCHEMA option.
Transporting a database schema involves taking a backup image of a database and
restoring the database schema to a different, existing database. When you transport a
database schema, the database objects in the transported schema are re-created to
reference the new database, and the data is restored to the new database.
Transportable sets
Following combinations of table spaces and schemas are valid transportable sets:
• Tablespace1 with schema1 and schema2
• Tablespace2 and tablespace3 with schema3
• Tablespace4, tablespace5, and tablespace6, with schema4 and schema5
• Combination of valid transportable sets also constitutes a valid transportable set:
tablespace1, tablespace2, and tablespace3, with schema1, schema2, schema3
Transportable sets
A database schema must be transported in its entirety. If a table space contains both
the schema you want to transport, as well as another schema, you must transport all
data objects from both schemas. These sets of schemas that have no references to
other database schemas are called transportable sets. The data in the table spaces
and logical objects in the schemas in a transportable set reference only table spaces
and schemas in the transportable set. For example, tables have table dependencies
only on other tables in the transportable set.
The example shows the mapping of table spaces to database objects in different
schemas.
The following combinations of table spaces and schemas are valid transportable sets:
• tablespace1 with schema1 and schema2
• tablespace2 and tablespace3 with schema3
• tablespace4, tablespace5, and tablespace6, with schema4 and schema5
AP1) SCHEMA(AP1,AP2)
TRANSPORT into TEST
TSAP2 TSAP3 TSAP4
FROM ... REDIRECT
(schema
AP2) db2 set tablespace containers
for 4 using ……
Production Site db2 set tablespace containers
for 5 using ……
db2relocatedb command
After copying the files,
use db2relocatedb to: Instance inst1
1. Change database name Automatic Storage
2. Change database path Path(s) DB Directory
DB_NAME=oldName,newName
DB_PATH=oldPath,newPath
INSTANCE=oldInst,newInst
NODENUM=nodeNumber
LOG_DIR=oldDirPath,newDirPath
CONT_PATH=oldContPath1,newContPath1
CONT_PATH=oldContPath2,newContPath2
STORAGE_PATH=oldStorPath1,newStorPath1
Db2 database and tablespace relocation © Copyright IBM Corporation 2018
db2relocatedb command
Each Db2 database has a set of control files that identify the name of the database, the
instance name, the names of all table space containers, the automatic storage paths
and the various logging related paths. The Db2 RESTORE utility makes changes to
some of these files automatically. The db2relocatedb command can be used to update
this information when part of a Db2 database is relocated outside Db2's control.
This command renames a database, or relocates a database or part of a database (for
example, the container and the log directory) as specified in the configuration file
provided by the user. This tool makes the necessary changes to the Db2 instance and
database support files.
The target database must be offline before running the db2relocatedb command to
modify the control files and metadata of the target database.
The changes that the db2relocatedb command makes to files and control structures of
a database are not logged and are therefore not recoverable. A good practice is to
make a full backup after running the command against a database, especially if the
database is recoverable with log files being retained.
Authorization
None.
Command Syntax
db2relocatedb -f configFilename
Command Parameters
-f configFilename
Specifies the name of the file containing configuration information necessary for
relocating the database. This can be a relative or absolute filename. The format of the
configuration file is:
DB_NAME=oldName,newName
DB_PATH=oldPath,newPath
INSTANCE=oldInst,newInst
NODENUM=nodeNumber
LOG_DIR=oldDirPath,newDirPath
CONT_PATH=oldContPath1,newContPath1
CONT_PATH=oldContPath2,newContPath2
…
STORAGE_PATH=oldStoragePath1,newStoragePath1
STORAGE_PATH=oldStoragePath2,newStoragePath2
…
FAILARCHIVE_PATH=newDirPath
LOGARCHMETH1=newDirPath
LOGARCHMETH2=newDirPath
MIRRORLOG_PATH=newDirPath
OVERFLOWLOG_PATH=newDirPath
Where:
• DB_NAME Specifies the name of the database being relocated. If the database
name is being changed, both the old name and the new name must be specified.
This is a required field.
• DB_PATH Specifies the path of the database being relocated. This is the path
where the database was originally created. If the database path is changing, both
the old path and new path must be specified. This is a required field.
• INSTANCE Specifies the instance where the database exists. If the database is
being moved to a new instance, both the old instance and new instance must be
specified. This is a required field.
• NODENUM Specifies the node number for the database node being changed.
The default is 0.
• LOG_DIR Specifies a change in the location of the log path. If the log path is
being changed, then both the old path and new path must be specified. This
specification is optional if the log path resides under the database path, in which
case the path is updated automatically.
• CONT_PATH Specifies a change in the location of table space containers. Both
the old and new container path must be specified. Multiple CONT_PATH lines
can be provided if there are multiple container path changes to be made. This
specification is optional if the container paths reside under the database path, in
which case the paths are updated automatically. If you are making changes to
more than one container where the same old path is being replaced by a
common new path, a single CONT_PATH entry can be used. In such a case, an
asterisk (*) could be used both in the old and new paths as a wildcard.
• STORAGE_PATH Specifies a change in the location of one of the storage paths
for the database. Both the old storage path and the new storage path must be
specified. Multiple STORAGE_PATH lines can be given if there are several
storage path changes to be made. You can specify this parameter to modify any
storage path in all storage groups. However, you cannot specify this parameter to
modify the storage paths for an individual storage group.
• FAILARCHIVE_PATH Specifies a new location to archive log files if the
database manager fails to archive the log files to either the primary or the
secondary archive locations. You should only specify this field if the database
being relocated has the failarchpath configuration parameter set.
• LOGARCHMETH1 Specifies a new primary archive location. You should only
specify this field if the database being relocated has the logarchmeth1
configuration parameter set.
• LOGARCHMETH2 Specifies a new secondary archive location. You should only
specify this field if the database being relocated has the logarchmeth2
configuration parameter set.
• MIRRORLOG_PATH Specifies a new location for the mirror log path. The string
must point to a path name, and it must be a fully qualified path name, not a
relative path name. You should only specify this field if the database being
relocated has the mirrorlogpath configuration parameter set.
• OVERFLOWLOG_PATH Specifies a new location to find log files required for a
rollforward operation, to store active log files retrieved from the archive, and to
find and store log files required by the db2ReadLog API. You should only specify
this field if the database being relocated has the overflowlogpath configuration
parameter set.
Usage Notes:
If the instance that a database belongs to is changing, the following must be done
before running this command to ensure that changes to the instance and database
support files are made:
• If a database is being moved to another instance, create the new instance. The
new instance must be at the same release level as the instance where the
database currently resides.
• If the new instance has a different owner than the current instance, grant access
to the new instance owner.
• Copy the files and devices belonging to the databases being copied onto the
system where the new instance resides. The path names must be changed as
necessary. However, if there are already databases in the directory where the
database files are moved to, you can mistakenly overwrite the existing sqldbdir
file, thereby removing the references to the existing databases. In this scenario,
the db2relocatedb utility cannot be used. Instead of db2relocatedb, an alternative
is a redirected restore operation.
• Change the permission of the files/devices that were copied so that they are
owned by the instance owner.
When moving a database from a database path where more than one database
resides, the sqldbdir directory within that database path must be copied and not
moved. This directory is still needed in the old location for Db2 to locate the
databases that are not moving. After copying the sqldbdir directory to the new
location, a LIST DB DIRECTORY ON newPath command lists databases that were
not moved. These references cannot be removed and new databases with those
names cannot be created on this same path. However, databases can be created
with those names on a different path.
The db2relocatedb command cannot be used to move existing user created
containers for a table space that was converted to use automatic storage using the
ALTER TABLESPACE MANAGED BY AUTOMATIC STORAGE statement.
If the instance is changing, the command must be run by the new instance owner.
/dbauto/path1/inst1/NODE0000/PROD/T0000000/C0000000.CAT
SYSCATSPACE
Db2 Database
/dbauto/path1/inst1/NODE0000/PROD/T0000001/C0000000.TMP
PROD TEMPSPACE1
/dbvol2/DB1/dms01
Table space Table space /dbvol3/DB1/dms1a
DMS01 DMS01
/dbtest/TEST/logs APSTOGRP1
Active Logs
IBMSTOGROUP TSAP1
SYSCATSPACE TSAP2
Db2 Database TEMPSPACE1
/dbtest/apgrp1 Table space
TEST
/dbtest/sysgrp DMS01
Database /tsdb/TEST/dms01
Directory
Instance inst2 /tsdb/inst2/NODE0000/SQL00001
Db2 database and tablespace relocation © Copyright IBM Corporation 2018
SYSCATSPACE SYSCATSPACE
TEMPSPACE1 TEMPSPACE1
Db2 Db2
Database Active Logs
Active Logs Database
PROD TEST
TSAP1 STOGROUP STOGROUP TSAP1
TSAP2 APSTOGRP1 APSTOGRP1 TSAP2
Table space
Table space
DMS01
DMS01
DB_NAME=PROD,TEST
db2relocatedb -f newdb DB_PATH=/dbprd,/tsdb
INSTANCE=inst1,inst2
LOG_DIR=/dblogs/PROD/logs,/dbtest/TEST/logs
CONT_PATH=/dbprd/DB1/dms01,/tsdb/TEST/dms01
STORAGE_PATH=/dbprd/sysgrp,/dbtest/sysgrp
STORAGE_PATH=/dbprd/apgrp1,/dbtest/apgrp1
Db2 database and tablespace relocation © Copyright IBM Corporation 2018
Demonstration 1
Db2 tablespace relocation and transportation
Demonstration 1:
Db2 tablespace relocation and transportation
Purpose:
This demonstration will allow you how to perform several redirected restores.
One DMS managed table space will be restored to a different container.
Several DMS managed tablespaces will be converted to use automatic storage
management. You will utilize the TRANSPORT option of RESTORE to copy a
schema of objects in a set of table spaces to a second database. The
db2relocatedb command will be used to rename a container.
CONNECT RESET
DB20000I The SQL command completed successfully.
TERMINATE
DB20000I The TERMINATE command completed successfully.
Next you will create a set of objects using the schema TEST in the three
tablespaces and load data into the tables. The file testtables.ddl contains the
necessary SQL.
4. Enter the following commands in the Linux terminal session:
• db2 connect to tp1
• db2 -tvf testtables.ddl
The output from this command will look similar to the following:
CREATE TABLE TEST.BRANCH (BRANCH_ID SMALLINT NOT NULL primary key,
BRANCH_NAME CHAR(20) NOT NULL, BALANCE DECIMAL(15,2) NOT
NULL, AREA_CODE CHAR(4) NOT NULL, ADDRESS CHAR(30)
NOT NULL, TEMP CHAR(40) NOT NULL) IN TESTSMALL
DB20000I The SQL command completed successfully.
SQL3107W At least one warning message was encountered during LOAD processing.
SQL3107W At least one warning message was encountered during LOAD processing.
Create a database level offline backup before you begin to make changes to the
tablespace containers.
-- DBPATH ON '<target-directory>'
INTO TP1
-- NEWLOGPATH '/dblogs/inst464/tp1/NODE0000/LOGSTREAM0000/'
-- WITH <num-buff> BUFFERS
-- BUFFER <buffer-size>
-- REPLACE HISTORY FILE
-- REPLACE EXISTING
REDIRECT
-- PARALLELISM <n>
-- COMPRLIB '<lib-name>'
-- COMPROPTS '<options-string>'
-- WITHOUT ROLLING FORWARD
-- WITHOUT PROMPTING
;
-- *****************************************************************************
-- ** storage group definition
-- ** Default storage group ID = 0
-- ** Number of storage groups = 2
-- *****************************************************************************
-- *****************************************************************************
-- ** Storage group name = IBMSTOGROUP
-- ** Storage group ID = 0
-- ** Data tag = None
-- *****************************************************************************
-- SET STOGROUP PATHS FOR IBMSTOGROUP
-- ON '/dbauto/path1'
-- ;
-- *****************************************************************************
-- ** Storage group name = TP1SG1
-- ** Storage group ID = 1
-- ** Data tag = None
-- *****************************************************************************
-- SET STOGROUP PATHS FOR TP1SG1
-- ON '/dbauto/path2'
-- ;
-- *****************************************************************************
-- ** table space definition
-- *****************************************************************************
-- *****************************************************************************
-- *****************************************************************************
-- ** start redirected restore
-- *****************************************************************************
RESTORE DATABASE TP1 CONTINUE;
-- *****************************************************************************
-- ** end of file
-- *****************************************************************************
During the redirected restore, the container for the TESTHIST2 table space will
be changed to a file named /database/inst464/testhist2_2. The size of the new
container will be the same as the original container. The TESTHIST1 table
space will be converted to use automatic storage.
First, restore the TESTHIST1 and TESTHIST2 table spaces using the
REDIRECT option to allow definition of new containers. Run the Db2
RESTORE command to restore the table space from backup in the
$HOME/backups/u5 directory
3. Enter the following command in the Linux terminal session:
• db2 " restore db tp1 tablespace(testhist1,testhist2) online from
$HOME/backups/u5 redirect "
The command should complete with a message:
SQL1277W A redirected restore operation is being performed. During a table
space restore, only table spaces being restored can have their paths
reconfigured. During a database restore, storage group storage paths and DMS
table space containers can be reconfigured.
DB20000I The RESTORE DATABASE command completed successfully.
Check the table space status for TESTHIST1 and TESTHIST2 using the LIST
TABLESPACES command. Note the tablespace ID numbers.
Tablespace ID = 9
Name = TESTHIST1
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x2002100
Detailed explanation:
Restore pending
Restore in progress
Storage may be defined
Tablespace ID = 10
Name = TESTHIST2
Type = Database managed space
Contents = All permanent data. Large table space.
State = 0x2003100
Detailed explanation:
Restore pending
Storage must be defined
Restore in progress
Storage may be defined
Convert the tablespace TESTHIST1 to utilize automatic storage management
using the SET TABLESPACE CONTAINER command.
5. Enter the following command in the Linux terminal session:
• db2 " SET TABLESPACE CONTAINERS FOR 9 USING automatic
storage "
Note that there is no option in SET TABLESPACE CONTAINERS to assign a
storage group, so this tablespace will utilize the default storage group,
IBMSTOGROUP.
List the new container information for the TESTHIST1 table space using a LIST
TABLESPACE CONTAINERS command.
Container ID = 0
Name =
/dbauto/path1/inst464/NODE0000/TP1/T0000009/C0000000.LRG
Type = File
Total pages = 5056
Useable pages = 4992
Accessible = Yes
Define a new container for the DMS managed, TESTHIST2 table space using
the SET TABLESPACE CONTAINER command.
7. Enter the following command in the Linux terminal session:
• db2 " set tablespace containers for 10 using (file
'/database/inst464/testhist2_2' 5000) "
List the new container information for the TESTHIST2 table space using a LIST
TABLESPACE CONTAINERS command.
8. Enter the following command in the Linux terminal session:
• db2 LIST TABLESPACE CONTAINERS FOR 10 SHOW DETAIL
The output will include information similar to the following:
Tablespace Containers for Tablespace 10
Container ID = 0
Name = /database/inst464/testhist2_2
Type = File
Total pages = 5000
Useable pages = 4928
Accessible = Yes
Complete the restore process by issuing the RESTORE command with the
CONTINUE option and roll forward the table space to the end of the logs.
Member ID = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = -
Last committed transaction = 2014-05-15-13.57.30.000000 UTC
3 record(s) selected.
• db2 terminate
• db2 deactivate db tp1
3 record(s) selected.
The tablespaces are all defined using automatic storage management. The
tablespace ID numbers are different in the target database than those in the
source database.
Use the command file unit5_end.cmd to drop the tablespaces used for the
TEST objects in the TP1 database and to drop the TEST database.
6. Enter the following commands in the Linux terminal session:
• db2 terminate
• db2 deactivate db tp1
• unit5_end.cmd
7. Close the terminal and then logout of the Linux operating system
Results:
You used db2relocatedb to rename a table space container. You made table
space container changes, including converting DMS table spaces to use
Automatic Storage management during a redirected restore. You utilized the
TRANSPORT option of RESTORE to copy several table spaces and the
objects for a schema to a different database.
Unit summary
• Explain the facility of the Db2 RESTORE command to recover table
spaces to different containers
• Use the SET TABLESPACE CONTAINERS command to define new
containers during a redirected restore
• Utilize the SET STOGROUP PATHS command to change the storage
paths for automatic storage tablespaces in storage groups
• Plan the use of redirected restore as part of a disaster recovery
• Describe two methods that can be used to convert a DMS table space to
utilize Automatic Storage
• Use the GENERATE SCRIPT option of RESTORE to set up a command
script for a redirected restore operation
• Copy schemas from one database to another using the TRANSPORT
option of the RESTORE utility
• Use db2relocatedb when moving or copying Db2 databases with non-Db2
utilities
Db2 database and tablespace relocation © Copyright IBM Corporation 2018
Unit summary
Unit objectives
• Plan a database recovery strategy that includes both full and
Incremental backups to reduce the duration and size of database
backups
• Implement a physical database design to take advantage of
Incremental backups of selected table spaces
• Check Tablespace trackmod status using SQL query with the
MON_GET_TABLESPACE table function
• Utilize an Incremental restore to recover a Db2 database or table
space from incremental backup images
• Use the LIST UTILITIES command to track the processing of an
Incremental backup or restore process
Unit objectives
Space Required for Backups and Logs: Your database recovery plan might include
a combination of full database backups and incremental backup operations. You might
decide to take full database backups regularly to provide the fewest number of backup
images to manage. Table space backup images are useful for efficient recovery from
an isolated disk failure or an application error. You should also consider saving at least
two full database backup images and their associated logs as an extra precaution.
If a database contains large amounts of long field and large object (LOB) data, backing
up the database could be very time-consuming. The Backup Utility lets you back up
selected table spaces. If you use DMS table spaces, you can store different types of
data in their own table spaces to reduce the time required for backup operations. You
can keep table data in one table space, long field and LOB data in another table space,
and indexes in yet another table space. By storing long field and LOB data in separate
table spaces, the time required to complete a backup operation can be reduced by
choosing not to back up the table space containing the long field and LOB data. If the
long field and LOB data is critical to your business, backing up these table spaces
should be considered against the time required to complete the restore operation for
these table spaces.
Using the COMPRESS option of the BACKUP utility might significantly reduce the size
of each database backup. Depending on the system resources, using a compressed
backup could extend the backup duration based on increased CPU usage or reduce
backup time by reducing the number of I/Os required.
The LOGARCHCOMPR1 and LOGARCHCOMPR2 database configuration option
control compression for archived log files. These can be used to reduce storage
requirements for the archived logs, retained to support various recovery tasks.
Time required for recovery: The time required to recover a database is made up of
two parts: the time required to complete the restoration of the backup image(s); and, if
the database is enabled for forward recovery, the time required to apply the logs during
the roll forward operation. When formulating a recovery plan, you should take these
recovery costs and their impact on your business operations into account.
Testing your overall recovery plan will assist you in determining whether the time
required to recover the database is reasonable given your business requirements.
Following each test, you might want to increase the frequency with which you take a
backup. If roll forward recovery is part of your strategy, this will reduce the number of
logs that are archived between backups and, as a result, reduce the time required to roll
the database forward after a restore operation.
If you reorganize a table, you should back up the affected table spaces after the
operation completes. If you have to restore the table spaces, you will not have to roll
forward through the data reorganization.
Incremental (Cumulative)
Table space Backups
Logs
Incremental (Cumulative)
Table space Backups
Logs
In the example, the daily delta table space backups vary in size depending on the
amount of new database updates each day. The equivalent Incremental table space
backups will increase in size each day to include any newly updated pages. Changing
the same page multiple times will not increase the size of the backup images. Notice
that each delta backup points to the previous day's backup rather than back to the full
backup.
The use of the delta table space backups should reduce the time required for each daily
backup as well as the total space required to store the backup images. The Incremental
backup strategy might support faster recovery because only the full backup and the
single last Incremental backup images are restored, where using the delta backups for
recovery would require the entire set of delta backups to be restored over the full
backup to complete the recovery process.
• Time required for recovery: The time required for recovery using the
incremental backup images could in some cases take longer than recovering
using full backups. For example, recovery using an incremental table space
backup would require reading and restoring the incremental backup and the full
database or table space backup that it is based on compared to restoring a single
full table space backup. The smaller size of incremental backup images could
minimize the impact. Restoring a long sequence of delta backups could also
lengthen the restore processing.
• The roll forward will only require the logs since the last incremental backup, so to
optimize recovery time it might be necessary to schedule the incremental or delta
backups to minimize the number of Db2 logs needed for recovery. For example,
you could run an incremental or delta backup following a large update process to
avoid having to redo the associated logs during a recovery.
Backup Backups
Incremental (Cumulative)
Table space Backups
Logs
6. Friday: An new incremental table space backup is taken for the same subset of
table spaces. This will include all the changes since Sunday's full database
backup. This backup would allow a recovery to be done without using any of the
backups since Sunday.
7. Saturday: A fourth delta backup of the same set of table spaces contains just
the updates for those table spaces since the incremental backup on Friday.
Mixing the use of incremental and delta backups could provide a balance between the
desire to minimize backup size and duration with the requirements to recover any
portion of the database efficiently.
Incremental
Full Database DB Backup
Backup (offline)
(offline)
Logs
• Only database backups can be created, table space backups are not allowed.
• Backups must be created offline, with no concurrent access to the database.
• Following a restore, no roll forward can be performed.
Full Tablespace
Full DB backup
Backup
Incremental
DB backup
Logs
Db2 Database
ASTS1
SYSCATSPACE
Table Space DMSHIST
Information Table Space
Table Space Information
Information
>--+-------------------------------------+---------------------->
'-USER--username--+-----------------+-'
'-USING--password-'
>--+----------------------------------------------------------------------------+-->
'-ON--+-+-DBPARTITIONNUM--+--| Partition number(s) |-------------------------+-'
| '-DBPARTITIONNUMS-' |
'-ALL DBPARTITIONNUMS--+-----------------------------------------------+-'
'-EXCEPT--+-DBPARTITIONNUM--+--| Partition number(s)
'-DBPARTITIONNUMS-'
>--+---------------------------------------+--+--------+-------->
| .-,---------------. | '-ONLINE-'
| V | |
'-TABLESPACE--(----tablespace-name-+--)-'
>--+------------------------+----------------------------------->
'-INCREMENTAL--+-------+-'
'-DELTA-'
Delta
Full Incremental
Logs
The final determination about whether a page is included in a backup image will be
done by inspecting the page change LSN on each page, and comparing this with the
LSN of this backup’s predecessor. If the page has been updated since the previous
backup, then it will be copied into the backup image. Otherwise, it will not.
Although minimal, the tracking of updates to the database can have an impact on the
run time performance of transactions which update or insert data. At run time,
whenever a page is written to disk after any modification to it, an additional overhead
will be incurred in order to track this modification in the manner described above. This
additional overhead will be an examination of the table space dirty flag in the table
space definition in memory. If this is the first modification to a clean table space, then
the table space definition will be updated and written to disk. Subsequent updates to the
same table space will inspect the tracking indicator, but will not require the additional
I/O.
Delta
Full Incremental
Logs
Delta
Full
Incremental
Logs
8 record(s) selected.
Db2 cannot detect whether LOB and Long field data have been updated so all of these
data types will be included in every Incremental backup. If the LOB data is not changed
often, placing the LOB data in a separate DMS Large table space might allow Db2 to
skip processing the entire DMS Large table space because Db2 does know if there
have not been any changes at the table space level.
Placing the data components and index portions of a table in separate table spaces
could allow Db2 to skip reading the index table space if the indexes have not been
updated when the data portion has been updated.
Range-partitioned tables allow defined ranges to be stored in different table spaces. For
some applications, this would allow those ranges that will not be updated to be stored in
a set of table spaces that Db2 can track as read-only, while the ranges that do contain
changes would be stored in another set of table spaces that would be included in an
incremental backup. This is especially useful for very large tables where new ranges
are added or attached and the existing data might be static.
Delta
Incremental
+ + +
Full Incremental Delta(s) Log(s)
Logs
4. Repeating Step 3 until the target image from Step 1 is read a second time. The
target image is accessed twice during a complete incremental restore operation.
During the first access, only initial data is read from the image; none of the user
data is read. The complete image is read and processed only during the second
access. The target image of the incremental restore operation must be
accessed twice to ensure that the database is initially configured with the correct
history, database configuration, and table space definitions for the database that
will be created during the restore operation.
In cases where a table space has been dropped since the initial full database backup
image was taken, the table space data for that image will be read from the backup
images but ignored during incremental restore processing.
restore-options
>--+--------------------------------------------------------------------------------------------------+-->
+-REBUILD WITH--+-+-ALL TABLESPACES IN DATABASE-+--+---------------------------------------+-+-----+
| | '-ALL TABLESPACES IN IMAGE----' '-EXCEPT--| rebuild-tablespace-clause |-' | |
| '-| rebuild-tablespace-clause |----------------------------------------------' |
'-+-TABLESPACE--+------------------------------------------------------------------+-+--+--------+-'
| | .-,---------------. | | '-ONLINE-'
| | V | | |
| '-(----tablespace-name-+--)--+-----------------------------------+-' |
| '-SCHEMA--+-----------------------+-' |
| | .-,-----------. | |
| | V | | |
| '-(----schema-name-+--)-' |
+-HISTORY FILE---------------------------------------------------------------------+
+-COMPRESSION LIBRARY--------------------------------------------------------------+
'-LOGS-----------------------------------------------------------------------------'
>--+----------------------------+------------------------------->
'-INCREMENTAL--+-----------+-'
+-AUTO------+
+-AUTOMATIC-+
'-ABORT-----'
Backups
Delta
1. RESTORE DB TP1 TABLESPACE(TP1DMS) ONLINE
Thu
INCREMENTAL FROM /home/inst49/backups/thursday
TAKEN AT 20140820124217
+
Full
Recovery 2. RESTORE DB TP1 TABLESPACE(TP1DMS) ONLINE Sunday
History file INCREMENTAL /home/inst49/backups/sunday
TAKEN AT 20140816012005 +
Incremental
3. RESTORE DB TP1 TABLESPACE(TP1DMS) ONLINE Wed
INCREMENTAL FROM d:\cf49\backups\wednesday
TAKEN AT 20140819020700
+
Delta
4. RESTORE DB TP1 TABLESPACE(TP1DMS) ONLINE
Thu
INCREMENTAL FROM /home/inst49/backups/thursday
TAKEN AT 20140820124217
Backups
In the example:
1. The first restore command refers to the Delta table space backup taken on
Thursday to begin the manual incremental restore.
RESTORE DB TP1 TABLESPACE(TP1DMS) ONLINE INCREMENTAL FROM
/home/inst49/backups/thursday TAKEN AT 20140820124217
2. The next command restores the TP1DMS table space from the full database
backup taken on Sunday.
RESTORE DB TP1 TABLESPACE(TP1DMS) ONLINEINCREMENTAL
/home/inst49/backups/sunday TAKEN AT 20140816012005
3. The next command restores the TP1DMS table space pages that were included
in the Incremental table space backup taken on Wednesday. The delta backups
from Monday and Tuesday are not needed because the incremental backup is
cumulative.
RESTORE DB TP1 TABLESPACE(TP1DMS) ONLINEINCREMENTAL FROM
d:\cf49\backups\wednesdayTAKEN AT 20140819020700
4. The last command restores the TP1DMS table space pages that were included
in the delta backup from Thursday. This was the target image for the manual
incremental restore, so the restore process is complete.
RESTORE DB TP1 TABLESPACE(TP1DMS) ONLINE INCREMENTAL FROM
/home/inst49/backups/thursday TAKEN AT 20140820124217
It is highly recommended that you not use the FORCE option on the PRUNE
HISTORY command. The default operation of this command prevents you from
deleting history entries that might be required for recovery from the most recent, full
database backup image, but with the FORCE option, it is possible to delete entries
that are required for an automatic restore operation.
====================================================================
Recovery
History file
ID = 13
Type = RESTORE
Database Name = TP1
Member Number = 0
Description = automatic incremental tablespace TP1HIST...
Start Time = 05/08/2014 11:43:14.874047
State = Executing
Invocation Type = User
Progress Monitoring:
Phase Number = 1
Total Work = 2080768 bytes
Completed Work = 2080768 bytes
Start Time = 05/08/2014 11:43:14.874050
Phase Number = 2
Description = 20140508110819
Total Work = 38944768 bytes
Completed Work = 38944768 bytes
Start Time = 05/08/2014 11:43:15.041918
Current Step
Description = 20140508111656
Completed Work = 24608768 bytes
Start Time = 05/08/2014 11:43:16.126243
Phase Number = 4
Description = 20140508112654
Completed Work = 0 bytes
Start Time = Not Started
. . . . . . .
Delta TS
Full TS Backup
Backup
Incremental
TS Backup
Logs
Incremental
Restores
+ +
Incremental Delta
Full TS TS TS
Rollforward
+ Table space
Logs
In the example, a damaged table space has been restored using an incremental restore
that included:
1. The full table space backup taken on Sunday.
2. The incremental table space backup taken on Wednesday.
3. The delta table space backup taken on Thursday.
The following rollforward command is issued:
db2 ROLLFORWARD DB TP1 TO END OF LOGS TABLEPSPACE(TP1HIST) ONLINE
The roll forward process will begin with the logs associated with the delta backup from
Thursday and continue through to the most current active logs.
One of the key advantages to utilizing incremental backups is the ability to reduce the
number of logs processed during the rollforward recovery by taking more frequent
backups while limiting the time and space required for the backups.
Demonstration 1
Incremental Backup and Restore
Demonstration 1:
Incremental Backup and Restore
Purpose:
To utilize the three modes for Db2 backups: Full, Incremental, and Delta at the
database and table space level. You will check the size of each backup image
produced and the portion of the database read to produce each backup to
help quantify the benefits of using these options. You will also perform an
Incremental restore in automatic mode.
DIRECT_READ_BEFORE_BACKUP
-------------------------
6452
select
(dir_read_now - dir_read_start) as direct_reads_since_start
from bkstats where id = 1
DIRECT_READS_SINCE_START
------------------------
391350
1 record(s) selected.
total 44032
-rw-------. 1 inst464 adm01 45088768 Apr 26 06:44
TP1.0.inst464.DBPART000.20180426064439.001
Note the size of the backup and the number of Direct Reads in the results table
for backup 1. In the example above, the size would be 45 MB and the number
of Direct Reads is 391K.
The Db2 database statistic Direct Reads shows the amount of data read outside
the Db2 buffer pools. Direct reads are in units, the smallest being a 512 byte
block. The Backup and Restore utilities use the database utility Heap rather
than the buffer pools so the read I/Os for backups are counted as Direct Reads.
DIRECT_READS_SINCE_START
------------------------
366452
1 record(s) selected.
total 64064
-rw-------. 1 inst464 adm01 45088768 Apr 26 06:44
TP1.0.inst464.DBPART000.20180426064439.001
-rw-------. 1 inst464 adm01 20512768 Apr 26 10:02
TP1.0.inst464.DBPART000.20180426100237.001
Notice the size of the backup and the number of Direct Reads for backup 2. In
the example above, the size of the incremental database backup image was 20
MB, which is significantly smaller than the full backup. The number of Direct
Reads is only slightly smaller, because the largest tablespaces needed to be
examined page by page.
Check the messages generated in the db2diag.log file by the Incremental
backup. Use the db2diag command to filter the diagnostic log messages and
list the informational messages associated with the incremental backups.
4. In the terminal session, issue the following commands:
• db2diag -gi message:=back | more
The output from this command will include messages similar to the following:
2018-04-26-10.02.38.312004-240 E2944206E496 LEVEL: Info
PID : 4212 TID : 140535163512576 PROC : db2sysc 0
INSTANCE: inst464 NODE : 000 DB : TP1
APPHDL : 0-288 APPID: *LOCAL.inst464.180426140237
AUTHID : INST464 HOSTNAME: ibmclass
EDUID : 56 EDUNAME: db2agent (TP1) 0
FUNCTION: DB2 UDB, database utilities, sqlubSetupJobControl, probe:1907
MESSAGE : Starting an online incremental db backup.
The table space TP1ACCTI was skipped. The TP1ACCTI table space contains
the Indexes for the ACCT table and the table changes to the ACCT table did not
require index changes.
Use the Db2 command file ingesttabs.ddl to make additional logged changes to
four tables using INGEST commands.
5. In the terminal session, issue the following commands:
• db2 connect to tp1
• db2 -tf ingesttabs.ddl
Create an Incremental Delta backup of the two table spaces TP1HIST and
TP1ACCTD. This backup will only contain the updates since the previous
incremental database backup. Run the Db2 BACKUP command to back up the
table spaces TP1HIST and TP1ACCTD using the $HOME/backups/u6
directory, with the INCREMENTAL DELTA option.
Use the file bkstart.sql to save the current count for direct reads.
6. In the terminal session, issue the following commands:
• db2 -tf bkstart.sql
• db2 " BACKUP DATABASE TP1 TABLESPACE(TP1ACCTD,TP1HIST)
ONLINE INCREMENTAL DELTA to $HOME/backups/u6 BUFFER 250
COMPRESS EXCLUDE LOGS "
Check the size of this backup image, issue the UNIX ls command. To get a
count of the Direct Reads performed by the BACKUP utility, use the SQL
statements in the file bkend.sql.
7. In the terminal session, issue the following commands:
• db2 connect to tp1
• db2 -tf bkend.sql
• ls -l $HOME/backups/u6
The output from this command will look similar to the following:
DB20000I The SQL command completed successfully.
DIRECT_READS_SINCE_START
------------------------
92244
1 record(s) selected.
DIRECT_READS_SINCE_START
------------------------
34900
1 record(s) selected.
Unit summary
• Describe the infrastructure used to support monitoring
• Configure a database to collect the activity, request and object metrics
returned by the Monitoring Table functions
• Investigate current application activity that might indicate performance
problems using SQL statements
• Use the Db2-provided views and functions in SQL to evaluate efficient
use of database memory for locks, sorting and database buffer pools
• Check database health indicators, like log space available and table
space utilization using CLP queries using Monitor functions and views
Unit summary