A db2 resource fails when the database instance user's login shell is set to csh or tcsh in a Pacemaker cluster

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 7 (with the High Availability Add-on)
  • Red Hat Enterprise Linux 8 (with the High Availability Add-on)

Issue

Resolution

Set the database instance user's login shell to /bin/sh or /bin/bash.

SAP Note Content from launchpad.support.sap.com is not included.202227 does not require csh specifically. The first two sentences state:

When you decide between a C shell (or a shell that is compatible with them) and a POSIX shell (such as a Bourne shell), the operating system that is used and the specific version of the shell may be significant.
In principle, the SAP system and the database runs with either of these shells.

Later, the SAP note states that ksh and tcsh specifically can be problematic as login shells due to implementation differences across various Unix platforms. But it never says not to use /bin/sh or /bin/bash. (Note that /bin/sh is a symlink to /bin/bash on RHEL.)

The note goes on to say that if you face issues with ksh or tcsh, "...first take the use of csh or sh into consideration."

Since setting the database instance user's login shell to csh causes a syntax error in the db2 resource agent (see Root Cause), the solution is to set the login shell to /bin/sh.

Root Cause

The db2 resource agent contains a function named runasdb2.

#
# Run the given command as db2 instance user
#
runasdb2() {
    su $instance -c ". $db2profile; $*"
}

As shown above, this function runs . $db2profile to import the profile and then runs the rest of the passed-in arguments as the DB2 instance user. However, the . <file> import syntax is not valid in csh; csh only recognizes the more portable source <file> syntax.

So the runasdb2() function causes a syntax error if the instance user's login shell is csh. The login shell must be one that correctly parses the . <file> import syntax. sh or bash can handle the . <file> syntax with no problem.

Diagnostic Steps

  1. A db2 resource agent fails immediately.
  2. The DB2 instance user's login shell is set to csh or tcsh.
SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.