48
1 13 October 2008 • 16:15 – 17:15 Platform: DB2 z/OS Melanie Stopfer IBM North America Lab Services [email protected] Session: B02 DB2 Connect to DB2 z/OS – Problem Determination & Performance Tips & Tricks Title: DB2 Connect to DB2 z/OS - Problem Determination & Performance Tips & Tricks Abstract: Learn how to resolve problems that arise in your DB2 Connect to DB2 z/OS environment. By using the right tools, develop a methodology to isolate and resolve problems and improve your ability to meet your On Demand business requirements. Attend this session and learn how to prepare yourself to successfully perform problem determination in your DB2 Connect to DB2 z/OS environment. Melanie will include tips and tricks that she has learned from customer experiences.

DB2 Connect to DB2 z/OS - Problem Determination

  • Upload
    tess98

  • View
    2.133

  • Download
    8

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: DB2 Connect to DB2 z/OS - Problem Determination

1

13 October 2008 • 16:15 – 17:15Platform: DB2 z/OS

Melanie StopferIBM North America Lab [email protected]

Session: B02DB2 Connect to DB2 z/OS –Problem Determination & Performance Tips & Tricks

Title:DB2 Connect to DB2 z/OS - Problem Determination & Performance Tips & Tricks

Abstract:Learn how to resolve problems that arise in your DB2 Connect to DB2 z/OS environment. By using the right tools, develop a methodology to isolate and resolve problems and improve your ability to meet your On Demand business requirements. Attend this session and learn how to prepare yourself to successfully perform problem determination in your DB2 Connect to DB2 z/OS environment. Melanie will include tips and tricks that she has learned from customer experiences.

Page 2: DB2 Connect to DB2 z/OS - Problem Determination

2

2

• Describe data flow within a DB2 Connect environment and develop a problem determination methodology

• Perform problem determination analysis using tools available on DB2 Client

• Capture, parse and examine CLI and JCC Traces, configure DB2 Connect to improve performance, and analyze Snapshot DCS monitor output

• Run and interpret network commands and use DB2 commands to perform problem determination

• Analyze accounting, statistics and performance trace output to identify and resolve connection and performance problems

Objectives

Outline:I. Preparing for Problem Determination

Distributed DB Environment - Data FlowDBM CFG SettingsDB2 Registry Variable SettingsZPARM Settings

II. Problem Determination - Where's the Problem?Methodology for Isolating Problem's SourceFailure to Connect Checklist

III. Monitoring and Flow Details Which Tool to Use?

IV. Analyzing with Client Tools Diagnostic Log ConfigurationsAnalyzing CLI Trace OutputAnalyzing JDBC/Java Trace Information

V. Analyzing with DB2 Connect ToolsList DCS Applications ExtendedSnapshot DCS ApplicationsDRDA Trace

Page 3: DB2 Connect to DB2 z/OS - Problem Determination

3

3

Application?Network?

Client System?DB2 Run-Time?

DB2 Connect?LUW System?

DRDA?TCP/IP?

DDF?VTAM?

z/OS System?DB2 Subsystem?

UNIX System Services?RACF?

Problem Determination –Where’s the Problem?

A typical problem description in a DB2 Connect environment is “It just doesn't work”. Data flows through a large number of components, all of which are required to support an application. You should be aware of the various components that make up a DB2 Connect environment. Problems can occur anywhere along the data flow path. There is no problem determination tool that can look at or analyze the global picture. Each component has its own logs and monitoring tools. As the system administrator, you need to know what components are in the data flow path, what logs to go to and what tools are available to monitor or trace a particular component.

So how do we approach problems in this environment?

Page 4: DB2 Connect to DB2 z/OS - Problem Determination

4

4

DBMCFG

DatabaseDirectory

db2cli.ini

NodeDirectory

DBMCFG

DatabaseDirectory

NodeDirectory

BSDS ZPARMS

DB2 ConnectDB2 Connect z/OSz/OSClientClientA

pplic

atio

n

DB2

CLI

/OD

BCD

river

DB2

Run

-Tim

e

TCP

/IP

Instance

TCP/

IP

db2a

gent

TCP

/IP

DDF

TCP/

IP

UN

IX S

yste

mS

ervi

ces

DBA

T

DB

2

DCSDirectory

Distributed Database Environment – TCP/IP

DB2 Connect operates in a distributed environment consisting of multiple components. Each component provides some required function in moving information between clients and servers. Each component is critical to the successful flow of data. When performing problem determination or performance studies, understanding what components data must flow through is critical for a successful resolution. Starting with the client system, SQL requests flow from an application through some networking protocol stack and onto the physical network. The data flows to a DB2 Connect system using DRDA protocol format and is handled by an agent task running under a DB2 Connect instance. The data flows into a z/OS system and is received by the DDF component of DB2 for z/OS, where any necessary codepage conversion is done. As of DB2 for z/OS V8, all SQL is parsed in UNICODE (CCSID 1208). Then the connection is assigned to a thread in the DBM1 address space. The thread is responsible for executing your SQL request and returning a response.

Page 5: DB2 Connect to DB2 z/OS - Problem Determination

5

5

Preparing for Problem Determination

DBM CFG– DIAGLEVEL/NOTIFYLEVEL = 4– DFT_MON_STMT = ON– DFT_MON_UOW = ON

DB2 Registry Variable– DB2CONNECT_IN_APP_PROCESS = NO

Allows Sysplex, Monitoring,Connection Concentrator

ZPARMS– EXTSEC = YES– SMFACCT = 1,2,3,7,8– SMFSTAT = YES (Default)

On average, each additional EDU agent takes 3MB memory in a process model environment. ExtSEC is set to YES by default and allows detailed security reason codes to be returned to DRDA and passwords to be changed. Only two monitor switches are used by DRDA. DB2 starts accounting classes 1, 2, and 3 automatically. The statistics trace is a system wide trace.

Because many (or most) problems that you will encounter are unintentional, unplanned, unlikely, unanticipated, and so forth, they always seem to come at the most inopportune times, when you least expect it and can least afford it. So the more you can be prepared for problem situations, the sooner you can identify the problems, bring appropriate problem tools to bear to isolate the problem, and resolve the problem. Many problem determination and analysis tools, like monitors and traces, are very effective in locating and resolving problems. However, by their very nature, they may be very resource intensive. Starting them automatically and running them all the time may put an additional load on the system, which could be counterproductive, and mask problems or lead to additional problems.

There are some things you can do to customize or alter the configuration of your system, however, which will probably not use a great deal of additional resources, and at the same time improve your ability to perform problem analysis more quickly and effectively. On your DB2 Connect system, you can make sure the following settings are in place:• In the DBM CFG, make the following updates:- NOTIFYLEVEL=4

Page 6: DB2 Connect to DB2 z/OS - Problem Determination

6

6

Failure to Connect

Application cannot connect to databasedb2 connect to ...

MissingLink

DDF

DB2 Connect

Missing link between DDF and DB2 Connect is often the reason for a connection failure.

If a DB2 Connect server configuration is being used, the missing link could also be between the remote client system and the DB2 Connect server.

If one thinks in terms of a DB2 Connect server perspective, the inbound link is between the remote client and DB2 Connect server. The outbound link is between DB2 Connect server and DDF.

Page 7: DB2 Connect to DB2 z/OS - Problem Determination

7

7

Failure to Connect ChecklistIs DRDA AS active?• DDF started• DDF LU active to VTAM

Is TCP/IP correctly configured?• IP addresses and host names• Routers operational?• Service name map to correct port numbers?

Is LOGON info correct?• User name• Password • DRDA AS password expired• User name been disabled on DRDA AS

Check z/OS console/master logs for DSN* messagesCheck diagnostic/error logs for messagesRun DRDA trace on DB2 Connect ServerIs DB2 Connect info correct?• Node, System Database, and DCS directories

FYI: Even if this is a TCP/IP only environment, DDF must have a LU defined under VTAM and that LU must be active.Problem Isolation Checklist:

- Make sure DDF is started on the DB2 for z/OS DRDA AS.- Make sure the DDF APPL LU is active under VTAM - even if this is a TCP/IP only environment, DDF must have an LU defined under VTAM and the LU must be active.- If using TCP/IP:

• Is TCP/IP properly configured on the host and at the DB2 Connect system?• IP addresses and host names are correct?• Routers are operational and a path exists between the host and DB2 Connect system?• Service names used are correct and map to correct port numbers?

- Verify Database, Node, and DCS directory entries on DB2 Connect Server.- Verify database and node directory entries on client.- Check the z/OS console log or DB2 for z/OS master log for DSN messages.- Check error logs for messages.- Run a DRDA trace on the DB2 Connect Server.- Try it locally. - Deliberately crash each component.

• DB2 Connect message identifiers consist of a three-character message prefix

Page 8: DB2 Connect to DB2 z/OS - Problem Determination

8

8

DB2 Connect Correlations Worksheet Using TCP/IP

Alias

Database

Node

System DB Directory

DCS Directory

Local Database

Target DatabaseDB2 for z/OS

BSDS

LOCATIONLUNAMEPORTRPORT

z/OS

\etc\hosts

Hostname:IP

address:

db2aserv446

TCPIP.DATADOMAINORIGIN

: HOSTNAME

tcpip.ETC.SERVICESdrda /tcp

tcpip.HOSTS.LOCAL or DNSHOST : :

TCPPARMS(PROFILE)PORT TCP DB2ADISTPORT TCP DB2ADISTHOME TR1

APPL LUNAME=

VTAM

Node Directory

Node

Hostname

Service name

Protocol TCPIP

DB2 CONNECT TO

Services fileService name:Port number:

Hosts file or DNSHostname:IP address:

Linux/UNIX/Windows

This graphic provides a correlation chart of z/OS, DB2 for z/OS, DB2 Connect, and client parameters. These parameters are required to establish connectivity between DB2 Connect and a DB2 for z/OS subsystem. It also provides students with a shell to document their own parameter values that need to match.

Page 9: DB2 Connect to DB2 z/OS - Problem Determination

9

9

Problem Determination -Methodology

Client

DB2 Connect

z/OS

Narrow Scope of Problem!

The first step is to start isolating the problem to as few components as possible. A good starting point is to see if the problem is with only one application on one workstation or if the problem is widespread. If the problem is only on one workstation or only with one application, then you've narrowed the scope of the problem.

If the problem is widespread, then you need to start looking at facilities being used by all users, such as the network, the DB2 Connect server, or the z/OS system.

If there is a connection problem, make sure:1. You can ping/aping from the DB2 client to the DB2 Connect system and the DB2 Connect system to the z/OS system.2. You can connect from the DB2 Connect system.3. The DB2 Connect system is up and the instance started.4. The DDF address space is started.5. The DB2 for z/OS subsystem is started.

If the problem is not a connection problem:1. Check whether any maintenance was applied or changes made to the DB2 for z/OS subsystem.2. Try to determine what assumptions were made by the application developers and retest the assumptions.3. If the problem cannot be isolated, gather your results and contact the IBM Support

Page 10: DB2 Connect to DB2 z/OS - Problem Determination

10

10

Data Flow - Client

Client SystemDB2 Instance

Net

wor

k P

roto

col

DB

2 R

un-T

ime

Clie

nt

Application Ada

pter

DBMCFG

db2cli.ini

NodeDirectory

DatabaseDirectory

LAND

B2

Driv

er

So lets start isolating the problem – starting with the data flow through the client.

Page 11: DB2 Connect to DB2 z/OS - Problem Determination

11

11

Monitoring and Flow Summary

DB2

TCP/IP

USS

DDF

thread

TCP/IP

TCP/IP

Agent

TCP/IP

Application

ODBC

DB2

RUN

TIME

DB2

CLI/JCC

Client DB2 Connect z/OS

db2 ping

jcctraceclitrace(In Appli-cation)

jcctraceclitrace (In DB2)

Class 1 Elapsed - Class 2 Nonnested Elapsed

Class 1 Elapsed

pingsnapshot

db2drdatsnapshot

Class 1Nonnested

CPU -Class 2

NonnestedCPU

Class 2Non-nestedElapsednetwork analyzer network analyzer

ping

snapshot

The key to solving the problem is knowing where time is spent. Is it spent in the application? In the network? On the client? In DB2 Connect? In DDF? In DB2 z/OS? Well let’s look at what traces are available to help us isolate the problem and know who to point the finger at! Whose to blame? This is a great chart to show you all your options. This graphic summarizes all the performance monitoring tools discussed previously and graphically shows what each tool is measuring.

Normally, the best place to start a performance analysis is on the client system where the application is executing. Using the CLI and JCC Traces and trace parser facilities, elapsed times can be broken down between In Application time and In DB2 time. This information can direct you towards looking at performance issues in the application or outside the application (in the DB2 Client code, network, DB2 Connect, or DB2 for z/OS. The CLI and JCC traces can also be used to measure elapsed time to complete every SQL statement.Statements with a higher than expected response time could then be analyzed further, using a tool like Visual Explain.

Next, by looking at DB2 for z/OS accounting trace Class 1 and Class 2 nonnested elapsed times, time can be separated by DB2 for z/OS processing time (Class 2 elapsed time) and distributed processing time (Class 1 elapsed time less Class 2 elapsed time). If Class 2 nonnested elapsed time seems excessive, take a percentage of Class 2 nonnested CPU time to Class 2 nonnested elapsed time. This will show the percentage of elapsed time executing SQL. If the percentage is small, then analyze wait times. Calculate what percentage of Class 2 nonnested elapsed time was spent on locks I/O and other wait elements If there is a performance problem within the DB2

Page 12: DB2 Connect to DB2 z/OS - Problem Determination

12

12

db2cli.ini

[COMMON]trace = 1tracecomm = 1traceerrimmediate=1tracefilename = d:\temp\cli.trctracepathname = d:\temptraceflush = 0traceflushonerror=1tracelocks = 0tracepidlist =tracepidtid = 1tracerefreshinterval = ntracestmtonly = 0tracetime = 1tracetimestamp = 1

Traces CLI/ODBC Programs

Client tools – Traces – CLI trace

Trace off is the default. Specify either the trace filename or trace pathname, but use path name for multi-threaded applications only. Only set trace flush to 1 if applications do not exit normally. Use TRACECOMM=1 to get network request information. Set tracetimestamp to 1. Trace pid ids by setting tracepidtid to 1.

Only the keywords that apply to all connections to DB2 through the DB2 CLI/ODBC driver are included in the COMMON section.

The CLI/ODBC trace facility is an essential tool for problem determination and general understanding of an application. All function calls executed are recorded in a text file for later analysis. In addition to functional information, the trace file contains time information which can be extremely useful for application and database tuning.

To obtain a CLI trace, the db2cli.ini file must be updated to include a [COMMON] section.

There are several ways to update the db2cli.ini file.1. Use the Configuration Assistant: Select a database (it must be one registered for ODBC), then Properties, CLI/ODBC Settings, Advanced, and Service.

2. DB2 Command Window:• db2 update cli cfg for section common using trace 1• db2 update cli cfg for section common using tracefilename filename• db2 update cli cfg for section common using tracecomm 1

Confirm the db2cli.ini configuration:db2 GET CLI CFG FOR SECTION COMMON

3. Edit the db2cli.ini file and add the following lines. Only the keywords that apply to allconnections to DB2 through the DB2 CLI/ODBC driver are included in the COMMON section:

[COMMON]• TRACE=1 (0 is the default)• TRACECOMM=1 (Use a 1 to include information about each network request in the trace file - 0 is the default)• TRACEERRIMMEDIATE=1 (helps in determining when errors occur during application execution by writing diagnostic records to the CLI/ODBC trace file at the time the records are generated)• TRACEFILENAME=<fully_qualified_filename> OR• TRACEPATHNAME=<fully_qualified_pathname> (Multi-threaded apps only)• TRACEFLUSH=1 (only use if applications do not exit normally - 0 is the default)• TRACEFLUSHONERROR=1 (forces the DB2 CLI driver to close and re-open the trace file each time an

Page 13: DB2 Connect to DB2 z/OS - Problem Determination

13

13

Client Tools – Traces – CLI Trace Output

SQLPrepare( hStmt=1:6, pszSqlStr="SELECT A.BRANCH_ID, B.BRANCH_NAME, COUNT(*),SUM(A.BALANCE) FROM ACCT A, BRANCH B WHERE A.BRANCH_ID = B.BRANCH_ID GROUP BYA.BRANCH_ID, B.BRANCH_NAME", cbSqlStr=-3 )

---> Time elapsed - +0.000000E+000 seconds( StmtOut="SELECT A.BRANCH_ID, B.BRANCH_NAME, COUNT(*), SUM(A.BALANCE) FROM ACCTA, BRANCH B WHERE A.BRANCH_ID = B.BRANCH_ID GROUP BY A.BRANCH_ID, B.BRANCH_NAMEFOR FETCH ONLY" )

SQLPrepare ( )<--- SQL_SUCCESS Time elapsed - +0.000000E+000 seconds

SQLExecute (hStmt=1:6 )---> Time elapsed - +0.000000E+000 secondssqlccsend( ulBytes - 436 )sqlccsend( Handle - 12744784 )sqlccsend( ) - rc - 0, time elapsed - +0.000000E+000 secondssqlccrecv( )sqlccrecv( ulBytes - 163 ) - rc - 0, time elapsed - +4.000000E-002

SQLExecute ( )<--- SQL_ERROR Time elapsed - +4.000000E-002 seconds

SQLFreeStmt ( hStmt=1:6, fOption=SQL_CLOSE )---> Time elapsed - +0.000000E+000 seconds

( Unretrieved error message="SQL0206N "A.BRANCH_ID" is not a colum in an inserted table, updated table, or any table identified in a FROM clause or is not a valid transition variable for the subject table of a trigger.SQLSTATE=42703" )( COMMIT=0

sqlccsend( ulBytes - 196 )sqlccsend( Handle - 12744784 )sqlccsend( ) - rc - 0, time elapsed - +0.000000E+000 sqlccrecv( )sqlccrecv( ulBytes - 27 ) - rc - 0, time elapsed - +3.000000E-002

The .002 negative means move decimal place two to the left so 4.0 -002 seconds is .04 seconds or 4 milliseconds. There was deferred prepare turned on by default. The execute had an error so didn’t take long to run the statement.

The DB2 Run-Time Client CLI driver writes trace records when it is entered and when it exits, to reflect the activity just completed. In the above graphic, the SQLPrepare entered into the CLI driver. You can tell entry records by the ---> symbol on the Time elapsed line.

The second entry for SQLPrepare was the exit from the CLI driver. The <--- symbol represents an exit from the CLI driver. The Time elapsed is the time spent in DB2 to process the SQLPrepare call. The in DB2 time includes the time in the CLI Driver, the DB2 Run-Time Client, the entire communication infrastructure between client and the database server, time spent on the DB2 Connect Server, and the time spent in the DB2 for z/OS subsystem.

The second SQLExecute record shows an SQL error occurred during execution of the SQL statement.

The line, SQLFreeStmt, shows the SQL error, SQL0206N, and a description of the error. The COMMIT statement flows because autocommit is on by default.

The trace example was captured using TRACECOMM=1. What was added to the trace were the lines in the entry record for SQLExecute following the “Time elapsed” line. By specifying TRACECOMM=1, you can:

1. Find out when a client-to-server communication occurs, either locally or over the network. Many CLI functions are processed completely on the client and therefore do not represent a performance problem.2. Find out the number of bytes sent and received in each communication.3. Break down CLI call elapsed times into their CLI and their communications components.

The CLI trace information provides you with several timings:• The time between SQL requests• The time to process the send and get a confirmation back• The time from the end of the send to the end of the receive• The total time spent "in DB2"

Two CLI keywords allow you to timestamp each record and to also include process and thread IDs.

• TraceTimeStamp adds a timestamp to the beginning of each line. There are three formats available, with the default value being 0 (off).

1. =1 [<number of seconds since 01/01/1970>.<microseconds>-<formatted timestamp>]2. =2 [<number of seconds since 01/01/1970>]3. =3 [<formatted timestamp>]

• TracePidTid causes each line to begin with the process ID and thread ID of the application thread issuing the CLI

Page 14: DB2 Connect to DB2 z/OS - Problem Determination

14

14

Sample CLITraceParser OutputOverall Trace statistics========================================================

10023 statements in trace.12.400 seconds total trace time.0.172 seconds spent for application processing.12.228 seconds spent for CLI processing.

Network Specific CLI processing time statistics========================================================

10002 network flows sent to transmit 1230482 bytes, requiring a total of0.476 seconds.

10002 network flows received, transmitting 860386 bytes, requiring a total of9.214 seconds.

End of overall trace statistics report***************************************************************************************************Function specific statistics========================================================

Timing Network Send Network ReceiveFunction Name Total Application CLI Flows Bytes Time Flows Bytes Time---------------------------------------------------------------------------------------------------SQLGetInfo 3 0.001 0.000 0 0 0.000 0 0 0.000SQLSetConnectAttr 1 0.000 0.000 0 0 0.000 0 0 0.000SQLExecDirect 1 0.000 0.008 1 10 0.000 1 54 0.008SQLGetFunctions 1 0.000 0.000 0 0 0.000 0 0 0.000SQLGetDiagRec 1 0.000 0.000 0 0 0.000 0 0 0.000SQLPrepare 1 0.000 0.001 0 0 0.000 0 0 0.000SQLFreeHandle 3 0.000 0.001 0 0 0.000 0 0 0.000SQLAllocHandle 3 0.000 0.002 0 0 0.000 0 0 0.000SQLConnect 1 0.000 0.076 1 342 0.000 1 208 0.002SQLDisconnect 1 0.000 0.000 0 0 0.000 0 0 0.000SQLExecute 10000 0.170 12.139 10000 1230130 0.476 10000 860124 9.204SQLBindParameter 2 0.000 0.000 0 0 0.000 0 0 0.000SQLGetStmtAttr 4 0.000 0.000 0 0 0.000 0 0 0.000SQLSetEnvAttr 1 0.000 0.000 0 0 0.000 0 0 0.000End of function specific statistics report

Network time = (9.214 + 0.476) = 9.69Application time = 0.172

CLI Driver time 12.228 - 9.69 = 2.538 DB2 Time

Download CLITraceParser code: ftp://ftp.software.ibm.com/ps/products/db2/tools/

Here’s the CLI Trace output which has been ran thru the CLI TRACE PARSER which is available for download at the site listed. This summarizes into a much cleaner report.

Note the network time is 9.69 seconds. The time in application is .172. The time that you left application until returned to application is 12.228.

CLITraceParser parses a DB2 Client CLI trace and produces a summary of the trace. The first section, Overall Trace statistics, shows the total trace time and the breakdown of time in the application and in CLI processing (everything outside of the time in the application).

The next section, Network Specific CLI processing time statistics, summarizes the number of sends and receives and the total bytes transmitted. The network CLI processing times include DB2 Connect and DB2 server processing times. The last section, Function specific statistics, shows the number of calls by function, each function's elapsed time in application and CLI, and the related network activity.

You can use the CLITraceParser output to determine very quickly if the elapsed time is being spent in your application or outside the application. It also provides a good summary of which CLI calls are being done the most and which ones are taking the most time to complete. Another factor to examine is the amount of data being sent and received by the application. In a lot of cases, network delay times can be significant, so by reducing the amount of data being transmitted you might improve on

Page 15: DB2 Connect to DB2 z/OS - Problem Determination

15

15

How to Take a DB2 Universal JDBC Driver Trace• Trace as standalone JCC application

• DataSource interface for connection to JCC• DB2DataSource > setTraceLevel > default TRACE_ALL • -javax.sql.DataSource.setLogWriter > TRACE_ALL only available

• DriverManager interface for connections to JCC• DriverManager.getConnection

• Set the traceLevel property in the info parameter or URL parameter• DriverManager.setLogWriter

• Specify trace destination and turn on the trace• Within WebSphere, embed the JCC trace points

• Set JDBC trace properties in WebSphere Application Server • Go to Resources > JDBC Provider > Data Sources > Additional

Properties > Custom Properties.• Set the property: traceLevel(-1 means full trace TRACE_ALL)

• Turn on the trace• Go to Troubleshooting > Logs and Trace > Pick the server > Diagnostic

Trace > Trace Specification: RRA=all=enabled:WAS.database=all=enabled• Specify two trace strings separated by ':', one for WAS resource adaptor

and one for database (JDBC driver)

I1

For more information, refer to:•Understand the DB2 UDB JDBC Universal Driver on http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0512kokkat/•DB2 application development: Tracing with the DB2 Universal JDBC Driver on http://www- 128.ibm.com/developerworks/db2/library/techarticle/dm-0506fechner/•Enabling DB2 Universal JDBC Driver (JCC) tracing on WebSphere Application Server V5 on http://www-1.ibm.com/support/docview.wss?rs=71&context=SSEPGG&q1=DRDA&uid=sw g21181878&loc=en_US&cs=utf-8&lang=en•Application Development Guide: Programming Client Applications for additional information concerning JDBC tracing with the DB2 Universal JDBC Driver (especially Chapter 20. Diagnosing JDBC and SQLJ problems)

Tracing data at the interface between JDBC application and DB2 z/OS or DB2 iseriesor DB2 Linux, Unix, or Windows database provides the developer with information to identify program errors and to optimize database access. JDBC tracing is a method for providing Java application developers with valuable information to aid in their database application development efforts.

• Searching for program logic or initialization errors -- A database connection may fail because of a wrong URL, a query that is expected to be executed once is called again and again, database inconsistencies may occur because of a transaction that is not correctly defined, and so on. In all these cases, it is likely that trace data can be used to uncover the cause of the problem.• Performance tuning -- Performance problems in multi-tier environments are

Page 16: DB2 Connect to DB2 z/OS - Problem Determination

Slide 15

I1 IBM_USER, 4/11/2006

Page 17: DB2 Connect to DB2 z/OS - Problem Determination

16

16

Taking JCC Trace Without Modifying the Application (Option 1)

DB2JccConfiguration.properties

db2.jcc.override.traceFile=c:\\jcc.trc

1. Create plain text file on client a. named DB2JccConfiguration.properties b. with one line of text

2. To enable JCC tracing automatically:c. Add file to the CLASSPATH

A Java Call Control (JCC) trace can be taken without having to modify the application. If you create a plain text file on the client namedDB2JccConfiguration.properties with only one line of text and add it to the CLASSPATH, it will enable JCC tracing automatically:

db2.jcc.override.traceFile=c:\\jcc.trc

This is very useful in cases where you cannot change any of the source code or JCC driver properties (for example, when using a third-party product that internally uses the JCC driver).

You can change the properties file to specify that these properties should override any data source and connection tracing properties. The global properties that are specified in the provided properties file are default values only. If any data source or connection tracingproperties are specified in an application, those values will be used instead. To override the data source and connection tracing properties in the application, you can use the following code:

db2.jcc.override.traceFile=jccTrace.txtdb2.jcc.override.traceFileAppend=truedb2.jdd.override.traceDirectory=c:\\test

Page 18: DB2 Connect to DB2 z/OS - Problem Determination

17

17

1. Create configuration file with trace properties:

2. When Java program is executed, specify the filename via the Option -Djava -Ddb2.jcc.propertiesFile=jcc.properties JccTraceExample2

a. The configuration file is placed in same directory as Java class fileor complete path for configuration file can be specified.

b. Trace level cannot be specified as constant

Taking JCC Trace Without Modifying the Application (Option 2)

db2.jcc.traceDirectory=c:\\tempdb2.jcc.traceFile=tracedb2.jcc.traceFileAppend=falsedb2.jcc.traceLevel=-1

jcc.properties

To control tracing without changes to the source code, create a separate configuration file containing the trace properties.

DB2 JDBC trace propertiesdb2.jcc.traceDirectory=c:\\tempdb2.jcc.traceFile=tracedb2.jcc.traceFileAppend=falsedb2.jcc.traceLevel=-1

There are no naming conventions for this configuration file. The filename is specified via the option -D when the Java program is executed. For example, if the configuration file is named jcc.properties, the program call looks like this.

DB2 JDBC trace properties filejava -Ddb2.jcc.propertiesFile=jcc.properties JccTraceExample2

In this case, the configuration file is placed in the same directory as the Java class file. Otherwise a complete path for the configuration file can be specified too.

If a configuration file is used, the trace level cannot be specified as constant, instead the corresponding integer values have to be used, for example -1 for TRACE_ALL or 6 for TRACE STATEMENT CALLS | TRACE RESULT SET CALLS (in this

Page 19: DB2 Connect to DB2 z/OS - Problem Determination

18

18

FeaturesTrace time analysis

– Application processing time– JCC processing time– Network processing time– Time analysis for overall trace– Time analysis for overall trace on per connection basis– Time analysis per JCC function call

Network flow analysis– Bytes sent or received during flush/fill– Time taken during flush/fill– Total number of flows– Network flow analysis on a per JCC function call basis

Error report identifying– Prints the entire exception– The line number of the error

Automatic extraction of multiple traces from a single file– For example, if there are many connections in a single trace file then that many numbers of trace

outputs will be generated.– To maintain the relationship between connection and respective method calls unique thread name

has taken into consideration.

Input = Valid JCC trace file Output = One report file which may contain multiple trace reports depending upon different connections information found in a given trace file

JCC Trace Parser

For some applications, the majority of the elapsed time is spent in the application, not in DB2. In this case, tuning your DB2 server is a waste of time. Application and in JCC times can be summarized using a Java tool called JCCTraceParser.

You want to get the file JCCTraceParser.zip. The README.TXT file has information on installing and using the tool.

Files included in JCCTraceParser.zip====================================JCCTraceParser.sh - a script to run JCCTraceParser on Unix.JCCTraceParser.bat - a script to run JCCTraceParser on MS-DOS.JCCTraceParser.jar - an archive containing all the classes used in JCC Trace Parser.Readme file for JCC Trace Parser

Page 20: DB2 Connect to DB2 z/OS - Problem Determination

19

19

JCCTrace Report Generated by JCCTraceParserOverall Trace Statistics for Connection: #1 ThreadName: ORB.thread.pool : 3========================================================

208 methods called in trace.15031.000 mili seconds total trace time.2177.000 mili seconds total trace time per connection.

2093.000 mili seconds spent for application processing.84.000 mili seconds spent for JCC processing.

Network Specific JCC processing time statistics========================================================

18 network flows sent 4256 bytes, and received 4384 bytes, and consumed a total network time of

72.000000 mili seconds.End of overall trace statistics report

Function specific statistics========================================================

Timing Network Information

Function Name Total Application JCC Flows SentBytes ReceiveBytesNetworkTime-------------------------------------------------------------------------------------------------------------setMaxRows 14 N/A N/A N/A N/A N/A N/A setLong 27 N/A N/A N/A N/A N/A N/A close 14 N/A N/A N/A N/A N/A N/A getString 38 2.000 0.000 0 0 0 0.000 rollback 4 2086.000 12.000 4 0 128 10.000 setAutoCommit 2 N/A N/A N/A N/A N/A N/A setString 9 N/A N/A N/A N/A N/A N/A prepareStatement 1 0.000 0.000 0 0 0 0.000 next 23 2.000 0.000 0 0 0 0.000 setObject 36 N/A N/A N/A N/A N/A N/A wasNull 6 0.000 0.000 0 0 0 0.000 executeQuery 14 3.000 72.000 14 4256 4256 62.000 getTimestamp 2 0.000 0.000 0 0 0 0.000 getLong 18 0.000 0.000 0 0 0 0.000

End of function specific statistics report

2093 time in Application84 JCC – 72 Network = 12 in DB2

JCCTraceParser parses a DB2 Client JCC trace and produces a summary of the trace. The first section, Overall Trace statistics, shows the total trace time and the breakdown of time in the application and in JCC processing (everything outside of the time is in the application).

The next section, Network Specific JCC processing time statistics, summarizes the number of sends and receives and the total bytes transmitted. The network JCC processing times include DB2 Connect (DB2 Connect processing time is included only for a Type 2 JCC trace - not for a Type 4 JCC trace since Type 4 does not need to connect through DB2 Connect) and DB2 server processing times.

The last section, Function specific statistics, shows the number of calls by function, each function's elapsed time in application and JCC, and the related network activity.

You can use the JCCTraceParser output to determine very quickly if the elapsed time is being spent in your application or outside the application. It also provides a good summary of which JCC calls are being done the most and which ones are taking the most time to complete. Another factor to examine is the amount of data being sent and received by the application. In a lot of cases, network delay times can be significant, so by reducing the amount of data being transmitted, you might improve on performance.

Page 21: DB2 Connect to DB2 z/OS - Problem Determination

20

20

DB2 ServerUniv. Driver SQLJ/JDBCJava App.

prepareStatement/executeUpdate

executeUpdate

executeUpdate

Java API for application monitoring– DB2SystemMonitor monitor=

((DB2Connection)conn).getDB2SystemMonitor();– monitor.enable(true);– monitor.start(com.ibm.db2.jcc.DB2SystemMonitor.RESET_TIMES);– monitor.stop();– monitor.getServerTime()– monitor.getNetworkIOTime()– monitor.getCoreDriverTime()– monitor.getApplicationTime()

See z/OS manual: SC18-7414Redbook:

SG24-6435

Client Tools –Java Application Monitoring

There is a Java API for application monitoring built into the IBM DB2 Driver for JDBC and SQLJ as of V8 Fix pack 4 of DB2 for Linux, UNIX, and Windows. The monitor will tell you how much time was spent in:

• Application time - The time between the start() and stop() calls• Core driver time - The time spent in the JAVA driver; this includes network I/O time and server time• Network I/O time - The time used to flow the DRDA protocol stream across the network • Server time - The time spent in the DB2 server itself

This information can be obtained by turning on the corresponding Java API at the Java client. The monitor itself can be dynamically turned on or off with the right API.

Example:import com.ibm.db2.jcc.DB2Connection;import com.ibm.db2.jcc.DB2SystemMonitor;...DB2SystemMonitor monitor = conn.getDB2SystemMonitor();monitor.enable(true);monitor.start(DB2SystemMonitor.RESET_TIMES);

Page 22: DB2 Connect to DB2 z/OS - Problem Determination

21

21

Client Tools –Visual Explain Output

The Visual Explain output consists of a graphic representation of the SQL access plan on the right side of your display. Different geometric shapes are used to indicate different types of objects. A rectangle represents a table, while a triangle represents an index. The hexagon shape denotes an operation. The flow of the access plan is from bottom to top. In the above graphic, a join operation is being performed. The table feeding the join from the left will be the outer table and the table feeding the join from the right will be the inner table.

One of the objects will be highlighted. Information about the highlighted object will be on the left side of the display. In this case the object is the last object in the access plan and represents a summary of the SQL statement. The statistical information shows the estimated CPU cost to be 27 milliseconds and a service unit cost of 308. Note that when you select one of the statistic lines, an explanation of the statistic is displayed in the Selection details window. The statistics vary by type of object, with tables and index objects showing runstats statistics collected on the table or index.

You want to identify which SQL statements have the highest service unit costs. These statements can then be analyzed to see if you can improve on their performance. If the application is using static SQL, the package can be explained and the most expensive SQL statements can easily be identified. If the application is using dynamic SQL and is a CLI/ODBC or Java application, the CLI and JCC traces can identify which SQL statementsare taking the longest to run. The SQL text could then be extracted from the CLI trace and submitted directly to Visual Explain.

Page 23: DB2 Connect to DB2 z/OS - Problem Determination

22

22

DB2 Connect SystemDB2 Instance

Net

wor

k P

roto

col

Ada

pter

DBMCFG

LAN

Net

wor

k Pr

otoc

ol

DB2Agent

DB2Agent

DB2Agent

DB2Agent

Ada

pter

LAN

DCSDirectory

NodeDirectory

DatabaseDirectory

Inbound from client Outbound to host

Listener

Data Flow - DB2 Connect

Returning to our Data Flow of DB2 Connect diagram and our requirement to isolating the problem, lets see what we can do to isolate the data flow through the DB2 Connect machine.

Page 24: DB2 Connect to DB2 z/OS - Problem Determination

23

23

General help Help for all options,but no examples

More advancedexamples

All help, usage,and examples

Help for a specific option Displays various examples Usage notes and restrictions

Provides the ability to filter and format db2diag.log messages

Dozens of options available - run the following for details:

db2diag -h [ <option> | brief | examples | tutorial | notes | all ]

Examples:db2diag -filter instance=DB2 -time 2005-03-08-17.42.35.164191

db2diag -gi "level=severe" -H 1d

db2diag Tool

Examples:• To display all severe error messages produced by the process with the process ID (PID) 52356 and on node 1, 2 or 3, enter:

db2diag -g level=Severe,pid=952356 -n 1,2,3

• To display all messages containing database SAMPLE and instance aabrashk, enter:db2diag -g db=SAMPLE,instance=aabrashk

• To display all severe error messages containing the database field, enter:db2diag -g db:= -gi level=severe

• To display all error messages containing the DB2 ZRC return code 0x8 040055, and the application ID G916625D.NA8C.068149162 29, enter:

db2diag -g msg:=0x8 040055 -l Error | db2diag -gi appid^=G916625D.NA

• To display all messages not containing the LOADID data, enter:db2diag -gv data:=LOADID

• To display only logged records not containing the LOCAL pattern in the application ID field, enter:

db2diag -gi appid!:=local or db2diag -g appid!:=LOCAL

Page 25: DB2 Connect to DB2 z/OS - Problem Determination

24

24

Examples:– List agents under the current instance, repeating every 10 seconds:

db2pd -agents –repeat 10

– Shows memory sets and operating system details db2pd -inst -memsets -osinfo

– Shows subsystems currently being used for workload balancing in sysplex environmentdb2pd -sysplex db=DSND

- Shows active and delayed database manager config valuesdb2pd -dbmcfg

– Developer Works article:http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0504poon2

db2pd Command Examples

The db2pd utility retrieves information from the DB2 for Linux, UNIX, and Windows memory sets.

Authorization: One of the following:• On Windows operating systems, the sysadm authority level.• On UNIX operating systems, the sysadm authority level.

You must also be the instance owner. Required connection: There is no minimum connection requirement. However, if a database scope option is specified, that database must be active before the command can return the requested information.

The db2pd utility retrieves various statistics, internal metadata, and snapshot information from a running DB2 instance. Run "db2pd -help" for options. It is completely non-intrusive and since it doesn't acquire latches, it is a Very fast retrieval and doesn't impact the engine in any way. It can be run even if the system is hung.

Please refer to the Developer Works article, http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0504poon2, for more information.

Page 26: DB2 Connect to DB2 z/OS - Problem Determination

25

25

Shows detail information for each application

DB2 Connect – db2 LIST DCS APPLICATIONS EXTENDED

The Status Change Time is only recorded if UOW switch on. The LIST DCS APPLICATIONS EXTENDED command provides more detailed information about each of the application connections. The output shows:

•Client Application ID - The name is in three parts, separated by periods. The first part of the name identifies the client host. If the connection from client to DB2 Connect is TCP/IP, the first part of the name is the IP address of the client, in hex. Every pair of hexnumbers represents the decimal value in the IP address. For example, the first part of the Client Application ID in our example is C0A801F8. If we break this into hex pairs, we get C0.A8.01.F8. If each pair of numbers is converted to decimal, we get the IP addressof the client: 192.168.1.248.

The second position is the client's port number used for the connection, in hex. If the first or second parts of the Client Application ID start with a value of G-P (like the PB11 value above in the second part of the ID), the G-P value is converted to 0-9 respectivelyto obtain the real hex value. So in the above example, the P is converted to a 9, and then the hex value 9B11 is converted to a decimal value of 39697 for the port number.

The third position is a unique identifier generated for this client connection. It is based on the timestamp of when the client connection was established, but because there is no guarantee it will be unique for example if you have

Page 27: DB2 Connect to DB2 z/OS - Problem Determination

26

26

Snapshot Options

GET SNAPSHOT FOR DBMGET SNAPSHOT FOR ALL DCS DATABASESGET SNAPSHOT FOR ALL DCS APPLICATIONS

Use Snapshot Monitor to displaydetail information

Monitor Switches for DB2 Connect

– STATEMENT– UOW

DB2 Connect – Snapshot DCS Connections

You can use the snapshot monitor with DB2 Connect Enterprise Edition to monitor remote client connections.

To monitor local clients, the DB2CONNECT_IN_APP_PROCESS registry variable must be set to NO.

The snapshot monitor is always active, but if you want more detailed information you need to turn on the STATEMENT and UOW switches. This can be done for a session by issuing the DB2 UPDATE MONITOR SWITCHES USING STATEMENT ON UOW ON command or permanently by updating the DBM CFG file.

You must have SYSADM, SYSCTRL, SYSMAINT, or SYSMON authority to use the SNAPSHOT command.There are five command formats that are applicable to DB2 Connect:• GET SNAPSHOT FOR ALL DCS DATABASES• GET SNAPSHOT FOR ALL DCS APPLICATIONS• GET SNAPSHOT FOR DCS APPLICATION APPLID appl_id• GET SNAPSHOT FOR DCS APPLICATION AGENTID appl_handle• GET SNAPSHOT FOR DCS DATABASE ON db-alias• GET SNAPSHOT FOR DCS APPLICATIONS ON db-alias

In addition instance information can be retrieved by executing the command:

Page 28: DB2 Connect to DB2 z/OS - Problem Determination

27

27

DB2 Connect –db2 Get Snapshot DBM

A snapshot at the database manager level provides statistics for the active database manager instance. If there is no instance attachment, a default instance attachment is created.

Some of the key elements to look for are:• Instance name - The name of the database manager instance for which the snapshot was taken.• Database manager status - The current status of the instance of the database manager.• Product name - Details of the version of the DB2 instance that is running.• Service level - This is the current corrective service level of the DB2 instance.• Start Database Manager timestamp - The date and time when the database manager was started using the db2start command.• Snapshot timestamp - The date and time when the database system monitor information was collected.• Remote connections to db manager - The current number of connections initiated from remote clients to the instance of the database manager that is being monitored.• Remote connections executing in db manager - The number of remote applications that are currently connected to a database and are currently processing a unit of work within the database manager instance being monitored.

Page 29: DB2 Connect to DB2 z/OS - Problem Determination

28

28

db2 get snapshot for dcs database on tdsnl

DB2 Connect – Snapshot DCS Database

A snapshot at the database level provides information on database connections, performance, errors and throughput of SQL requests.Some of the key elements to look for are:

• Most recent elapsed time to connect - The elapsed time between the start of connection processing and actual establishment of a connection, for the most recent DCS application that connected to this database. Use this element as an indicator for the time it takes applications to connect to a particular host database.• Most recent elapsed connection duration - The elapsed time that the DCS application which was most recently disconnected from this host database was connected.• Host response time - The sum of the elapsed times for all the statements that were executed for a particular database. Use this element with Outbound Number of Bytes Sent and Outbound Number of Bytes received to calculate the outbound response time (transfer rate): ((outbound bytes sent + outbound bytes received) / host response time).• Number of SQL statements attempted - The number of SQL statements that have been attempted since the database activated or the last reset monitor switches command was issued. Use this to measure the rate of SQL activity against a host database. By taking multiple snapshots and calculating the difference between number of SQL statements attempted and dividing by the elapsed time between the snapshots, you can get a rate at which SQL statements are being processed at the DB2 Connect Server. • Failed statement operations - The number of SQL statements that were

d b f il d f b ff d b h i h dl f il d

Page 30: DB2 Connect to DB2 z/OS - Problem Determination

29

29

db2 get snapshot for dcs applications

DB2 Connect – Snapshot DCS Applications (1 of 2)

Host response time is sum of elapsed times for all statements that were executed for a particular application. Time spent on gateway processing is time in seconds/microseconds at DB2 Connect server to process an application request. Idle time is number of seconds since an application has issued any requests to the server.

An application snapshot provides information on activity on a specific client application-DB2 Connect Agent-DDF thread connection.

Some the of key elements to monitor are:• Application status - The status of a DCS application at the DB2 Connect Server. The values can be:

- connect pending - outbound - The application has initiated a database connectionfrom the DB2 Connect server to the host database, but the request has notcompleted yet.- waiting for request - The connection with the host database has been established, and the DB2 Connect agent is waiting for an SQL statement from the client application.- waiting for reply - An SQL statement has been sent to the host d t b d th t i iti f l

Page 31: DB2 Connect to DB2 z/OS - Problem Determination

30

30© Copyright IBM Corporation 2006

DB2 Connect – Snapshot DCS Applications (2 of 2)

f the UOW monitor switch is turned on, an application snapshot will return additional information about the most recent unit of work (transaction). Key fields to monitor are:

• UOW start timestamp - The date and time that the unit of work first required database resources. The time is when the first SQL statement of a unit of work is sent to the host for the most recent transaction. This time is used to calculate how long transactions are taking and to see if any applications have not issued a commit or rollback for a long time. • UOW stop timestamp - The data and time that the most recent unit of work completed, which occurs when a commit or rollback is issued. By subtracting UOW start timestamp from UOW stop timestamp, you can tell how long transactions are taking to complete, or to see if an application has failed to issue a commit or rollback for an extensive period of time.• Elapsed time of last completed UOW - The elapsed time of the most recently completed unit of work in seconds and microseconds. The timing is tracked by DB2 Connect solely based on its own processing. This elapsed time starts counting when DB2 Connect starts the new unit of work. The counting stops when DB2 Connect finishes the unit of work, which includes processing the commit/rollback reply from the DB2 for z/OS server.

If the STATEMENT monitor switch is turned on, an application snapshot will return additional information about the most recent SQL statement. Key fields to monitor are:

Page 32: DB2 Connect to DB2 z/OS - Problem Determination

31

31

DB2 z/OSDB2 Connect Network

4.

1.

2.

Time in seconds

Element name in output

1. Elapsed time of last completed stmt

2. Host response time

3. Host execution elapsed time

4. Time spent on gateway processing

Element name/identifier in manual

Most recent statement elapsedtime/stmt_elapsed_time

Host response time/host_response_time

Statement execution elapsedtime/elapsed_exec_time

Elapsed time spent on DB2 Connectgateway/gw_exec_time

Analyzing DCS applications snapshot

3.

Elapsed time of last completed stmt contains the highest value of all three elements as it represents all time spent processing a statement inside DB2 Connect.

This includes all time spent on the network communications between it and the host, that is, Host response time.

The next highest value is Host response time which represents only all time spent on the network communications between it and the host. As such, this time includes time spent processing the statement on the host, that is, Host execution elapsed time.

The lowest value is Host execution elapsed time as it represents only the time spent for processing a statement on the host as reported by the host DB2 back to DB2 Connect.

At the DCS statement level, host_response_time or Host Response Time, monitor element is the elapsed time between the time that the statement was sent from the DB2 Connect gateway to the host for processing and the time when the result was received from the host. At DCS database and DCS application levels, it is the sum of the elapsed times for all the statements that were executed for a particular application or database.

Time spent on gateway processing is the time in seconds and microseconds at the DB2 Connect server to process an application request (since the connection was established).

At the application level, this is the cumulative time spent processing requests. At the statement level, this is the time to process the last SQL statement. This element can be used to determine how much time is spent within the DB2 Connect server. An average time per SQL statement can be calculated using the formula: (Time spent on gateway processing / number of SQL statements attempted).

Page 33: DB2 Connect to DB2 z/OS - Problem Determination

32

32

db2drdat - DRDA Trace

db2drdat

path

-t=tracefile

on

off

-p=pid

-l=length-r-s

-f

1. -r - TRACE RECEIVE BUFFERS 2. -s - TRACE SEND BUFFERS

TYPE OF DRDAREPLY/OBJECT

TYPE OF DRDAREQUEST

DB2 Connect – db2drdat Command

The db2drdat trace utility provides a record of the data interchanged between the DB2 Connect server (on behalf of an application client) and a DB2 for z/OS subsystem. This is an I/O trace of the DRDA protocol flow between the agent on the DB2 Connect server and the thread on the DB2 for z/OS system, and also between the agent and the client system if the client is at V8 (thus it would also use DRDA to communicate with the DB2 Connect server). No communication protocol information is captured in this trace.

The trace can be used for problem determination, by displaying exactly what DRDA data is being sent and received, and performance tuning. For performance tuning, each entry is time stamped which allows us to determine the elapsed time between data sent and the response received.

The db2drdat DRDA trace allows the user to capture the DRDA data stream exchanged between a DRDA Application Requestor (AR) and the DRDA Application Server (AS).

Although this tool is most often used for problem determination, by determining how many sends and receives are required to execute an application, it can also be used for performance tuning in a client/server environment.

Page 34: DB2 Connect to DB2 z/OS - Problem Determination

33

33

Syntaxping db_alias request packet_size response packet_size [ n times ]

Example:

db2 connect to tdb2390 user <id> using <pswd>db2 ping tdb2390 request 100 response 200 2 times

Elapsed time: 26754 microsecondsElapsed time: 27352 microseconds

db2 ping host

Client DB2 Connect

Response Time

DB2 z/OS Host

DB2

TCP/IP

USS

DDF

Response Time

Network - DB2 PING Command

DB2 for Linux, UNIX, and Windows Version 7 Fix pack 2 introduced the db2 ping command. This command tests the network response time of the underlying connectivity between a client and a database server where DB2 Connect is used to establish the connection. No special authority is required to issue the command. As of V8, the db2 ping command supports the specification of a request and response packet size.

The command syntax is:

db2 ping dbalias REQUEST packet_size RESPONSE packet_size number_of_times

where:dbalias - Specifies the database alias for a DRDA server that the ping is being sent to.

REQUEST packet_size - Specifies the size, in bytes, of the packet to be sent to the server. The size must be between 0 and 32767 inclusive. The default is 10 bytes. This option is only valid on servers running DB2 for Linux, UNIX, and Windows Version 8 or later, or DB2 for z/OS Version 8 or later.

RESPONSE packet_size - Specifies the size, in bytes, of the packet to be returned back to client The size must be between 0 and 32767 inclusive The

Page 35: DB2 Connect to DB2 z/OS - Problem Determination

34

34

> netstat -e -n -s -p tcpInterface Statistics

Received Sent Bytes 68180872 3067496 Unicast packets 50847 40949Non-unicast packets 80022 384Discards 0 0 Errors 0 17Unknown protocols 20302

TCP Statistics

Active Opens = 1111Passive Opens = 0Failed Connection Attempts = 27Rest Connection = 789Current Connections = 7Segments Received = 38814 Segments sent = 29613Segments Retransmitted = 31

Network –TCP/IP NETSTAT - Statistics

For Windows platforms:Network statistical information can be displayed by using the NETSTAT command with the ESP options. In this example, the command

netstat -ensp tcp is issued to display Ethernet interface statistics and per protocol statistics for tcp in numerical form.

We are displaying network interface statistics and TCP statistics. DB2 Connect users, both inbound and outbound, will only use TCP packets.

The Interface Statistics information is for all protocols and can be used to develop transmission rates. By taking successive displays, a data rate for received and sent rates can be computed. This could be used to track usage and trends. There is also an Error value shown. If the percentage of errors is high (over 1 to 2 percent), then this needs to be investigated.

Under TCP Statistics, you can get a rate at which TCP connections are occurring. If Segments Retransmitted is high (1 to 2 percent) to Segments Sent, then this could indicate a problem within the network.

For UNIX systems:The netstat -v command shows network statistics for each network adapter. You can

thi i f ti t d t i t k d d l t d t t h

Page 36: DB2 Connect to DB2 z/OS - Problem Determination

35

35

z/OS System

ZPARMSCDB

Net

wor

k Pr

otoc

ol

OSA

LAN

BSDS

UN

IX S

yste

m S

ervi

ces

DD

F

DB

M1

MS

TR

IRLM

Comm Cntlr

RACF

Data Flow - z/OS

Returning to our Data Flow of DB2 Connect diagram and our requirement to isolating the problem, lets see what we can do to isolate the data flow through the z/OS machine.

Page 37: DB2 Connect to DB2 z/OS - Problem Determination

36

36

CMTSTAT(I or A)

# of DBATsPooled

Number ofConnections

InactiveCurrent #of DBATs

Display DDF Detail

The DISPLAY DDF command is a DB2 for z/OS command that displays information regarding the status and configuration of DDF, as well as statistical information regarding connections or threads controlled by DDF. This command can be issued from a z/OS console, a DSN session under TSO, or a DB2I panel (DB2 COMMANDS). DB2 commands issued from a z/OS console are not associated with any secondary authorization IDs.

To execute this command, the privilege set of the process must include one of the following:

• DISPLAY privilege• SYSOPR, SYSCTRL, or SYSADM authority

The DETAIL option displays additional configuration and statistical information.

The DISPLAY DDF command displays the following output:• STATUS - The operational status of DDF. • LOCATION - The location name of DDF. • LUNAME - The fully qualified logical unit name (LUNAME) of DDF. • GENERICLU - The fully qualified generic LUNAME of DDF.• IPADDR - The IP address of the z/OS system that DDF is running on.• TCPPORT - The SQL listener port used by DDF. • RESPORT - The resync listener port used by DDF, when involved in two-phase commit processing.

Page 38: DB2 Connect to DB2 z/OS - Problem Determination

37

37

>>DISPLAY THREAD_______________________________________________>| <_,_____________________________| ||_(______connection-name_________|____) | | |_partial-connection*___| ||_(_*_)__________________________________|

>______________________________________________________________>| ACTIVE____ ||_TYPE(_|_INDOUBT_____|_)__|| |_*___________|| |_INACTIVE____|| |_POSTPONED___|

>______________________________________________________________>| <_,________________________| |_DETAIL_||____LOCATION(____location-name__|__)__|| | |partial-location*_| || |_*_____________________|| <__,_______________________| |____LUWID___(_____luwid__________|__)_|| |_partial-luwid*__|| |_token___________|

DB2 for z/OS – DISPLAY THREAD Command Syntax

The DB2 for z/OS command DISPLAY THREAD displays current status information about DB2 for z/OS threads. A DB2 for z/OS thread is either an allied thread, a database access thread, or a parallel task thread. Threads can be active, inactive, indoubt, or postponed.

Distributed threads are those threads that have a connection with a remote location (active or inactive) or that had a connection with a remote location (indoubt). An allied thread and a parallel thread can be distributed or nondistributed; a database access thread is always distributed.

For most applications using DB2 Connect, the thread will be a distributed thread (DBAT). If an application is using a stored procedure however, an allied thread is used for the stored procedure.

The privilege needed to display thread information is DISPLAY privilege or SYSOPR, SYSCTRL, or SYSADM authority. You can limit the threads you display by specifying the TYPE of thread, or the LOCATION, or for a specific LUWID. The LOCATION name is the IP address of the DB2 Connect system. The LUWID is the Host application ID from a DB2 LIST DCS APPLICATIONS command.

The DETAIL option displays additional information about each thread. A thread is associated with a DB2 Connect agent, which is associated with a client application. When an application is processing a transaction (unit of work), the thread is ACTIVE. Immediately following a COMMIT or ROLLBACK the thread goes INACTIVE This

Page 39: DB2 Connect to DB2 z/OS - Problem Determination

38

38

Display Thread Detail

The above graphic represents the output from a DISPLAY THREAD (*) TYPE(INACTIVE) DETAIL command.

The following are key items to look for on the display:• NAME value of SERVER - A 1 to 8-character variable representing the connection name used to establish the thread. For distributed database access threads using application-directed access from a non-DB2 for z/OS requester, this variable displays the constant SERVER.• ST value of R2 - A distributed thread is performing a remote access on behalf of a request from another location. The thread is currently a Type 2 inactive thread and is waiting for an agent to become available to process.• A - The A column represents the active indicator status of the thread. A value of asterisk is displayed if the thread is active within DB2. The value is blank otherwise.• REQ - A wraparound counter showing the number of requests received bythis thread. If this counter is increasing, then you know that this thread is performing work.• ID - The application name passed to the thread at connection time.• AUTHID - The primary authid of the end user making the connection.• DISTSERV value of PLAN - A 1 to 8-character variable representing the plan name associated with the thread. For distributed database access threads using application-directed access from a non-DB2 for z/OS requester, this variable displays the constant DISTSERV. • V445 - The LUWID (Logical Unit f W k ID tifi ) i d t thi th d Thi th H t

Page 40: DB2 Connect to DB2 z/OS - Problem Determination

39

39

Who is holding the lock?

DBNAMECF63T23

TSNAME

CF63T000

Select dbname , tsname from sysibm.systableswhere name=‘ACCT2' and creator = 'ADMIN'

DB2 for z/OS: Display Database Locks

The DISPLAY DATABASE command displays information about specific DB2 for z/OS databases, table spaces, tables in segmented table spaces, LOB table spaces, index spaces within a database, indexes on auxiliary tables, and partitions of partitioned table spaces and index spaces.

This command can be used to see what resources are being used by an application and if any locks are being held and by which application.

The DISPLAY DATABASE LOCKS output shows locking information for table spaces, index spaces, and partitions. The key fields are:

• NAME - The table space name, index space name, or table object ID.• TYPE - A TS for table space, IX for index, or TB for table.• PART - The partition number. It is blank for a simple table space or index space.• STATUS - Status of object. Will normally show RO - the table space, table space partition, index space or index space partition is started for read-only activity, or RW - the table space, table space partition, index space or index space partition is started for read and write activity.• CONNID - A connection identifier for the thread. For DBAT threads using application-directed access from a non-DB2 for z/OS requester, this field contains the constant SERVER.• CORRID - The name of the application holding the connection.

Page 41: DB2 Connect to DB2 z/OS - Problem Determination

40

40

AVERAGE APPL(CL.1) DB2 (CL.2)------------ ---------- ----------ELAPSED TIME 24:59.7823 3:50.24315NONNESTED 24:59.7823 3:50.24315STORED PROC 0.000000 0.000000UDF 0.000000 0.000000TRIGGER 0.000000 0.000000

CPU TIME 1:05.93530 40.218570AGENT 1:05.93530 40.218570NONNESTED 1:05.93530 40.218570STORED PRC 0.000000 0.000000UDF 0.000000 0.000000TRIGGER 0.000000 0.000000PAR.TASKS 0.000000 0.000000

SUSPEND TIME N/A 1:18.03509AGENT N/A 1:18.03509PAR.TASKS N/A 0.000000

NOT ACCOUNT. N/A 1:51.98949DB2 ENT/EXIT N/A 213306EN/EX-STPROC N/A 0.00EN/EX-UDF N/A 0.00

SQL DML TOTAL-------- --------SELECT 50974INSERT 30949UPDATE 13029DELETE 1292

DESCRIBE 0DESC.TBL 0PREPARE 0OPEN 5670FETCH 15100CLOSE 5670

DML-ALL 122684

Time in DB2 = 3:50.24315+(1:05.93530-40.218570) = 4:15.95988Time outside of DB2 = 24:59.7823-4:15.95988 = 20:43.82242

--- DISTRIBUTED ACTIVITY -------REQUESTER : 10.10.10.10COMMITS(1) RECEIVED: 4738SQL RECEIVED : 101914MESSAGES SENT : 106653MESSAGES RECEIVED : 106653BYTES SENT : 12943505BYTES RECEIVED : 21614937MESSAGES IN BUFFER : 9430ROWS SENT : 13326BLOCKS SENT : 5670

Using Accounting Trace Information

This is an accounting trace of a recent performance problem. Even though the time in the DB2 server is about 14%, there is an indication in this information that the entire platform has a problem. Can you tell what it is? Look at the NOT ACCOUNT. time in DB2. It is almost half the total time in DB2. This indicates a serious delay waiting for processing resources which can equate to either there are other more important tasks in the same LPAR or, with floating processor resources, there are other more heavily weighted LPARs taking precedence on the overall system. The latter was the case here.

The number of messages sent in this case is the total of the SELECT (singleton), INSERT, UPDATE, DELETE, and OPEN DMLs processed plus the number of commits. This is an active thread accounting trace report.

Finally, if the application was dynamic, then PREPAREs would be part of the inbound message usually chained with a DESCRIBE INPUT (JDBC), and INSERT/UPDATE/DELETE/OPEN. If a DESCRIBE was chained with a PREPARE, thenthe other kinds of DML would be separate messages.

Distributed threads always fall under the NONNESTED category or element in the trace output. So in the above output the Class 2 NONNESTED ELAPASED TIME is the amount of time spent processing in DB2 for this thread.

Th Cl 1 NONNESTED CPU TIME i th CLASS 2 NONNESTED CPU

Page 42: DB2 Connect to DB2 z/OS - Problem Determination

41

41

z/OS Host

DB2

TCP/IP

USS

DDF

Class 1Nonnested CPU -Class 2Nonnested CPU -

Class 1 Elapsed - Class 2 Nonnested Elapsed

Class 1 Elapsed

Class 2 Nonnested Elapsed Time

DB2 for z/OS Timings

Class 2 nonnested elapsed time measures the time spent processing in the DB2 for z/OS subsystem, including wait time.

Class 1 elapsed time measures the time spent processing in the DB2 for z/OS subsystem and outside DB2. This time reflects the total elapsed time since the application connected to the database.

The time just in DDF can be computed by taking the Class 1 nonnested CPU time and subtracting the Class 2 nonnested CPU time. DDF processing is all CPU time.

The time spent outside the DB2 for z/OS subsystem can be computed by taking Class 1 elapsed time and subtracting Class 2 nonnested elapsed time. Then by subtracting the time in DDF, all of DB2 for z/OS can be eliminated.

You are not looking for any specific values. Calculate percentages of Class 1 time to see where most of the time is being spent. Then investigate that component.

Page 43: DB2 Connect to DB2 z/OS - Problem Determination

42

42

DB2 ConnectDB2 Connect

Application

SQL

SQL

ClientClient

Agent

Agent?

Thread?

XX

DB2 for z/OSDB2 for z/OS

Set TCP/IP KEEPALIVE Interval– Network Setting– TCPKPALV ZPARM

z/OS - TCP/IP KEEPALIVE Interval

TCP/IP has a configurable option to periodically send a keepalive packet over a connection if there has been no activity on that connection for some specified period of time. Since TCP/IP keepalive support is optional, not all applications will respond to the keepalive packet. DB2 for z/OS, however, does recognize the TCP/IP keepalive packet.

It is recommended that TCP/IP keepalive be configured and the keep alive interval be set to 5 minutes or less. This will allow lost connections to be detected either because of a network outage or a system crash. Resources being held by an application can then be released.

To enable TCP/IP keepalive and set a keep alive interval, the client, the DB2 Connect, and the DB2 for z/OS systems must all be configured (assuming TCP/IP is being used between all systems).

On the z/OS system, the keep alive enablement and interval setting can be set within TCP/IP to cover all applications. In the TCP/IP PROFILE file, there is a parameter called KEEPALIVEOPTIONS in the TCPPARMS(PROFILE) on z/OS. One of the keywords in this option is INTERVAL, which sets the keep alive interval in terms of seconds. Check with your z/OS TCP/IP person to find out what was used on your system. To override the default KEEPALIVE setting for DB2 for z/OS, you can set a TCP/IP KEEPALIVE value during installation on the DSNTIP5 installation panel. You can also modify the TCPKPALV ZPARM value. Possible settings are:

• ENABLE - Do not override the TCP/IP KEEPALIVE configuration value.

Page 44: DB2 Connect to DB2 z/OS - Problem Determination

43

43

Operating System

Parameter wait time before probing the connection

Parameter interval between retry probes

Parameter maximum retry probes

Unit of measure

AIX tcp_keepidle tcp_keepintvl n/a half-seconds

HP-UX 11i tcp_timewait_interval tcp_keepalive_interval tcp_keepalives_kill (1) milliseconds

Linux tcp_keepalive_time tcp_keepalive_intvl tcp_keepalive_probes seconds

Solaris tcp_time_wait_interval tcp_keepalive_interval n/a milliseconds

Windows KeepAliveTime KeepAliveInterval TepMaxDataRetransmissions milliseconds

Note: (1): tcp_keepalives_kill cannot be modified on HP. It is set to 1.

LUW - TCP/IP KEEPALIVE Settings

TCP/IP uses operating system keepalive parameters to detect when the client or server side of an idle connection is no longer responding. DB2 sets the TCP/IP keepalive setting on both the client and server by default.

You may wish to decrease the keepalive parameters on the server side machine to improve detection of client failures, or decrease the keepalive parameters on the client side machine to improve detection of server failures. Alternatively, you may wish to increase the keepalive parameters on the server side machine to prevent client disconnects on idle connections, or increase the keepalive parameters on the client side machine to prevent server disconnects on idle connections.

Each keepalive parameter comes with a default setting; many parameters are configurable. In general, the parameters:

• Determine how long to wait before probing the idle connection. On most platforms, the default is 2 hours.• Determine how long to wait before retrying the probe after initial failure to respond.• Determine the maximum number of times to retry the probe.

Modifying any keepalive parameter may involve trade-offs and affects applications on your entire machine. For example, changing these parameters affects rlogin, ssh, and telnet.

Page 45: DB2 Connect to DB2 z/OS - Problem Determination

44

44

RegistryVariables

DB2CHECKCLIENTINTERVAL - Server

DB2TCP_CLIENT_CONTIMEOUT - Client

DB2TCP_CLIENT_RCVTIMEOUT - Client

Registry Variables –Detect if Client or Server Alive

• See the Communications variables topic in the product Information Center at:• http://publib.boulder.ibm.com/infocenter/db2luw/v8/

index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0005660.htm

DB2 registry variables to help detect when a client or server is not responding.

If you do not wish to adjust the keepalive operating system settings, DB2 has additional registry variable settings that you can use to help detect some situations where a client or server is not responding.

DB2CHECKCLIENTINTERVAL - Adjusting this variable on the server determines how quickly the DB2 server can detect a client-server connection has been terminated (for example, a client kills a DB2 application). Setting this variable does not help with situations where the client is not responding because of an abnormal machine termination where TCP cannot respond (operating system keepalive values must be adjusted to handle this condition).

DB2TCP_CLIENT_CONTIMEOUT - Adjust this variable on a client to guarantee that a connection will be established or will fail within a specified amount of time. This is useful when the server is not responding because the machine is down or overloaded.

DB2TCP_CLIENT_RCVTIMEOUT - Adjust this variable on the client to terminate the connection if data is not received from the server within a specified amount of time. This is useful in situations where a connection has already been established with the server but the server is no longer responding because the machine is down or overloaded.

Page 46: DB2 Connect to DB2 z/OS - Problem Determination

45

45

DB2 Connect Enhancements• BINARY, VARBINARY, and DECFLOAT data type support in .NET

and CLI client applications• Client support for trusted connections to DB2 for z/OS databases• Command line processor (CLP) 64 KB limit for SQL statements has

been changed to 2 MB• Developer Workbench replaces the Development Center in DB2 9• Data Studio replaces Developer Workbench in DB2 9.5• XML and XQuery support• JDBC and SQLJ driver enhancements• Connection timeout support for database applications• Support for IPV6• Statement level isolation for nicknames• Two-phase commit for multivendor data sources• User mapping retrieval from an external repository is supported• NetBIOS and SNA communication protocols are no longer supported

The above list includes enhancements to DB2 Connect 9 and DB2 9.5. The only enhancement that is unique to DB2 9.5 is that Data Studio replaces Developer Workbench which replaced the Development Center in DB2 9.

Page 47: DB2 Connect to DB2 z/OS - Problem Determination

46

46

• Describe data flow within a DB2 Connect environment and develop a problem determination methodology

• Perform problem determination analysis using tools available on DB2 Client

• Capture, parse and examine CLI and JCC Traces, configure DB2 Connect to improve performance, and analyze Snapshot DCS monitor output

• Run and interpret network commands and use DB2 commands to perform problem determination

• Analyze accounting, statistics and performance trace output to identify and resolve connection and performance problems

Summary

In summary, we have covered the above objectives.

Page 48: DB2 Connect to DB2 z/OS - Problem Determination

47

47

Melanie StopferIBM North America Lab Services

[email protected]

Session B03

DB2 Connect to DB2 z/OS –Problem Determination & Performance Tips & Tricks

For additional information, see www.ibm.com/training

• CF632 DB2 Connect to DB2 for z/OS Problem Determination & Performance

• CF602 DB2 Connect to DB2 for z/OS DRDA Implementation

For additional information, see www.ibm.com/training for courses CF632and CF602.