DB21015E on Red­Hat 5.6

If you receive the fol­low­ing mes­sage try­ing to con­nect do a DB2 instance

[user@host ~]$ db2 connect to INSTANCE
 DB21015E The Command Line Processor backend process request queue or input
 queue was not created within the timeout period.

Look­ing into the strace out­put shows some­thing like

msgget(0x416b94ef, IPC_CREAT|IPC_EXCL|0610) = -1 ENOSPC (No space left on device)

and db2diag.log shows

PID : 9999 TID : 47272606561216PROC : db2bp
 INSTANCE: INSANCE NODE : 000
 FUNCTION: DB2 UDB, oper system services, sqloMLNique, probe:8
 MESSAGE : ZRC=0x870F0043=-2029060029=SQLO_QUE_EXCEED
 "Maximum system queue limit exceeded"
 DIA8559C A message queue limit has been exceeded.
 CALLED : OS, -, msgget OSERR: ENOSPC (28)

Basi­cally that means that

a) In terms of shared Mem­ory all pos­si­ble shared mem­ory IDs have been taken (SHMMNI), or allo­cat­ing a seg­ment of the requested size would cause the sys­tem to exceed the system-wide limit on shared mem­ory (SHMALL).

b) In terms of Sem­a­phores A sem­a­phore set has to be cre­ated but the sys­tem limit for the max­i­mum num­ber of sem­a­phore sets (SEMMNI), or the sys­tem wide max­i­mum num­ber of sem­a­phores (SEMMNS), would be exceeded.

(we’ll get to the point that this is not our issue here …)

Next step would be to check the system-wide val­ues to see what we’re look­ing for:

$ ipcs -l
------ Shared Memory Limits --------
 max number of segments = 4096
 max seg size (kbytes) = 67108864
 max total shared memory (kbytes) = 17179869184
 min seg size (bytes) = 1
------ Semaphore Limits --------
 max number of arrays = 128
 max semaphores per array = 250
 max semaphores system wide = 32000
 max ops per semop call = 32
 semaphore max value = 32767
------ Messages: Limits --------
 max queues system wide = 16
 max size of message (bytes) = 65536
 default max size of queue (bytes) = 65536
$ sysctl -a | grep shm
 vm.hugetlb_shm_group = 0
 kernel.shmmni = 4096
 kernel.shmall = 4294967296
 kernel.shmmax = 68719476736

So we have a max­i­mum of 4096 shared mem­ory seg­ments, 128 Sem­a­phore Arrays and 250 Sem­a­phores per Array avail­able. Looks rea­son­ably good so far.

The most con­cern­ing para­me­ter in terms of DB2 is this one, and that goes well together with the msgget() sys­tem call:

max queues system wide = 16

Accord­ing to the DB2 Doc­u­men­ta­tion, the max­i­mum num­ber of mes­sage queues (MSGMNI) has to be set to at least 16384. Also, the max­i­mum num­ber of Sem­a­phore Arrays should be 1024.

OK, let’s do it:

sysctl -w kernel.msgmni=16384
sysctl -w kernel.sem="250 32000 100 1024"

Et voila, it’s working:

$ db2 connect to INSTANCE
Database Connection Information
Database server = DB2/LINUXX8664 9.7.1
 SQL authorization ID = USER
 Local database alias = INSTANCE

Now, let’s make the change persistent:

echo "kernel.msgmni=16384" >>/etc/sysctl.conf
echo "kernel.sem=\"250 32000 100 1024\"" >>/etc/sysctl.conf

That’s it! Now your DB2 adven­tures can begin …

Note: Please see the offi­cial DB2 doc­u­men­ta­tion.