Anil Mahadev's picture

 

DubuntuTKL Patch 

         

The easiest way to get started on DB2              

                                                              

Ever wanted to get started with DB2 quickly?
Did you ever want to build an appliance with DB2 without much fuss?
Are you into Appliance Customization / Management creation?
Do you wish you could install DB2 seamlessly without any hassles?
 
If the above answers, you answered YES, then the DubuntuTKL Appliance is for you!
 
The Dubuntu-TKL patch is the first of its kind patch that is needed to successfully build and deploy DB2 Express-C based Appliances for your custom applications and usage.                                                            

QuickStart Approach

Ready-Set-Patch! Dubuntu!
 
 
1) Download the TKL-Core-Appliance.ISO and the Dubuntu-tkl.tar.gz patch attached
dubuntu-tkl.tar.gz
2) Run the command
    tklpatch tkl-core.iso dubuntu-tkl.tar.gz
3) Then TKLpatch do the Magic! and you have the ISO ready for Deployment

 

Indepth Step by Step Approach [ Developers Section ]

 

   Step by Step approach to building and using the Dubuntu-TKL Patch

1. Pre-requiste setup

2. Using TKL-Core Appliance as base

3. Making changes to the conf file

4. TKL-Apply the patch

5. Bundle the patch

6. Finally build the patch and generate the ISO
 

Introduction:


1. Pre-requiste setup

Dev-Patch - Turnkey-Core Appliance, Turnkey LAMP Appliance(For Dev Web Server to place the DB2 Express-C debs), DB2 Express-C 9.7 deb and of course TKLpatch
Prod-Patch - Turnkey-Core Appliance, DB2 Express-C 9.7 deb and of course TKLpatch + A fast internet connection as we need to download the DB2 debs from the FTP site
 
To download the DB2 Express-C deb for i386 visit the following site
[Note: For re-distributing DB2 Express-C you will need to request a Free Redistribution License from IBM . It's Free!]

The link to the website
 
For setting up the Prod-Patch use the url below in the conf file

For setting up the Dev-Patch place the downloaded deb in the TKL-LAMP Stack appliance's /var/www directory

2. Using TKL-Core Appliance as base

a) You will now need to create a VM using the TKL-Core Appliance as the base VM.

b) Next copy and place the TKL-Core Appliance.iso file in the root directory of the appliance.

c) Now run and install some pre-requisites
apt-get update
apt-get install wget

Now under the root dir, issue the command

tklpatch-example dubuntutkl-dev

and hit enter

e) You should now have a directory [dubuntutkl-dev]

f) Copy the TKL-Core Appliance.iso to the dubuntutkl-dev directory

g) Navigate to the dubuntutkl-dev directory

h) Extract the TKL-Core-Appliance.iso , by issuing the command  
 
tklpatch-extract-iso turnkey-core-2009.10-hardy-x86.iso
 
 

After this operation completes, you will two directories, one called [turnkey-core-2009.10-hardy-x86.cdroot] and the other [turnkey-core-2009.10-hardy-x86.rootfs]

We are now almost set for the dev-patch.


[Part II - Dev-Patch] Very Important

3) Editing the Conf file

[The default conf file]

#!/bin/bash -ex
install()
{
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y \
-o DPkg::Options::=--force-confdef \
-o DPkg::Options::=--force-confold \
install $@
}

# installs hello - a highly useful package
install hello

# tell the world what we've done!
echo 'Hello world - I just patched TurnKey!' >> /etc/issue
 


[Replace it with this content for the Dev-Patch to work]
#!/bin/bash -ex
install()
{
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y \
-o DPkg::Options::=--force-confdef \
-o DPkg::Options::=--force-confold \
install $@
}
DEPS="wget libaio1 bc ksh libasound2 libx11-6 libxext6 libxft2 libxi6 libxp6 libxtst6 libstdc++5"
install $DEPS

export TERM=rxvt
wget http://192.168.35.139/db2exc_9.7.0-8_i386.deb
dpkg -i db2exc_9.7.0-8_i386.deb
rm db2exc_9.7.0-8_i386.deb

HOSTNAME="dubuntutkl"
echo "$HOSTNAME" > /etc/hostname
sed -i "s|127.0.1.1 \(.*\)|127.0.1.1 $HOSTNAME|" /etc/hosts

rm -rf /var/cache/apt/*
mkdir -p /var/cache/apt/archives/partial

Let's explore what each section does before we build our patch

The install() function first does an apt-get update to ensure all the dependencies are satisfied for the Core-Appliance Root FileSystem.

Next we define a variable called DEPS, which downloads the required dependencies for DB2 to function and install properly.

We call the install $DEPS variable

[Note: For DB2 Express-C to install properly a TERM variable needs to be defined prior to the install as it is a pre-requisite. Otherwise, the install will fail]

export TERM=rxvt

Now using the TKL-LAMP appliance where we have placed the db2exc_9.7.0-8_i386.deb file, it will download it for faster development.

Replace the IP address of your TKL-LAMP Appliance in place of the IP address shown above.

[Note: the use of a local Web server is used only in development and is not recommended for Production Development]

dpkg -i db2exc_9.7.0-8_i386.deb - will install DB2 Express-C on your system

During the installation, you might get the following messages
Starting DAS - failed
Starting db2inst1 - failed
 
 
Don't Panic :-). Let the patch do the magic.
It will work when the ISO is loaded into a VM or installed :-).
 
rm db2exc_9.7.0-8_i386.deb - will remove the Debian package to save on disk space
 
Next we come to configuring our custom HOSTNAME = dubuntuTKL
Feel free to choose whatever name you wish.
[Note: Only change the section : HOSTNAME="Your HostName"]

Finally, we will be cleaning up our APT cache to save on Space during ISO creation
To do this, the command below is given
 
rm -rf /var/cache/apt/* - Cleans out the APT cache
mkdir -p /var/cache/apt/archives/partial - Recreates the APT system and ensures all the hierarchies are in place
 


Part II (b) - Prod Conf File Contents
 

Replace the default conf file when creating the dubuntutkl-prod patch with the text below

[PROD Patch]

#!/bin/bash -ex
install()
{
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y \
-o DPkg::Options::=--force-confdef \
-o DPkg::Options::=--force-confold \
install $@
}
DEPS="wget libaio1 bc ksh libasound2 libx11-6 libxext6 libxft2 libxi6 libxp6 libxtst6 libstdc++5"
install $DEPS

export TERM=rxvt
wget ftp://ftp.software.ibm.com/software/data/db2/express/Ubuntu/debs/x86/9.7.0/db2exc_9.7.0-8_i386.deb
dpkg -i db2exc_9.7.0-8_i386.deb
rm db2exc_9.7.0-8_i386.deb

HOSTNAME="dubuntutkl"
echo "$HOSTNAME" > /etc/hostname
sed -i "s|127.0.1.1 \(.*\)|127.0.1.1 $HOSTNAME|" /etc/hosts

rm -rf /var/cache/apt/*
mkdir -p /var/cache/apt/archives/partial

As you notice, the only difference here is that we are downloading it live from an FTP Server

Save and close the file.

4) Applying the Patch

Now we are ready to apply the patch.

Issue the following command
 
tklpatch-apply turnkey-core-2009.10-hardy-x86.rootfs/ /root/dubuntutkl-dev/ [ Dev-Patch Only]

tklpatch-apply turnkey-core-2009.10-hardy-x86.rootfs/ /root/dubuntutkl-prod/ [ Prod-Patch Only]

The above command will now start applying the patch to the rootfs as per the conf file's specification
This will take sometime to finish. Please be patient

[Common Issues for failing to apply the patch]
 
  1. Internet broken downloads
  2. Wrong path to DB2 ex.deb in your TKL-LAMP Appliance
Once done, do a cleanup

[Remember to do this in the following order to avoid confusion]

1) Navigate to the overlay directory and issue the command

rm -rf usr - this will remove the usr directory

2) now in the patch-directory remove the following directories

turnkey-core-2009.10-hardy-x86.cdroot

turnkey-core-2009.10-hardy-x86.rootfs

and

turnkey-core-2009.10-hardy-x86.iso


5) Bundle the patch

 

Now its time to bundle the patch
Issue the command
tklpatch-bundle /root/dubuntutkl-dev/


It will create a bundle with a filename like dubuntutkl-dev.tar.gz and bundles it into a tarball

6) Final Procedure to build the Patch and deploy for ISO Creation
 Now the time has come to build the patch.
 Now come out of the patch directory  and Issue the command
tklpatch turnkey-core-2009.10-hardy-x86.iso dubuntutkl-dev.tar.gz


 and hit enter

Finally the patch process begins, it will finally create an ISO in our case , dubuntutkl-dev.iso


Next Steps

 
 
[Post-Patch Appliance Building Instructions]

 Upon building the Appliance ISO, Follow these instructions to use them

1) The Live System does not require a password for the root user + db2inst1 + db2fenc1 + dasusr1

2) During the installation the appliance, you can choose to enter a custom root password.

The db2inst1 + db2fenc1 + dasusr1 require no passwords

To secure your DB2 usernames enter the following commands at the root prompt

passwd db2inst1 passwd db2fenc1 passwd dasusr1  Enter your desired password Your Appliance is now Secure

Congratulations! You have now created your first patch for DB2 Express-C and can now use it and share it with the World!

You can now test it using VMware or any Virtualization Platform you wish.

 

Forum: 
Tags: 
Liraz Siri's picture

Anil, thanks for putting together the DB2 appliance. I would love to include a community version of DB2 in the appliance library but from my research it seems IBM have yet to open source any version of DB2. There was talk a while back about that changing but IBM have yet to move forward on that.

Anil Mahadev's picture

Hi Liraz,

Thanks, I am humbled. Yes, I read about it as well.

Well, we can only hope there may be one in the near future.

Cheers!

Anil

Add new comment