I am trying to install and start db2 on my linux machine using the following script:

#!/usr/bin/env bash



echo "changing to $DB_SERVER_PROGRAM_PATH"
echo "removing expc"
${RM} -rf expc
echo "untarring ${DB2_SERVER_PROGRAM}"

echo "changing to expc"
cd expc

echo "Installing db2 as root"
sudo ./db2_install

echo "Adding user group db2grp1 as root"
sudo groupadd db2grp1
echo "Adding user group dasadm1 as root"
sudo groupadd dasadm1
echo "Adding user group db2fgrp1 as root"
sudo groupadd db2fgrp1

echo "Adding user db2inst1. Please provide password for new user db2inst1."
sudo useradd -g db2grp1 -G dasadm1 -m db2inst1
sudo passwd db2inst1

echo "Adding user dasusr1. Please provide password for new user dasusr1."
sudo useradd -g dasadm1 -G db2grp1 -m dasusr1
sudo passwd dasusr1

echo "Adding user db2fenc1. Please provide password for new user db2fenc1."
sudo useradd -g db2fgrp1 -m db2fenc1
sudo passwd db2fenc1

cd /opt/ibm/db2/V10.5/instance

echo "Creating DAS as root via user dasusr1."
sudo ./dascrt -u dasusr1

echo "Creating database instance as root via user db2fenc1 and db2inst1."
sudo ./db2icrt -u db2fenc1 db2inst1

echo "Setting communication protocol to tcpip as user db2inst1."
sudo -u db2inst1 ../adm/db2set DB2COMM=tcpip
echo "Setting SVCENAME 50000 for dbm cfg as user db2inst1."
sudo -u db2inst1 ../bin/db2 update dbm cfg using SVCENAME 50000

echo "starting db2 as user db2inst1."
sudo chmod +x ../adm/db2start
sudo -u db2inst1 ../adm/db2start

netstat -an | grep 50000

Everything works fine, till I get to the penultimate line:

sudo -u db2inst1 ../adm/db2start

SQL1641N  The db2start command failed because one or more DB2 database
manager program files was prevented from executing with root 
privileges by file system mount settings.

Now I checked /etc/fstab and it says:

proc            /proc           proc    nodev,noexec,nosuid 0       0
UUID=d4d794eb-1e68-4ddf-a9ec-249a22f084fb none            swap    sw             0       0
/swapfile swap swap defaults 0 0

My installation path, /opt/ibm/db2/V10.5/adm is basically on /dev/sda1 and it's not mounted using the nosuid option.

Here is the output of mount:

alok@hostname:~$ mount
shmfs on /dev/shm type tmpfs (rw,size=2048m)
gvfs-fuse-daemon on /home/alok/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=alok)

This again indicates that / is not mounted in nosuid mode. So why am I getting error SQL1641N? Is it a different problem throwing out this message instead?

  • I chmod'd the db2start file to +s and this started working. Shouldn't this have been done by the installer to begin with? – alok Sep 13 '13 at 8:57
  • Yes but how is that relevant at all? My installation is a root installation (see the script) in the question – alok Sep 16 '13 at 3:09

The files in /opt/ibm/db2/V10.5/ are not to be used for a specific instance. When you run the db2icrt command, it copies a series of files and directories into ~db2inst1/sqllib, and sets the permissions accordingly. (Some of the directories in ~db2inst1/sqllib will be soft links back to directories in /opt/ibm/db2/V10.5).

For example, you should find that ~db2inst1/sqllib/adm/db2start has permissions set to 6555 (i.e. -r-sr-sr-x), owned by root, and have the group owner set to the instance owner's primary group.

You should not be executing things from /opt/ibm/db2/V10.5/adm. That is why the permissions of the files in that directory are set the way they are – /opt/ibm/db2/V10.5/adm/db2start should be 0444.

So, to start your instance, you should be executing ~db2inst1/sqllib/adm/db2start.

Be aware that you also need to initialize the db2inst1 user environment prior to starting the instance, so you should use the -i option for sudo to handle this:

sudo -i -u db2inst1 /home/db2inst1/sqllib/adm/db2start

One last note: All of this configuration (except perhaps the db2start) can be done using a response file and db2setup. db2_install has been deprecated, so using response files is the way to handle this going forward.

  • -i switch saved my life! – mlewandowski Jul 9 '19 at 7:59

Your Answer

