IBM Support

Environment variables from DB2 instance's profile files not not sourced at startup

Question & Answer


Procedure to set environment variables from DB2 instance's profile files so they are picked up when DB2 is started by ibmslapd.


In order to make DB2 aware of Tivoli Storage Manager (TSM), certain environment variables need to be set before starting DB2. Then DB2 can perform TSM related functions appropriately. The common practice is to set these TSM related environment variables in the DB2 instance's .profile or even in the DB2 instance's userprofile file. When DB2 gets started as the instance owner, the database will have all the required environment variables properly set.

On a Tivoli Directory Server system, the ldap server (ibmslapd) stores all its data into its own backend DB2 database on the same system. When using the default ldap ports (389 and 636), ibmslapd must be started as the root user. During the start of ibmslapd, ibmslapd also starts the associated DB2 instance. If DB2 is already started, ibmslapd will just proceed.

If ibmslapd is started by the root user then neither the instance's profile nor the userprofile files are sourced into ibmslapd. In turn if DB2 also gets started during this step by ibmslapd, the required TSM related environment variables will not be set into DB2. This causes issues with DB2 (in TDS system) being aware of TSM.


Use one of the following methods to start ibmslapd appropriately and have the DB2 acquire the required environment variables from the .profile or userprofile files.

Make sure the required environment variables are appropriately exported from the .profile OR userprofile files.

Example for setting environment variables (for ksh / bash):
export DSMI_CONFIG=/usr/tivoli/tsm/client/api/bin64/dsm.opt

export DSMI_DIR=/usr/tivoli/tsm/client/api/bin64
export DSMI_LOG=/home/instance/tsmlog/

profile file locations:
.profile is located in the home folder of the instance.
db2profile is located in the sqllib folder inside home folder of the instance.
idsprofile is located in the folder <Location>/idsslapd-<Name>/, where "idsilist -a" shows the <Location> and <Name> values of the instance.
userprofile file for DB2 is located in the sqllib folder inside home folder of the instance.
userprofile file for TDS is located in the folder <Location>/idsslapd-<Name>/.

Its recommended to update either .profile file or userprofile file of DB2/TDS only with environment variables. Do not update either db2profile or idsprofile files.

Method 1: Source instance's .profile OR just the idsprofile and db2profile files into the root's shell before starting up ibmslapd. Its suggested to store the user specific env variables into the userprofile file of the ITDS instance or into the userprofile file of the DB2 instance. A custom script can be written to complete this task.

    Sample script (ITDS and DB2 instance names are assumed to be "instance"):

    # ibmslapd_start_with_instance_env.ksh
    # Method A - Source the .profile of the ITDS/DB2 instance.
    . ~instance/.profile

    # Method B - Source the idsprofile and db2profile files explicitly, the following is commented since Method A is in use.
    # . ~instance/sqllib/db2profile
    # . <Location>/idsslapd-<Name>/idsprofile
    # Use "idsilist -a" command to find the <Location> and <Name> values of the instance.

    # start ibmslapd.
    /opt/IBM/ldap/V6.2/sbin/ibmslapd -I instance

    # end of script.

Method 2: Follow the remote start up method as suggested before.
    • Stop and Start ibmdiradm as the instance owner.
      ==> su - instance
      ==> ibmdiradm -I instance -k
      ==> ibmdiradm -I instance
    • Stop ibmslapd and DB2 (Using the same shell as instance user)
      ==> ibmslapd -I instance -k
      ==> db2 force applications all
      ==> db2stop force
      ==> ipclean
    • Start ibmslapd with ibmdirctl command
      ==> ibmdirctl -p 3538 -D cn=root -w password start
      where 3538 is admin daemon port as per "idsilist -a" output.

      Note: if ibmslapd is configured to run on ports higher than reserved ports range (>1024), ibmslapd can be started directly as non-root user:
      ==> ibmslapd -I instance
    • ibmdirctl communicates with ibmdiradm and kick starts ibmslapd - ibmslapd will in turn starts up DB2.
    • When using this method the env variables from .profile gets into ibmdiradm, which in turn gets into ibmslapd and then into db2sysc.
Method 3: Start DB2 as instance user by either login/step into instance user and then start ibmslapd as root user:
    • Using command line methods:
      ==> su - instance
      ==> db2start
      ==> exit
      ==> ibmslapd -I instance # as root
    • An alternative method as root user:
      ==> su - instance -c db2start
      ==> ibmslapd -I instance
Verify: Use the following commands to verify if the environment variables are set correctly for the DB2 processes:
    • Get the process number of db2sysc after start of db2 using one of the methods mentioned above:
      ==> ps -aef | grep instance | grep db2sysc
      instance 356458 401650 7 12:05:00 - 0:00 db2sysc 0
    • Verify the environment variables:
      ==> ps eww 356458

[{"Product":{"code":"SSVJJU","label":"IBM Security Directory Server"},"Business Unit":{"code":"BU008","label":"Security"},"Component":"General","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"}],"Version":"6.0;6.1;6.2;6.3;6.3.1;6.4","Edition":"","Line of Business":{"code":"LOB24","label":"Security Software"}}]

Document Information

Modified date:
16 June 2018