Linux-UNIX: Configure S-TAP for Db2 WPAR

Learn to configure S-TAP® for Db2 WPAR

About this task

There are two methods of determining the shmem parameters:
  • If your output to db2 get dbm cfg | grep ASLHEAPSZ is in English, use the script find_db2_shmem_parameters.sh ( 1). Its output lists the Db2 shared memory parameters defined in the Inspection Engines. You can run it from any directory. It requires the db2 instance name as parameter.
  • If your output to db2 get dbm cfg | grep ASLHEAPSZ is not in English, compute the client I/O area offsest (step 2), then find the Db2 shared memory size (step 3).

When ktap_fast_shmem set to 1, if there are multiple Db2 instances that are configured for a single WPAR in guard_tap.ini file and they have the same db2_shmem_size, then the db2_fix_pack_adjustment and db2_shmem_client_position are taken from the first Db2 section for that WPAR. So in cases where there are multiple Db2 instances running on the WPAR:

  • If all Db2 instances have the same db2_shmem_size, db2_fix_pack_adjustment, and db2_shmem_client_position, the packets from all instances are collected even if only one instance is configured.
  • If all Db2 instances have the same db2_shmem_size, but different db2_fix_pack_adjustment or db2_shmem_client_position, then only packets from the first configured Db2 instance are collected.

Procedure

  1. Run the script find_db2_shmem_parameters.sh from any directory, using the syntax: find_db2_shmem_parameters.sh <instance name>. Its output lists the Db2 shared memory parameters defined in the Inspection Engines.
  2. (Perform only if output to db2 get dbm cfg | grep ASLHEAPSZ is not in English). Compute the client I/O area offsest (db2_shmem_client_position).
    1. Open a new bash shell as the db2 instance user.
    2. Run the ps -x command to verify that the db2bp command processor is not currently running for this shell. You should not see a command called db2bp running. If it is running, either kill it or run a new shell.
    3. Run the following:
      db2 get database manager configuration | awk '/ASLHEAPSZ/{print $9 * 4096}'
      
    The output is the required value for db2_shmem_client_position
  3. (Perform only if output to db2 get dbm cfg | grep ASLHEAPSZ is not in English). To find the Db2 shared memory segment size (db2_shmem_size), perform one of:
    • This method gives the most accurate results.
      1. Start a Db2 shared memory connection and keep it open.
      2. Run this command to get the process ID for db2sysc: ps -eaf | grep db2sysc. The output looks like:
        db2inst1  5309370  5505772   0   Nov 11      - 1232:12 db2sysc 0
        In this example, the process ID is 5309370.
      3. Run this command to retrieve information about shared-memory processes: ipcs -ma. The output looks like:
        IPC status from /dev/mem as of Wed Nov 20 13:21:45 CST 2013
        T        ID     KEY        MODE       OWNER    GROUP  CREATOR   CGROUP NATTCH     SEGSZ  CPID  
        m   2097152 0xffffffff D-rw------- pconsole   system pconsole   system      1 536870912 4522088
        m         1 0x78000015 --rw-rw-rw-     root   system     root   system      3  16777216 3605314
        m         2 0x78000016 --rw-rw-rw-     root   system     root   system      3 268435456 3605314
        m 219152387 0xffffffff D-rw-------     root   system     root   system      1 536870912 5243842
        m   1048580 0x61013002 --rw------- pconsole   system pconsole   system      1  10485760 4522088
        m  10485765 0xd9fd8a61 --rw------- db2inst1 db2iadm1 db2inst1 db2iadm1      5  47644672 5571082
        m   9437190 0xd9fd8a74 --rw-rw-rw- db2inst1 db2iadm1 db2inst1 db2iadm1      9 140852104 5571082
        m   9437191 0xe1bd8858 --rw-rw----   oracle      dba   oracle      dba     40 53687107584 3801352
        m   3145736 0x52594801 --rw-rw----     root informix     root informix     13 223019008 5702650
        m   3145737 0xd9fd8b68 --rw-rw---- db2inst1 db2iadm1 db2inst1 db2iadm1      1  58720256 6619354
        m   3145738 0xffffffff --rw------- db2fenc1 db2fadm1 db2inst1 db2iadm1      7 268435456 5505772
        m        11 0x52594802 --rw-rw----     root informix     root informix     13  33439744 5702650
        m        12 0x52594803 --rw-rw-rw-     root informix     root informix     13    573440 5702650
        m        13 0xf2033f7e --rw------- sybase15   sybase sybase15   sybase      1 115564544 5178168
        m 409993231 0x52594804 --rw-rw---- informix informix informix informix     13   8388608 5702650
        m 763363344 0xffffffff --rw------- db2inst1 db2iadm1 db2inst1 db2iadm1      1 268435456 5309370
        m 125829140 0xffffffff --rw------- db2inst1 db2iadm1 db2inst1 db2iadm1      2    131072 5309370
        m 201326613 0xffffffff --rw------- db2inst1 db2iadm1 db2inst1 db2iadm1      1 163905536 5309370
        m 103750230 0xffffffff --rw------- db2inst1 db2iadm1 db2inst1 db2iadm1      1 134217280 5309370
        The output contains several columns beyond those shown here, but they do not affect this procedure. Find the line that contains the process ID that was identified in step 3.b and also has a value of 2 under NATTCH. The Db2 shared-memory segment size is the value in the SEGSZ column. In this example, it is 131072.
      4. Tip: if the list returned in step 3.c is too long, you can filter it by using the process ID. In this case, you would enter ipcs -ma | grep 5309370. The results do not contain the column headers, but you can look at the previous results to see the column headers and identify the correct line and column. In this example, it is the last line.
        m 131072014 0xffffffff --rw------- db2inst1 db2iadm1 db2inst1 db2iadm1      1 1342177280 5309370
        m 763363344 0xffffffff --rw------- db2inst1 db2iadm1 db2inst1 db2iadm1      1 268435456 5309370
        m 227541013 0xffffffff --rw------- db2inst1 db2iadm1 db2inst1 db2iadm1      1 163905536 5309370
        m 106353238 0xffffffff --rw------- db2inst1 db2iadm1 db2inst1 db2iadm1      2    131072 5309370
    • Alternatively, use this method, which is easier but less accurate:
      ATAP and KTAP rely on the size for identification of the Application/Agent shared memory segments. These segments are then tapped for C2S and S2C packets. The segments are equal to the sum of the ASLHEAPSZ and RQRIOBLK parameters. DB2® allocates much larger segments. In most cases, the size is equal to (ASLHEAPSZ + 1) * 2 pages, or (ASLHEAPSZ + 1) * 8192 bytes. Exact size can be determined by observation of the shared memory segments in the system before and after new Db2 local connection is created. Use this sequence of commands to determine the shared memory segment size. ipcs command parameters and output format differ from platform to platform. The following script is based on the AIX® version.
      ipcs -ma | sort -n -2 +3 > /tmp/before.txt
      db2 connect to <some_existing_database>ipcs -ma | sort -n -2 +3 > /tmp/after.txt
      db2 terminate
      diff /tmp/before.txt /tmp/after.txt | awk '{if ($10 == 2) print $11}'
      
  4. Set these parameters in order to capture the Db2 shared memory traffic.
    Table 1. Db2 Parameters
    Parameter STAP Name ATAP Name
    Packet header size db2_fixed_pack_adjustment db2_header_offset
    Client I/O area offset db2_shmem_client_position db2_c2soffset
    Db2 shared memory segment size db2_shmem_size db2_shmsize