Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Document Information
Prepared By Reviewed/Updated by Tested the actions in the document by Approved By Name Sambaraju Kiran Kumar Rajesh Chandramohan Sambaraju Kiran Kumar Date
2. Scope
DB2 UDB is product from IBM and is used to manager relational database. To keep the database up to mark with all other databases, by providing monitors to capture locks information which in turn will be used for analyzing the applications design so that the DB2 database will not get struck with locks.
3. Introduction / Overview
Diagnosing and correcting lock contention situations in large DB2 environments can be complex and time consuming. This lock event monitor along with other facilities, are designed to simplify this task by collecting locking data. The lock event monitor is used to capture descriptive information about lock events at the time that they occur. The information captured identifies the key applications involved in the lock contention that resulted in the lock event. Information is captured for both the lock requestor (applications that received the deadlock or lock timeout error, or waited for a lock for more than the specified amount of time) and the current lock owner. The information collected by the lock event monitor is written in binary format to an unformatted event table in the database. The captured data is processed in a post-capture step improving the efficiency of the capture process.
To remove the DB2DETAILDEADLOCK event monitor, issue the following SQL statements: SET EVENT MONITOR DB2DETAILDEADLOCK state 0 DROP EVENT MONITOR DB2DETAILDEADLOCK
5. Detailed Procedure
Two steps are required to capture lock event data using the locking event monitor: 1. You must create a LOCK EVENT monitor using the CREATE EVENT MONITOR FOR LOCKING statement. You provide a name for the monitor and the name of an unformatted event table into which the lock event data will be written. Below mentioned SQL creates a lock event monitor named LOCKEVMON CREATE EVENT MONITOR LOCKEVMON FOR LOCKING WRITE TO UNFORMATTED EVENT TABLE Note: The lock event monitor replaces the deprecated deadlock event monitors (CREATE EVENT MONITOR FOR DEADLOCKS statement and DB2DETAILDEADLOCK) and the deprecated lock timeout reporting feature (DB2_CAPTURE_LOCKTIMEOUT registry variable) with a simplified and consistent interface for gathering locking event data, and adds the ability to capture data on lock waits. The information collected by the lock event monitor (which is created above) is written in binary format to an unformatted event table in the database. After a locking event has occurred, the binary data in the unformatted event table can be transformed into an XML or a text document using a supplied Java-based application called db2evmonfmt. In addition, you can format the binary event data in the unformatted event table BLOB column into either an XML report document, using the EVMON_FORMAT_UE_TO_XML table function, or into a relational table, using the EVMON_FORMAT_UE_TO_TABLES procedure. Some of the information for lock events collected by the lock event monitor includes the following: 1. The lock that resulted in an event 2. The application holding the lock that resulted in the lock event 3. The applications that were waiting for or requesting the lock that result in the lock event 4. What the applications were doing during the lock event
2. Configure and use db2evmonfmt tool for reading event monitor data The Java-based, generic XML parser tool, db2evmonfmt, produces a readable flat-text output (text version) or a formatted XML output from the data generated by an event monitor that uses the unformatted event table. Based on the parameters that you specify, the db2evmonfmt tool determines how to parse the event monitor data and the type of output to create. The db2evmonfmt tool is provided as Java source code. You must setup and compile this tool, before you can use it, by performing the following steps: a. Locate the source code in the sqllib/samples/java/jdbc directory and compile it b. Before compiling the Java source code, copy the two files (db2evmonfmt.java + DB2EvmonLocking.xsl) to your current working directory c. Compile the copied java file using the below command javac db2evmonfmt.java Notes: A JDK (Java Development Kit) is required to compile the db2evmonfmt utility. Because a JDK is installed with each DB2 server product, you can use the Java compiler (javac) of the DB2 installation. d. After the succesful compilation, a new class file named db2evmonfmt.class will be created and is ready for use. The generated class (which is treated as the db2evmonfmt tool) file reads the unformatted lock events' data and generates the output in a readable format based on the parameters provided while using running the tool e. To read the locks events' data use the below command. By default, the output of the utility is written to standard out, so redirect its output into a text file. java db2evmonfmt -d sample -ue emdata.tab_locking -ftext -u username -p password > locktimeout.txt where the code options are as follows: -d Database name -ue Fully qualified path (including the schema) of the unformatted event table -ftext Output of lock-event information in plain text format (or, output can be in XML format by specifying the option -fxml) -u User ID for database access -p Password for database access Note: The db2evmonfmt utility is a Java-based tool which must be preceded by the java keyword in order to run successfully. The Java version required is that which is installed with the DB2 product from the sqllib/java/jdk64 directory.
7. FAQ
Use the below provided urls to find more details about the Lock event monitors on DB2 http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic= %2Fcom.ibm.db2.luw.admin.mon.doc%2Fdoc%2Fc0054136.html http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic= %2Fcom.ibm.db2.luw.sql.ref.doc%2Fdoc%2Fr0054074.html
http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic= %2Fcom.ibm.db2.luw.admin.mon.doc%2Fdoc%2Fc0053977.html
http://www.ibm.com/developerworks/data/library/techarticle/dm1004lockeventmonitor/
8. Step by Step
No Step-1 Step-2 Steps Install the DB2 UDB which has Lock monitor feature. Create the Lock event monitor event to capture locks related data to be collected in the db2 tables Create and configure the db2evmonfmt tool to read the unformatted data collected by the lock event monitors. It can be done by compiling the db2evmonfmt java file. Execute the db2evmonfmt tool by using the java commands on the db2evmonfmt class file which is created by compiling the db2evmonfmt java file Collect the generated output data which is in readable format and use it for analysis. Yes/No
Step-3
Step-4 Step-5