While we have had great success with the DB2 on AIX. There is, as of yet, no known native port of DB2 to FreeBSD. This poses a considerable problem. I prefer FreeBSD over Linux for web serving. (I will not discuss why here.) So when we needed to roll out our application we were left with a decision to make: use Linux or wait. Since we had a deadline to meet, we decided to roll out our initial production database dependent servers on Linux. This way I could explore other possibilities at a more comfortable pace.
As FreeBSD has progressed over the years, the FreeBSD team decided to add support for Linux binaries. This happened early in the 2.x tree, and over the years this has progressed into a simple and almost transparent interface to run the Linux binaries. This cannot really be called emulation because it is a little more complex and much more elegant then that. If you are really interested and want to know more, please read the FreeBSD Handbook.
cd /usr/ports/emulators/linux_base make && make install
This should install the base linux system into the /compat/linux directory. After that you need to decide whether or not you need support for development tools at this stage if you are developing complex programs that need to be compiled. You should still develop them on a running Linux system. This will be much easier to debug. Otherwise there is a port for Linux development tools in /usr/ports/devel/linux_devtools.
After you have installed the base Linux system. You still need to let the kernel know that you want to run Linux applications. Here again you have a choice. There is a kernel module that you enable by simply typing linux as root. Or you can compile in support. Since I know that I need this support all the time I chose to compile in support. Here are the kernel options:
options COMPAT_LINUX options DEBUG_LINUX
I decided not to use the DEBUG_LINUX option since this was a production web server. Now if you chose to use the module then you can activate it on start up by adding the following line to /etc/rc.conf
linux_enable="YES"
The last thing that you need to do is decide if your programs will need the Linux /proc file system. This can be activated either by an entry in /etc/fstab or by manually mounting it. The following entry in /etc/fstab should be fine.
/proc /compat/linux/proc linprocfs rw 0 0
find / >> /var/full_file_list.out
This all sounds simple, but it is not that easy. DB2 has
several directories that we found very important. First
was the /usr/IBMdb2/ directory. This will
hold the bulk of the installation. There is also a
/usr/local/db2/ directory -- that for us -- housed the
users' home directories. You need to pay close attention
to the permissions on all of the files that you will find
inside the /usr/local/db2/
When you install these directories onto the FreeBSD system you don't have to worry about putting them inside the /compat/linux directory. We were able to install them all into directories that mirrored the Linux installation exactly.
Once you have all the DB2 files installed onto the FreeBSD system and you have the support enabled for Linux you are ready to start the db2 client. The one thing that really took me a while to figure out was that /dev/null had to have permissions of 0666 otherwise the db2 client would not start. What it would do was hang around and finally time out. Why IBM decided to use /dev/null in a compiled binary is strange at best. So be careful and make sure that you adjust the permissions on /dev/null.
Also make sure that you set up the DB2 client to work and catalog the proper databases before you install onto FreeBSD. What DB2 does to store you database connection information is make the following directories inside the DB2 user's home.
/sqllib/sqlnodir/ /sqllib/sqldbdir/
Inside these two directories, there are some binary files that contain the proper node information as well as the database catalog information. I was unable to change these files from the db2 command prompt under the FreeBSD compat. So what I did instead is alter them when needed on Linux then tar them up and transfer them over. I imagine that this can be solved and eventually the ability to change these files from FreeBSD will happen in the near future.
However, I cannot say with 100% certainty and it would be very difficult to make formal benchmarks. I can say that from a system admin standpoint. I cannot notice a loss of performance running the Linux Apache on FreeBSD. To be honest it almost seems to be faster running on FreeBSD.
Nathan Boeger is a senior system admin / systems developer for GetRelevant, a promotional Internet marketing company.