but Ubuntu 8.10 and DB2 9.5 are so nice together
- Published:
- categories: ibm
- tags: db2, linux, open-source, ubuntu
So I have to install the two together for some testing, the first problem is discovered upon running the pre-requisite check failing with libst5++ missing, a quick search and we find the required packages, once you have these the install should go just fine.
user@ubuntu:~$ sudo apt-get install -y libstdc++5 libaio-dev
Now that we are installed and if all has gone correctly the services are started, we want to make DB2 start auto-magically when the machine is booted otherwise the services need to be started manually.
Manual startup is pretty straight forward but will require you to install your license if you have not using a free version.
user@ubuntu:~$ cd /opt/ibm/db2/V9.5/adm
user@ubuntu:/opt/ibm/db2/V9.5/adm$ sudo chmod o+x *
user@ubuntu:/opt/ibm/db2/V9.5/adm$ su -c ./db2stop db2inst1
Password:
SQL1064N DB2STOP processing was successful.
user@ubuntu:/opt/ibm/db2/V9.5/adm$ su -c ./db2start db2inst1
Password:
ADM12026W The DB2 server has detected that a valid license for the product
"DB2 xxx" has not been registered.
SQL1063N DB2START processing was successful.
user@ubuntu:/opt/ibm/db2/V9.5/adm$ su -c ./db2stop db2inst1
Password:
SQL1064N DB2STOP processing was successful.
user@ubuntu:/opt/ibm/db2/V9.5/adm$ sudo ./db2licm -a ~/my_db2_license.lic
LIC1402I License added successfully.
<... blah blah blah >
user@ubuntu:/opt/ibm/db2/V9.5/adm$
su -c ./db2start db2inst1
Password:
SQL1063N DB2START processing was successful.
user@ubuntu:/opt/ibm/db2/V9.5/adm$
Now that we can start and stop the instance manually we want to setup the instance for auto startup.
user@ubuntu:~$ cd /opt/ibm/db2/V9.5
user@ubuntu:/opt/ibm/db2/V9.5$ bin/db2ilist
db2inst1
user@ubuntu:/opt/ibm/db2/V9.5$ sudo db2iauto -on db2inst1
[sudo] password for user:
user@ubuntu:/opt/ibm/db2/V9.5$ adm/db2set
DB2COMM=tcpip
DB2AUTOSTART=yes
My simple /etc/init.d/db2-9.5 script
#!/bin/sh
#
# Startup script for the DB2 9.5 instance
### BEGIN INIT INFO
# Provides: db2-9.5
# Required-Start: $network
# Required-Stop: $network
# Default-Start: S 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: DB2 primary instance
# Description: DB2 database.
### END INIT INFO
DB2_INSTANCE_USER=db2inst1
DB2_INSTANCE_HOME=/home/${DB2_INSTANCE_USER}/sqllib
test -d ${DB2_INSTANCE_HOME} || exit 0
. /lib/lsb/init-functions
case "$1" in
start)
log_begin_msg "Starting DB2 ${DB2_INSTANCE}."
su -c ${DB2_INSTANCE_HOME}/adm/db2start ${DB2_INSTANCE_USER}
log_end_msg $?
;;
stop)
log_begin_msg "Stopping DB2 ${DB2_INSTANCE}."
su -c ${DB2_INSTANCE_HOME}/adm/db2stop ${DB2_INSTANCE_USER}
log_end_msg $?
;;
force-reload)
$0 restart
;;
restart)
$0 stop
$0 start
;;
status)
# Not sure how to use this command or of anything similar db2 specific?
# if you are shoot me a note!
# status_of_proc -p && exit 0 || exit $?
;;
*)
log_success_msg "Usage: /etc/init.d/db2-9.5 {start|stop|force-reload|restart|status}"
exit 1
;;
esac
exit 0
Now that we have a basic init script in place, we can make sure this is working by starting and stopping the instance. ( I was hoping) Once we are confident that we have it right, we can add this script to the default run level and let Ubuntu start and stop it automatically.
user@ubuntu:~$ sudo /etc/init.d/db2-9.5 start
* Starting DB2 .
SQL1063N DB2START processing was successful.
[ OK ]
user@ubuntu:~$ sudo /etc/init.d/db2-9.5 stop
* Stopping DB2 .
SQL1064N DB2STOP processing was successful.
[ OK ]
user@ubuntu:~$ sudo update-rc.d db2-9.5 defaults
Adding system startup for /etc/init.d/db2-9.5 ...
/etc/rc0.d/K20db2-9.5 -> ../init.d/db2-9.5
/etc/rc1.d/K20db2-9.5 -> ../init.d/db2-9.5
/etc/rc6.d/K20db2-9.5 -> ../init.d/db2-9.5
/etc/rc2.d/S20db2-9.5 -> ../init.d/db2-9.5
/etc/rc3.d/S20db2-9.5 -> ../init.d/db2-9.5
/etc/rc4.d/S20db2-9.5 -> ../init.d/db2-9.5
/etc/rc5.d/S20db2-9.5 -> ../init.d/db2-9.5
user@ubuntu:~$
Now you can test it out, restart your server and make sure you can connect to your fancy new server. Let me know if you see any problems or have some better suggestions as I can always use the help :)
Reference:
- http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin.dbobj.doc/doc/t0004910.html
- http://antoniocangiano.com/2007/11/11/installing-db2-95-on-ubuntu-710/
- http://www.ibm.com/developerworks/forums/message.jspa?messageID=13941864
- http://www.dbforums.com/showthread.php?t=1617101
- http://www.linux.org/docs/ldp/howto/DB2-HOWTO/ubuntu704.html