Skip to content

Instantly share code, notes, and snippets.

@lukewpatterson
Last active January 27, 2016 08:19
Show Gist options
  • Save lukewpatterson/6491377 to your computer and use it in GitHub Desktop.
Save lukewpatterson/6491377 to your computer and use it in GitHub Desktop.
db2 in docker
FROM base
RUN echo "deb http://archive.canonical.com/ubuntu precise partner" >> /etc/apt/sources.list
RUN echo "deb-src http://archive.canonical.com/ubuntu precise partner" >> /etc/apt/sources.list
RUN echo "deb http://archive.ubuntu.com/ubuntu precise universe" >> /etc/apt/sources.list
RUN echo "deb-src http://archive.ubuntu.com/ubuntu precise universe" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get --yes install ksh
RUN apt-get --yes --force-yes install apt-utils
RUN apt-get --yes install sudo
RUN sudo apt-get --yes install db2exc
-------------
... blows up with
sysctl: permission denied on key 'kernel.msgmni'
sysctl: permission denied on key 'kernel.msgmnb'
sysctl: permission denied on key 'kernel.msgmax'
sysctl: permission denied on key 'fs.file-max'
* Starting DAS: failed.
ftp://ftp.software.ibm.com/ps/products/db2/info/vr101/pdf/en_US/DB2InstallingServers-db2ise1010.pdf
http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg02074.html
kernel.msgmni (MSGMNI) 1 024 * <size of RAM in GB>
kernel.msgmax (MSGMAX) 65 536
kernel.msgmnb (MSGMNB) 65 536
http://edin.no-ip.com/blog/hswong3i/db2-express-c-10-1-ubuntu-12-04-howto
ubuntu@development:~$ ipcs -l
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 32768
max total shared memory (kbytes) = 8388608
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 = 1127
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384
`sysctl -a` to get original values:
kernel.msgmni = 1127
kernel.msgmax = 8192
kernel.msgmnb = 16384
fs.file-max = 399839
----------
so will change to
(for 4 gig)
sysctl -w kernel.msgmni=4096
sysctl -w kernel.msgmax=65536
sysctl -w kernel.msgmnb=65536
sysctl -w fs.file-max=6815744
then
service procps start
does it persist after reboot? -- no, add to /etc/sysctl.d/60-ibm.conf
http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg03681.html
have to add `hostname` to /etc/hosts
deb http://ubuntu.mirror.cambrium.nl/ubuntu/ precise main universe
deb http://ubuntu.mirror.cambrium.nl/ubuntu/ precise main
? $ sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install ia32-libs
deb http://ubuntu.mirror.cambrium.nl/ubuntu/ precise main universe
(before running the next stuff, might have to sudo apt-get --yes install dpkg)
add architecure i386
? $ sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install ia32-libs
sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install ia32-libs-multiarch
/home/db2inst1/sqllib/acs/acsnnas
http://unix.stackexchange.com/questions/13391/getting-not-found-message-when-running-a-32-bit-binary-on-a-64-bit-system
https://www.nesono.com/node/368 http://docs.docker.io/en/latest/examples/running_riak_service/
RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -s /bin/true /sbin/initctl
# sudo dpkg --configure -a
? DEBCONF_FRONTEND=noninteractive
$ cat db2_update_acs.42240
checking /home/db2inst1/sqllib/acs/acsnnas ...
/home/db2inst1/sqllib/acs/acsnnas: error while loading shared libraries: libssl.so.0.9.7: cannot open shared object file: No such file or directory
No valid acs agent found. Aborting.
sudo apt-get install libssl0.9.8 ?
http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/index.jsp?topic=%2Fcom.ibm.db2.luw.qb.server.doc%2Fdoc%2Fr0025127.html
@cjk
Copy link

cjk commented Jan 27, 2014

Hi, I'm also about to create a DB2 docker image. Did you eventually succeed with your solution and how does it look like now?

@jbonhag
Copy link

jbonhag commented Aug 9, 2014

@cjk @lukewpatterson Hi! I got a DB2 instance running on Docker (Ubuntu 14.04 base). Here's the repo:

https://github.com/jeffbonhag/db2-docker

You'll need to download v10.5fp1_linuxx64_expc.tar.gz (the latest 64-bit DB2 Express-C) into the same directory as the Dockerfile.

Initially, DB2 wouldn't start because there wasn't enough shared memory. You can increase kernel.shmmax but you have to do it with a post-build script, by running the container in privileged mode. The downside is that it takes a while to start the DB2 instance, and you have to do it every time the container runs.

I don't know if there's a way to start DB2 and then create a new image from that container -- although those Docker people are so amazing, I wouldn't put it past them.

Let me know how it goes!

@mikewaters
Copy link

@jeffbonhag were you able to get DB2 working under AUFS, or are you using the devicemapper backend?

@jbonhag
Copy link

jbonhag commented Sep 26, 2014

@mikewaters I have to confess I don't know what AUFS is -- I'm using whatever Docker 1.2.0 gives you by default in Ubuntu 14.04.

I can't seem to find a download link for DB2 10.5 Express-C Fix Pack 1 anymore... IBM's site takes me to a file called v10.5_linuxx64_expc.tar.gz now.

Also, it seems that the sysctl -w kernel.shmmax=18446744073709551615 under privileged mode trick doesn't work anymore, which is a little strange.

@wynandvanwyk
Copy link

@mike / Jeff - Have either of you actually succeeded in connecting to the database inside the container from a remote host or another container? I got it installed and running fine and all seemed well until I tried to actually connect. I'm sure you've tested your connectivity, but in case you haven't, I thought I'd perhaps suggest that you try it sooner rather than later as I'm still struggling to figure out what the problem is.

@jeff - is --privileged not enough by itself? Does one also need to do the "sysctl -w kernel.shmmax=18446744073709551615" thing?

@wynandvanwyk
Copy link

Update : It seems like my issue was db2 related and I simply needed to run "db2set DB2COMM=tcpip" for my comms to start working correctly

@jbonhag
Copy link

jbonhag commented Oct 29, 2014

@mikewaters Now I know what you're talking about -- switching the device driver backend a la http://muehe.org/posts/switching-docker-from-aufs-to-devicemapper/ .

This post makes me think that there may indeed be a problem with the default backend, so I'm trying with device-mapper and we'll see how it goes. I'm using boot2docker on OSX at the moment, so there's an additional layer of complexity.

Has aufs always been the default backend for Docker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment