Friday, June 3, 2011

Installing DB2 Express C V9.7 Ubuntu 11.04 64 bit

Before installing the DB2 express C, install the Java first.

Step how to install Java 6
1. Open the file /etc/apt/source.list.
    sudo nano /etc/apt/sources.list

2. Search the following two lines and uncomment it and then save the file.
Tip:
    To SEARCH a context using nano editor press [CTRL W] then type the text [archive.canonical] then press enter and you will see the cursor pointing to one of the result.
    To SAVE a file press using nano editor press [CTRL X] then press Y for yes
 

    deb http://archive.canonical.com/ubuntu/ natty partner
    deb-src http://archive.canonical.com/ubuntu/ natty partner

3. Issue the following command
    sudo apt-get update
    sudo apt-get install sun-java6-jdk
Note: This will take several minutes depends on your bandwidth.

4. Execute the command to check if the java is really installed
    java -version
        java version "1.6.0_24"
        Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
        Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
 

5. Now your done for Java installation.

Steps on how to Install DB2 Express C to Ubuntu 11.04

1. Download the DB2 Express C 9.7 from IBM website
 

2. Extract the file using command "sudo tar -zxvf "
 

3. Execute the command to check if db2 have the required library
      "sudo ./db2prereqcheck"

4. If there is an warning or error like the message below, go to step 5 else go to to step 6
WARNING:
   The 32 bit library file libstdc++.so.6 is not found on the system.
   32-bit applications may be affected. 
ERROR:
   The required library file libaio.so.1 is not found on the system.
   Check the following web site for the up-to-date system requirements
   of IBM DB2 9.7
   http://www.ibm.com/software/data/db2/udb/sysreqs.html
   http://www.software.ibm.com/data/db2/linux/validate 

5. You only need to execute the command below if you see similar message from step 4
    Command to fix step 4: sudo apt-get install libaio1

6. Now lets force to install the DB2 even if there is a warning message
    sudo ./db2install -f sysreq

7. After installing the DB2 express C core on the default directory "/opt/ibm/db2/V9.7" we still need to configure the installed DB2.

Steps for configuring the installed DB2
1. We need to login as a root using the command "su"

2. Add the following user db2inst1, db2fenc1 and db2das1
    useradd -m db2inst1
    passwd db2inst1

    useradd -m db2fenc1
    passwd db2fenc1

    useradd -m db2das1
    passwd db2das1
Note:     db2das1 user is for administration server instance
    db2inst1 user is a single instance DB user
   
3. Execute the command below to assign db2das1 for administrative role in DB2
    [your DB2 directory]/instance/dascrt -u db2das1

4. Now, lets create a db2 instance user
    [your DB2 directory]/instance/db2icrt -a server -u db2fenc1 db2inst1

5. Next lets create a link
    [your DB2 directory]/cfg/db2ln

Next Steps is to enable the TCP access to DB2

1. sudo nano /etc/services
        db2c_db2inst1 10100/tcp # DB2 connection service port

2. logout and login as db2inst1 user

3. Stop and start the db2
    db2stop [enter]
    db2start [enter]

4. Update the manager config
    db2 [enter]
            type "update database manager configuration using svcename db2c_db2inst1" then [enter]

3. Stop and start the db2
    db2stop [enter]
    db2start [enter]

5. Verify the config
    db2 [enter]
            type "get database manager config" then [enter]

6. Quit the db2 CLP by entering "quit"

7. Set the DB2COMM
    db2set DB2COMM=tcpip [enter]

8. Stop and start the db2
    db2stop [enter]
    db2start [enter]

9. Check if the TCP IP is open netstat -lnt | grep 10100
        tcp        0      0 0.0.0.0:10100           0.0.0.0:*               LISTEN

10. Now you're done and the DB2 is read to use.

If you want to have an automatic startup of your DB2 please follow the steps below:

1. Create a file in /etc/init.d/db2
    sudo nano /etc/init.d/db2

2. Copy and paste all the content below to the "db2" file and save it "CTRL X" then "Y"
#! /bin/sh
        set -e
        case "$1" in
          start)
                sudo su - db2inst1 -c 'db2start' >> /tmp/db2initd.log
                sudo su - db2das1 -c 'db2admin start' >> /tmp/db2initd.log
                ;;
          stop)
                sudo su - db2das1 -c 'db2admin stop' >> /tmp/db2initd.log
                sudo su - db2inst1 -c 'db2stop' >> /tmp/db2initd.log
                ;;
          *)
                exit 1
        esac
        exit 0

3. Change the mod of the file with +x
    sudo chmod +x /etc/init.d/db2

4. Add the the "/etc/init.d/db2 start" before exit 0 to /etc/rc.local
    sudo nano /etc/rc.local

    .....
    /etc/init.d/db2 start
    .....
    exit 0
 
For more information just post your comments. By i101