Difference between revisions of "DB2 installation"
(How to get DB2 Express-C going in a Virtual Environment) |
(use the new settings) |
||
(8 intermediate revisions by 3 users not shown) | |||
Line 8: | Line 8: | ||
== Create a new VE == | == Create a new VE == | ||
− | I created a new VE for the Debian distribution using debootstrap. | + | I created a new VE for the Debian distribution using debootstrap, as described in [[Debian template creation]]. |
== Set VE resource limits appropriately == | == Set VE resource limits appropriately == | ||
− | + | These are tested resource limits for x86-64 system running Debian/GNU Linux 5.0.6: | |
− | * kmemsize to | + | * kmemsize to 26214400:29491200 |
− | * privvmpages to | + | * privvmpages to 2097152:unlimited |
− | * shmpages to | + | * shmpages to 1572864 |
− | * numproc to | + | * numproc to 400 |
− | * tcpsndbuf to | + | * tcpsndbuf to 1720320:2703360 |
− | * tcprcvbuf to | + | * tcprcvbuf to 1720320:2703360 |
− | * | + | * vmguardpages to 2097152:unlimited |
+ | * oomguardpages to 26112:unlimited | ||
+ | |||
+ | And according to DB2 9 documentation, the following minimal guest kernel options must be set in /etc/sysctl.conf: | ||
+ | <pre>kernel.shmmax = 1073741824 | ||
+ | kernel.sem = 250 256000 32 1024 | ||
+ | kernel.msgmax = 65535 | ||
+ | kernel.msgmnb = 65535</pre> | ||
== Install additional packages == | == Install additional packages == | ||
Line 42: | Line 49: | ||
* Run exp/disk1/db2setup | * Run exp/disk1/db2setup | ||
* Follow the prompts: | * Follow the prompts: | ||
− | + | ** Setup user 'dasusr1' | |
− | + | ** Setup user 'db2inst1' and database instance 'db2inst1' | |
== Post-install actions == | == Post-install actions == | ||
− | This is where it gets yukky. DB2 wants to run a browser inside the | + | This is where it gets yukky. DB2 wants to run a browser inside the VE. It wants to run Java applets inside the browser. I installed Iceweasel, but the post-install script does not recognise it. I was eventually able to hack the script to recognise and use the browser but it crashed on one of the Java applets. I think you can get by without running the post-install. |
Here's what to do instead: | Here's what to do instead: | ||
Line 62: | Line 69: | ||
If these don't work it means your environment variables are not set properly. IBM set these for me: | If these don't work it means your environment variables are not set properly. IBM set these for me: | ||
− | + | CLASSPATH=/home/db2inst1/sqllib/java/db2java.zip:/home/db2inst1/sqllib/java/db2jcc.jar:/home/db2inst1/sqllib/java/sqlj.zip:/home/db2inst1/sqllib/function:/home/db2inst1/sqllib/java/db2jcc_license_cu.jar:. | |
− | + | DB2INSTANCE=db2inst1 | |
− | + | PATH=/usr/local/bin:/usr/bin:/bin:/usr/games:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc | |
Try creating IBM's sample database: | Try creating IBM's sample database: | ||
Line 108: | Line 115: | ||
;; | ;; | ||
esac | esac | ||
− | + | ||
exit 0 | exit 0 | ||
And I used this command to create the symlink to make it start at VE "boot" time: | And I used this command to create the symlink to make it start at VE "boot" time: | ||
− | + | update-rc.d db2 start 95 2 . | |
== Testing your installation == | == Testing your installation == | ||
Line 123: | Line 130: | ||
Inside the db2 client, try: | Inside the db2 client, try: | ||
− | + | connect to sample | |
− | + | grant dbadm on database to user fred | |
− | + | connect reset | |
+ | |||
+ | == Enjoy! == | ||
+ | |||
+ | Please provide feedback in the discussion (Talk) page about improvements to this HOWTO. | ||
+ | |||
+ | [[Category:HOWTO]] |
Latest revision as of 07:49, 20 September 2010
DB2 has been certified by IBM for use inside Virtuozzo. It works in OpenVZ too!
IBM provides a free download of DB2 Express-C which is what I installed.
Here is a rough guide to installing DB2 into a freshly-created VE.
Contents
Create a new VE[edit]
I created a new VE for the Debian distribution using debootstrap, as described in Debian template creation.
Set VE resource limits appropriately[edit]
These are tested resource limits for x86-64 system running Debian/GNU Linux 5.0.6:
- kmemsize to 26214400:29491200
- privvmpages to 2097152:unlimited
- shmpages to 1572864
- numproc to 400
- tcpsndbuf to 1720320:2703360
- tcprcvbuf to 1720320:2703360
- vmguardpages to 2097152:unlimited
- oomguardpages to 26112:unlimited
And according to DB2 9 documentation, the following minimal guest kernel options must be set in /etc/sysctl.conf:
kernel.shmmax = 1073741824 kernel.sem = 250 256000 32 1024 kernel.msgmax = 65535 kernel.msgmnb = 65535
Install additional packages[edit]
- libstdc++5 (required for installation)
- pdksh (required for operation?)
- ssh (may be required for operation)
- xbase-clients (for xauth)
- firefox (for post-installation)
- strace and telnet (for debugging)
- libdbi-perl gcc libc6-dev make (for building CPAN DBD::DB2 package)
Download the DB2 Express-C package[edit]
DB2 Express-C version 9 is available from this page: [[1]]
You will need to register with IBM before you can download.
- Untar the received file as root
- Run exp/disk1/db2setup
- Follow the prompts:
- Setup user 'dasusr1'
- Setup user 'db2inst1' and database instance 'db2inst1'
Post-install actions[edit]
This is where it gets yukky. DB2 wants to run a browser inside the VE. It wants to run Java applets inside the browser. I installed Iceweasel, but the post-install script does not recognise it. I was eventually able to hack the script to recognise and use the browser but it crashed on one of the Java applets. I think you can get by without running the post-install.
Here's what to do instead:
First, su to the instance owner:
- su - db2inst1
Try starting and stopping the database:
- db2start
- db2stop
If these don't work it means your environment variables are not set properly. IBM set these for me:
CLASSPATH=/home/db2inst1/sqllib/java/db2java.zip:/home/db2inst1/sqllib/java/db2jcc.jar:/home/db2inst1/sqllib/java/sqlj.zip:/home/db2inst1/sqllib/function:/home/db2inst1/sqllib/java/db2jcc_license_cu.jar:. DB2INSTANCE=db2inst1 PATH=/usr/local/bin:/usr/bin:/bin:/usr/games:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc
Try creating IBM's sample database:
- db2sampl
Setup a development environment[edit]
I develop in perl so I was most interested in access to the database though the DBI library. I did this:
- Use CPAN to download and install DBD::DB2
If you don't use CPAN you can also do this (as root):
- Download http://search.cpan.org/CPAN/authors/id/I/IB/IBMTORDB2/DBD-DB2-1.1.tar.gz
- Untar the file and change into the directory
- perl Makefile.PL PREFIX=/usr
- make
- make test
- make install
Setup DB2 for autostart[edit]
It seems that DB2 can be auto-started at VE boot time, but not auto-stopped. I used this script:
#!/bin/sh # # Script to start DB2 instances on bootup. # set -e . /lib/lsb/init-functions case "$1" in start) echo Starting DB2 /opt/ibm/db2/V9.1/instance/db2istrt ;; stop) ;; restart|reload) ;; esac exit 0
And I used this command to create the symlink to make it start at VE "boot" time:
update-rc.d db2 start 95 2 .
Testing your installation[edit]
From the db2inst1 user, do:
- db2
Inside the db2 client, try:
connect to sample grant dbadm on database to user fred connect reset
Enjoy![edit]
Please provide feedback in the discussion (Talk) page about improvements to this HOWTO.