Command Line DB2 Install Example

by bitznbitez

I am a command line junkie, preferring it often to GUI’s.    Tonight I setup a demo instance of db2 9.7 Express C 64 bit on Linux Mint.    First I went to IBM and downloaded and untarred the appropriate archive file.

Next as user root I performed the following

blackwater Downloads # cd special_27924_linuxamd64_expc/
blackwater special_27924_linuxamd64_expc # ls
db2 db2ckupgrade db2_deinstall db2_install db2ls db2prereqcheck db2setup doc readmefirst readmefirst.htm readmefirst.txt
blackwater special_27924_linuxamd64_expc # ./db2_install 

Default directory for installation of products - /opt/ibm/db2/V9.7
***********************************************************
Do you want to choose a different directory to install [yes/no] ?
no
DB2 installation is being initialized.
Total number of tasks to be performed: 38
Total estimated time for all tasks to be performed: 1284
Task #1 start
Description: Checking license agreement acceptance
Estimated time 1 second(s)
Task #1 end
Task #2 start
Description: Base Client Support for installation with root privileges
Estimated time 3 second(s)
Task #2 end
...
Task #38 start
Description: Updating global profile registry
Estimated time 3 second(s)
Task #38 end
The execution completed successfully.
For more information see the DB2 installation log at
"/tmp/db2_install.log.19959".
blackwater special_27924_linuxamd64_expc # groupadd -g 999 db2iadm1
blackwater special_27924_linuxamd64_expc # set -o vi
blackwater special_27924_linuxamd64_expc # groupadd -g 998 db2fadm1
blackwater special_27924_linuxamd64_expc # groupadd -g 997 dasadm1
blackwater special_27924_linuxamd64_expc # useradd -g db2iadm1 -m -d /home/db2inst1 db2inst1
blackwater special_27924_linuxamd64_expc # useradd -g db2iadm1 -m -d /home/db2fenc1 db2fenc1
blackwater special_27924_linuxamd64_expc # useradd -g dasadm1 -m -d /home/dasusr1 dasusr1
blackwater special_27924_linuxamd64_expc # passwd db2inst1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
blackwater special_27924_linuxamd64_expc # passwd db2fenc1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
blackwater special_27924_linuxamd64_expc # passwd dasusr1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
blackwater special_27924_linuxamd64_expc # /opt/ibm/db2/V9.7/instance/db2icrt -u db2fenc1 db2inst1

DBI1070I Program db2icrt completed successfully.
blackwater special_27924_linuxamd64_expc #

Next I tried to start it after some poking around only to discover I’d forgot the libaio-dev package which enables asynchronous io in the kernel in linux Linux.

blackwater special_27924_linuxamd64_expc # su - db2inst1
$ ls -la
total 36
drwxr-xr-x 7 db2inst1 db2iadm1 4096 2012-01-24 21:38 .
drwxr-xr-x 7 root root 4096 2012-01-24 21:36 ..
-rw-r--r-- 1 db2inst1 db2iadm1 220 2011-03-31 17:20 .bash_logout
drwxr-xr-x 4 db2inst1 db2iadm1 4096 2012-01-24 21:38 .config
drwxr-xr-x 3 db2inst1 db2iadm1 4096 2012-01-24 21:38 .ibm
drwxr-xr-x 3 db2inst1 db2iadm1 4096 2012-01-24 21:38 .local
drwxr-xr-x 4 db2inst1 db2iadm1 4096 2011-12-31 06:52 .mozilla
-rw-r--r-- 1 db2inst1 db2iadm1 844 2012-01-24 21:38 .profile
drwxrwsr-t 19 db2inst1 db2iadm1 4096 2012-01-24 21:38 sqllib
$ which db2
/home/db2inst1/sqllib/bin/db2
$ db2start
db2start: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

So then had to install the libaio-dev product by becoming root again as follows…..

blackwater special_27924_linuxamd64_expc # apt-get install libaio-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
 libopenal1 libmjpegtools-1.9 libunshield0 unrar gstreamer0.10-plugins-ugly libdiscid0 libbluray0 libsvga1 libquicktime1 libdvdcss2 gstreamer0.10-plugins-bad-multiverse w64codecs unshield mplayer gstreamer0.10-ffmpeg mint-flashplugin-square liblzo2-2
 cabextract gecko-mediaplayer apport-hooks-medibuntu libxvidcore4 libsidplay1 libvdpau1 libmusicbrainz3-6 libid3tag0 libopencore-amrnb0 gstreamer0.10-plugins-ugly-multiverse gnome-mplayer libopencore-amrwb0 libfaac0
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
 libaio1
The following NEW packages will be installed:
 libaio-dev libaio1
0 upgraded, 2 newly installed, 0 to remove and 30 not upgraded.
Need to get 36.5 kB of archives.
After this operation, 258 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://archive.ubuntu.com/ubuntu/ natty/main libaio1 amd64 0.3.107-7ubuntu2 [6,250 B]
Get:2 http://archive.ubuntu.com/ubuntu/ natty/main libaio-dev amd64 0.3.107-7ubuntu2 [30.2 kB]
Fetched 36.5 kB in 0s (39.1 kB/s)
Selecting previously deselected package libaio1.
(Reading database ... 263892 files and directories currently installed.)
Unpacking libaio1 (from .../libaio1_0.3.107-7ubuntu2_amd64.deb) ...
Selecting previously deselected package libaio-dev.
Unpacking libaio-dev (from .../libaio-dev_0.3.107-7ubuntu2_amd64.deb) ...
Processing triggers for man-db ...
Setting up libaio1 (0.3.107-7ubuntu2) ...
Setting up libaio-dev (0.3.107-7ubuntu2) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
blackwater special_27924_linuxamd64_expc # blackwater special_27924_linuxamd64_expc #

With that out of the way I return to user db2inst1 and start the instance as follows

#su - db2inst1
$ db2start
SQL1063N DB2START processing was successful.
$ db2sampl
Creating database "SAMPLE"...
 Connecting to database "SAMPLE"...
 Creating tables and data in schema "DB2INST1"...
 Creating tables with XML columns and XML data in schema "DB2INST1"...
'db2sampl' processing complete.
$ db2 connect to sample
Database Connection Information
Database server = DB2/LINUXX8664 9.7.5
 SQL authorization ID = DB2INST1
 Local database alias = SAMPLE
$

Now I observe I still have bash so I edit, as root, the /etc/passwd file and change /bin/sh to /bin/bash for the 3 new users.   Returning to user db2inst1 I run “db2stop” and “db2start” to ensure no complications.

Now I must configure TCPIP communication.   As root I add the following line to /etc/services

db2c_db2inst1 50001/tcp

Now again as db2inst1 we configure the port name for the instance to listen on.   And then set the registry variable to tell db2 to listen for TCPIP connections.

db2inst1@blackwater ~ $ db2 get dbm cfg | grep -i svcename
 TCP/IP Service name (SVCENAME) =
 SSL service name (SSL_SVCENAME) =
db2inst1@blackwater ~ $ db2 update dbm cfg using SVCENAME db2c_db2inst1
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
db2inst1@blackwater ~ $ db2 get dbm cfg | grep -i svcename
 TCP/IP Service name (SVCENAME) = db2c_db2inst1
 SSL service name (SSL_SVCENAME) =
db2inst1@blackwater ~ $
db2inst1@blackwater ~ $ db2set -all
[g] DB2_COMPATIBILITY_VECTOR=MYS
[g] DB2SYSTEM=blackwater
[g] DB2ADMINSERVER=dasusr1
db2inst1@blackwater ~ $ db2set DB2COMM=TCPIP
db2inst1@blackwater ~ $ db2set -all
[i] DB2COMM=TCPIP
[g] DB2_COMPATIBILITY_VECTOR=MYS
[g] DB2SYSTEM=blackwater
[g] DB2ADMINSERVER=dasusr1

Now we have a functioning db2 instance with the sample database listening for tcpip connections and we are ready to do whatever else we wish to do.

Advertisements