gorddbds 060001JCXS Visits (1357)
DB2 LUW provides the db2pd tool with two fmp options that when used in conjunction with each other can provide information which will identify the routine that was running in a particular db2fmp. The following technote documents a method to determine which db2fmp a routine ran in using the db2pd tool.
If a db2fmp entry is logged in the db2diag.log, the entry should contain the process ID (PID) and thread ID (TID). Below is a sample of a db2diag.log entry which identifies the db2fmp PID and TID.
PID : 59900132 TID : 0 PROC : db2fmp
Since the db2pd -fmp command described in the above technote returns the PID and TID as well as the routine name and time of the run, it is possible to use the information in the db2diag.log to map a routine to its db2fmp. Below is a sample of the output.
59900132 0 2012
So we can see from the above output that the db2fmp error occurred while running the routine SYSPROC.ADMIN_CMD
gorddbds 060001JCXS Visits (1210)
DB2 LUW is capable of running Java applications as stored procedures or user defined functions (Stored Procedures and UDFs are collectively referred to as routines). When a Java routine is invoked DB2 will load the class and start a JVM in a process called the db2fmp. Unlike other DB2 processes, this process is owned by the fenced user, so it is necessary for the fenced user ID to have access to the libraries containing the application classes and the JVM. By default the JDK that is shipped with DB2 is used. You can use a JDK other than the one shipped with DB2 by modifying the JDK_PATH dbm cfg variable to point to the location of the desired JDK. If you are using a 1.6 JDK it will be necessary to set the environment variable DB2LIBPATH to the path containing the JDK. Not every JDK is supported for running routines. Supported JDKs are documented in the DB2 Infocenter. The JDKs supported for version 9.7 are listed at the following URL.
In order to execute a Java routine DB2 will start a JVM in the db2fmp. On AIX systems the db2fmp will be unable to start a JVM if the Stack Execution Disable mode is set to “all' or “setidfiles”. If the SED is set to one of these modes it will be necessary to change the mode in order to run Java routines. You can verify the setting of the SED by issuing the command sedmgr.
For information on General routine performance including additional information on Java routines see the following URL.
See the following URL for information on modifying the dbm cfg variable JDK_PATH
gorddbds 060001JCXS Visits (1373)
100 Tech Tips: #86 What information is in the name of the db2fmp
The db2fmp or DB2 Fenced Mode Process is used to run untrusted external routines. These routines can be created in a variety of languages and can be thread-safe (meaning it is safe to run them in a multi-threaded db2fmp process with other unrelated routines), or not thread-safe (meaning they will be run in a single db2fmp process). The name of the db2fmp in the ps output can be used to determine the language and thread-safeness of the db2fmp. The name also indicates if the db2fmp is associated with one or more agents or is currently in the fenced pool. For example here is the output of the command ps -elf | grep db2fmp
242001 A nobody 6881336 10616948
0 60 20 850f65590 39372 * Apr 30 - 0:03 db2fmp
242001 A nobody 7143552 13697146
0 60 20 8f36cf590 4024 * 16:00:10 - 0:00 db2fmp (C)
242001 A nobody 36831440 22282262
0 60 20 892889590 2176 * 09:19:08 - 0:00 db2fmp
242001 A nobody 8913102 10616948 0 60 20 963616590 3876 * 14:54:10 - 0:00 db2fmp (idle)
The first db2fmp in the output with the (Java) in its name is associated with one or more agents and is being used to run thread-safe Java routines.
The second db2fmp with the (C) in its name is also associated with one or more agents and is being used to run thread-safe C routines.
The db2fmp with the (2829) in its name is currently associated with a single agent with the thread or process id that matches the number in the brackets. The routine run by this db2fmp is not thread-safe. If it were thread-safe the db2fmp name would contain the name of the routine's programming language instead of a number.
The db2fmp with (idle) in its name is currently in the fenced pool waiting for reuse and not associated with an agent.
gorddbds 060001JCXS Visits (1594)
100 Tech Tips, #62 Finding and Changing the DB2 fenced ID on Unix and Linux
External DB2 LUW routines (stored
procedures and user defined functions that are not coded in SQL) often run
under the fenced user ID, which is provided when the DB2 instance is
created. The authority these routines have on the system is
limited to the access the fenced ID has, so it is useful when
designing external routines to know the fenced ID. You can find the
ID that will run routines by checking the ownership of the .fenced
file located in the <INS
$ ls -al
-r--r--r-- 1 nobody nobody 0 Feb 03 15:44 .fenced
In this example the fenced ID is nobody belonging to the group nobody.
You can change the fenced ID by changing the ownership of the .fenced file. Please note, it will be necessary to stop and start the instance in order for the change to take effect.
You can confirm that the fenced ID has been changed by issuing the ps command and looking for the db2fmp processes. Below is an example.
ps -elf |grep db2fmp
242001 A nobody 573636 458870 0 60 20 10da27b590 6184 * Dec 23 - 0:16 db2fmp ( C )
You may notice other db2fmp processes running on the system under IDs that are not the fenced ID. Only the db2fmp processes running under the fenced ID will be used to run external routines.