Friday, February 16, 2007

The DB2 install experience

All these years I have been working with Oracle and mysql. For an application developer my oracle knowledge should be quite good. Till fairly recently it was not easy to get a "personal" copy of oracle so most of my side projects used mysql. When oracle came out with express edition (XE) I pretty much said goodbye to mysql also. So when we were "forced" to work with DB2 my initial reaction was pretty vile.

First , I was not sure if i can install it on one of the free linux distros like fedora or opensuse since I had a copy of enterprise edition of DB2. My first task was to install DB2 on a intel box running open suse 10.2. So after some big download sessions involving DVD images of open suse and DB2 enterprise edition I rolled my sleeves and dived in. Installing open suse was, what should i say, a piece of cake? Since this box was exclusively to run DB2 i decided not to install all the 5000 nifty utilities ;o)

To install DB2 i took the easiest path out , the X windows installer. The installer looks from some other era but works. I just took all the default and ended up with a minor error that installer was not able to create an instance. Before you begin your install it is recommended to read the quick beginning for DB2 servers available from IBM site. If you are using the X windows installer you would not need it but the information is pretty useful.

Now this was nothing minor. During install DB2 dumps the log files in /tmp and reading log files was more or less of no help! The errors were too generic and would have implied a range of things. This was my first "stuck-up" point. I must have spent close to 4 days trying to create an instance by hand. I am not going to waste more space here telling that story because installations are very individual things and a number of things can go wrong. I had installed NX server on my suse box that some how screwed up the host name and DB2 install was not able to resolve the host name. I solved this issue by contacting our resident DB2 expert.

After resolving host name issue I was able to start and stop the database instance but not the listener. The db2start and db2stop commands would run fine but the listener would not start. This was my second stuck-up point. DB2 service entry is put in /etc/services file and SVCENAME config parameter should also have the same value. That issue was resolved after issuing a $db2=> update dbm cfg using SVCENAME 60000 command. BTW, whenever you see db2=> or CLP mentioned in the documents, it means the db2 command line processor. You can start the CLP by typing $/bin/db2 command.

Next steps were verifying the install by creating sample database and doing some selects here and there. At this point i could start stop the database, start the listener and connect to it. All of this was done on the DB2 server machine. One more thing to remember is to switch to DB2 instance user before you issue any commands. Now I needed a client to use this DB2 server from my win XP laptop. Here I did something that I should not have done. I wasted quite a few days trying to run with runtime client.

Now YMMV but i would recommend grabbing the full DB2 client. if you intend to do any serious work with DB2 you would be happy with the set of tools that come with full client. And at this point i am not very sure of thin JDBC driver support with DB2. Also if your work involves porting from an existing database like oracle and you plan to run MTK toolkit then you need a "FAT" client. That helps things. At least when you are in novice stage. With the DB2 client installed, it is pretty easy to setup database aliases on client machine using the configuration assistant. It also includes a command editor that can be used to fire up queries.

My next stops were
  • Using the MTK tool to port existing oracle schema and data to DB2
  • porting oracle stored procedures and triggers by hand
  • Using DB2 with hibernate

Thursday, February 01, 2007

DB2 suffers from too much documentation

January is already gone and that means about 8% of this year too. last few days have been hectic because of DB2 intall. Right now we are running on oracle but the instruction from management is to port our application to DB2. I never had a chance to play with DB2 before. Right now, we are not interested in performance and tuning , we just want to port our oracle tables and procedures over to DB2 as quickly as possible.

The install is supposed to be easy and i guess it should have been like that. But we had some issues with hostname resolution on our open SUSE box. Due to that hostname issue, we were not able to create DB2 instances. That issue is now resolved. However , I noticed two things about DB2 documentation. There is documentation and lot of documentation , so much so in fact that your search token will become that proverbial "needle in haystack". Second thing is , all the errors reported by DB2 are way too generic. They wont be of much help in troubleshooting.

Maybe I need to read it from cover to cover. But you know how it is when you are starting with a new software. You want to get quickly on your feet and start your work straight-away. It is hard to believe that I spent 4 days to get the DB up and running. time to RTFM.
© Life of a third world developer
Maira Gall