Installing Oracle Instant Client and DBD::Oracle on Ubuntu Linux 8.04 Server JEOS

Ever want to just install the minimal amount of Oracle client software for client applications on Linux? Well, Oracle has provided Oracle Instant Client to do this but they have neglected to make it intuitive to install. I’ve written a couple scripts that make it easy on Linux. I’ve tested this on Ubuntu Linux 8.04 Server JEOS.

Download the files you need

Download Oracle Instant Client

Retrieve the Instant Client packages and save them to a directory (e.g. “linux 32bit”).

  • Instant Client Package – Basic
  • Instant Client Package – JDBC Supplement
  • Instant Client Package – SQL*Plus
  • Instant Client Package – SDK
  • Instant Client Package – ODBC

Download DBD::Oracle and place it in the build-cfg directory

Copy your tnsnames.ora file into the build-cfg directory

Download build_oracle_instantclient.sh into the directory above build-cfg directory

Save root.sh into the build-cfg directory

Build a tar ball containing everything we need in the directory format we need.

build_oracle_instantclient.sh "../linux 32bit"

Script1: build_oracle_instantclient.sh

SOURCE_DIR="$1"
BUILD_DIR=builddir
CFG_DIR=build-cfg

if [[ -z $1 ]]; then
  echo "Usage: build_oracle_instantclient.sh <directory containing oracle instant client zip files>"
  exit 1
fi

if [[ ! -d "${SOURCE_DIR}" ]]; then
   echo "${SOURCE_DIR} is not a directory"
   exit 1
fi

find "${SOURCE_DIR}" -name "*.zip" -type f -exec unzip {} \;

if [[ -d instantclient_11_1 ]]; then
  TMP_DIR=instantclient_11_1
elif [[ -d instantclient_10_2 ]]; then
  TMP_DIR=instantclient_10_2
else
  echo "unable to determine extraction dir"
  exit 1
fi

if [[ -d ${BUILD_DIR} ]]; then
  rm -rf ${BUILD_DIR}
fi

mkdir -p ${BUILD_DIR}
mkdir -p ${BUILD_DIR}/bin
mkdir -p ${BUILD_DIR}/doc
mkdir -p ${BUILD_DIR}/java
mkdir -p ${BUILD_DIR}/lib

cp ${CFG_DIR}/* ${BUILD_DIR}
mv ${TMP_DIR}/*README* ${BUILD_DIR}/doc
mv ${TMP_DIR}/*.html ${BUILD_DIR}/doc
mv ${TMP_DIR}/*.htm ${BUILD_DIR}/doc
mv ${TMP_DIR}/lib* ${BUILD_DIR}/lib
mv ${TMP_DIR}/*.jar ${BUILD_DIR}/java
mv ${TMP_DIR}/sdk ${BUILD_DIR}
mv ${TMP_DIR}/* ${BUILD_DIR}/bin

cd ${BUILD_DIR}/lib
ln -s libclntsh.so.* libclntsh.so
ln -s libocci.so.* libocci.so
ln -s libsqora.so.* libsqora.so

cd ..
tarball=`echo ${SOURCE_DIR} | tr ' ' '-'`
tarball=`basename ${tarball}`
tarball=Oracle-${TMP_DIR}-${tarball}
tar cvf - * | gzip -9c > "../${tarball}.tgz"

cd ..
rm -rf ${BUILD_DIR} ${TMP_DIR}

Once we have the tar ball, we can copy that file to any compatible Linux system, extract it and run the root.sh file which will copy the install to /usr/local/oracle/InstantClient, set up the system variables and build DBD::Oracle for you.

Script2: root.sh

#!/bin/bash

############################################
function copy_instantclient () {
  if [[ `pwd` != "/usr/local/oracle/InstantClient" ]]; then
    if [[ ! -d /usr/local/oracle/InstantClient ]]; then
      echo "Creating /usr/local/oracle/InstantClient directory"
      mkdir -p /usr/local/oracle/InstantClient
    fi

    echo "Copying Oracle Instant Client to /usr/local/oracle/InstantClient" 
    cp -Ra * /usr/local/oracle/InstantClient
  fi
}

#---------
function update_etc_profile () {
  if [[ -f /etc/profile ]]; then
    if [[ `grep -c "ORACLE_HOME" /etc/profile` = 0 ]]; then 
      echo "Updating /etc/profile"
      cat >> /etc/profile < < EOF
  export ORACLE_HOME=/usr/local/oracle/InstantClient
  export TNS_ADMIN=\${ORACLE_HOME}
  export PATH=\${ORACLE_HOME}/bin:\${PATH}
  export CLASSPATH=\${ORACLE_HOME}/classes:\${CLASSPATH}
  export LD_LIBRARY_PATH=\${ORACLE_HOME}/lib:\${LD_LIBRARY_PATH}
  export SQLPATH=\${ORACLE_HOME}/bin
EOF
    else
      echo "Updates to /etc/profile already applied"
    fi
  fi
}

#---------
function update_library_cache () {
  if &#91;&#91; -d /etc/ld.so.conf.d &#93;&#93;; then
    if &#91;&#91; -f /etc/ld.so.conf.d/oracle_instant_client.conf &&  `grep -c "/usr/local/oracle/InstantClient" /etc/ld.so.conf.d/oracle_instant_client.conf` != 0 &#93;&#93;; then
       echo "Updates to /etc/ld.so.conf.d/oracle_instant_client.conf already applied"
    else
      echo "Updating /etc/ld.so.conf.d/oracle_instant_client.conf"
      echo "/usr/local/oracle/InstantClient" > /etc/ld.so.conf.d/oracle_instant_client.conf
      /sbin/ldconfig
    fi
  else
    if [[ `grep -c "/usr/local/oracle/InstantClient" /etc/ld.so.conf` == 0 ]]; then
      echo "Updating /etc/ld.so.conf"
      echo "/usr/local/oracle/InstantClient" > /etc/ld.so.conf
      /sbin/ldconfig
    else
      echo "Updates to /etc/ld.so.conf already applied"
    fi 
  fi
}

#---------
function print_env () {
  echo "Add the following to the rc.d script for any daemon processes that need to access Oracle.  For example, apache"
  echo '  export ORACLE_HOME=/usr/local/oracle/InstantClient
  export TNS_ADMIN=${ORACLE_HOME}
  export PATH=${ORACLE_HOME}/bin:${PATH}
  export CLASSPATH=${ORACLE_HOME}/classes:${CLASSPATH}
  export LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}
  export SQLPATH=${ORACLE_HOME}/bin'
}

#---------
function install_DBD-Oracle () {
  echo "Building DBD::Oracle"
  DBDORA=`ls DBD-Oracle-*`

  if [[ -f ${DBDORA} ]]; then
    tar zxf ${DBDORA} 
    cd DBD-Oracle* 
    TMP_DBDORA=`pwd`
    TMP_DBDORA=`basename ${TMP_DBDORA}`
  	perl Makefile.PL -m $ORACLE_HOME/sdk/demo/demo.mk
    make && make install
    cd ..
    rm -rf ${TMP_DBDORA}
  else
    echo "Unable to find DBD-Oracle file"
  fi
}

############################################

export ORACLE_HOME=/usr/local/oracle/InstantClient
export TNS_ADMIN=${ORACLE_HOME}
export PATH=${ORACLE_HOME}/bin:${PATH}
export CLASSPATH=${ORACLE_HOME}/classes:${CLASSPATH}
export LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}
export SQLPATH=${ORACLE_HOME}/bin

copy_instantclient
update_etc_profile
update_library_cache
print_env
install_DBD-Oracle

Share Button

Installing Oracle 10g / 11g on Ubuntu 8.04.1 (Hardy Heron) Server JEOS in VMware Server 1.0x/2.0x

I’ve been tasked with becoming an Oracle DBA, so I need to be able to create an VMware Server image containing 32 bit Ubuntu 8.04.1 Server JEOS and Oracle 10g. Much of the work was taken from Augusto Bott‘s Installing Oracle 11g on Ubuntu Linux 7.10 (Gutsy Gibbon) and Peter Cooper‘s How to Install VMware Tools on Ubuntu Hardy 8.04 under VMware Fusion.

I was able to consolidate the methods to work rather well together. As soon as Ubuntu 8.10 Server JEOS (Intrepid) is released, I’ll verify the procedure on that operating system as well.

If you’re looking for instructions on how to install Oracle 11 XE on Ubuntu 8.04.1, look at Installing Oracle Database XE on Debian, Ubuntu, and Kubuntu by Todd Trichler.
Create a VMware Image with the following settings

  1. Choose 32bit Ubuntu for the OS type
  2. 1024 MBytes RAM
  3. 16GBytes disk space
  4. Ubuntu 8.04.1 (or higher) Server JEOS edition http://www.ubuntu.com/products/whatisubuntu/serveredition/jeos
  5. Upon the os installation, create a non “oracle” id to use to administer the os.

Install the required updates and packages

$ sudo aptitude update
sudo aptitude safe-upgrade
sudo aptitude install build-essential xinetd linux-headers-`uname -r` openssh-client openssh-server unzip libaio1 gawk ksh rpm libmotif3 alien lsb-rpm libtool libxtst-dev libxtst6 libstdc++5

Add swap

$ sudo dd if=/dev/zero of=/extraswap bs=1M count=1536
sudo mkswap /extraswap
sudo swapon /extraswap
sudo echo "/extraswap   none   swap   sw   0   0" >> /etc/fstab

# "/sbin/swapon -s" should show the added swap space
/sbin/swapon -s
Filename				Type		Size	Used	Priority
/dev/mapper/oracle10g-swap_1            partition	401400	92	-1
/extraswap                              file		1048568	0	-2

If VMware Server version is 2.0x or higher, install VMware tools:

$ sudo su - root
mount /dev/cdrom
cp /media/cdrom/*.gz ~
tar zxvf VMwareTools*.tar.gz
cd vmware-tools-distrib
./vmware-install.pl

If VMware Server version is 1.0x, install VMware tools:

$ sudo su - root
mount /dev/cdrom
cp /media/cdrom/*.gz ~
aptitude install libgtk2.0-dev libproc-dev libdumbnet-dev xorg-dev wget
wget http://mesh.dl.sourceforge.net/sourceforge/open-vm-tools/open-vm-tools-2008.04.14-87182.tar.gz
tar xzvf VMware*.gz ; sudo tar xzvf open-vm-tools*.gz ; cd open-vm-tools-2008.04.14-87182/
./configure && make
cd modules/linux/
for i in *; do mv ${i} ${i}-only; tar -cf ${i}.tar ${i}-only; done
cd ../../..
mv -f open-vm-tools-2008.04.14-87182/modules/linux/*.tar vmware-tools-distrib/lib/modules/source/ ; cd vmware-tools-distrib/
sudo ./vmware-install.pl
sudo reboot

Append to /etc/sysctl.conf

$ sudo cat >> /etc/sysctl.conf < <EOF
fs.file-max = 65535
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
EOF&#91;/bash&#93;

Append to /etc/security/limits.conf
&#91;bash&#93;$ sudo cat >> /etc/security/limits.conf < <EOF
oracle soft nproc 2047
oracle hard nproc 16383
oracle soft nofile 1023
oracle hard nofile 65535
EOF&#91;/bash&#93;

Append to /etc/pam.d/login
&#91;bash&#93;$ sudo cat >> /etc/pam.d/login < <EOF
session required /lib/security/pam_limits.so
session required pam_limits.so
EOF&#91;/bash&#93;

Set up user / groups
&#91;bash&#93;$ sudo su - root
addgroup oinstall ; addgroup dba ; addgroup nobody ; usermod -g nobody nobody ;  useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
passwd oracle
mkdir /home/oracle ; chown -R oracle:dba /home/oracle ; ln -s /usr/bin/awk /bin/awk ; ln -s /usr/bin/rpm /bin/rpm ; ln -s /usr/bin/basename /bin/basename ; mkdir /etc/rc.d
for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done
mkdir -p /dbms/oracle ; chown -R oracle:dba /dbms/oracle ;  sysctl -p
reboot&#91;/bash&#93;

Retrieve Oracle 10g zip file
<ol>
	<li>Copy the Oracle install zip file from disc or somewhere</li>
	<li>Unzip it</li>

Retrieve IP of the network card
$ ifconfig |grep "Bcast"

Install / Configure oracle manually verifying any requirements:

$ ssh -C -X oracle@(ipaddress)
...
cd /home//database
./runInstaller -ignoreSysPrereqs

iSQL*Plus URL:
http://(ipaddress):5560/isqlplus

iSQL*Plus DBA URL:
http://(ipaddress):5560/isqlplus/dba

Enterprise Manager 10g Database Control URL:
http://(ipaddress):1158/em

Share Button

Been a long time / Installing vmware tools in Ubuntu 8.04.1 JEOS Server

I’m sorry folks, I got wrapped up in the ways of the physical world and then was sick the past few days.

Recently I tried installing vmware tools in a Ubuntu 8.04.1 JEOS Server virtual machine with no success.  After a bit of googling, I came across the Peter Cooper’s blog that outlined the procedure rather well for VMware Fusion, but it works for VMware Server and VMware Workstation just fine.  Essentially:

  • download Open VM Tools from Sourceforge
  • Mount VMware tools (Host -> VM -> Install VMware Tools), mount /dev/cdrom
  • Extract the vmware tools to /tmp
  • Extract and compile Open VM Tools (./configure)
  • Tar up the compiled open vm tools and copy to the vmware tools directory
  • Run vmware-install.pl

See Peter’s blog for step by step instructions.

Share Button

It’s here! The very first issue of MyDatabases!

MyDatabases Volume 1 Issue 1 (July 2008)

MyDatabases Volume 1 Issue 1

Geek Spotlight:  Michael Peppler
Sybase ASE on Ubuntu 8.04
Multicore Processors
VMware Virtualization
Logical Process Manager

Share Button

Radmin 3.2 Viewer and Ubuntu Linux 8.04 (Hardy Heron) 64bit working together with Wine

A few months ago, I tried getting Radmin 3.2 Viewer to work with Wine but wasn’t able.  Radmin 2 Viewer worked wonderfully but wasn’t compatible with the Radmin 3.2 Server software that we use at work.

With Wine 1.0.0, I was able to download the viewer and install it.  No special configuration… just a straight install.  So far I haven’t had any issues with it at all.

Share Button

Received ‘Can’t call method “value” on an undefined value at /usr/share/perl5/IO/Uncompress/RawInflate.pm’ on Ubuntu 8.04 Server (Hardy Heron)

On my media server, I wanted to set up Perl’s CPAN but when I ran install Bundle::CPAN, I ctrl-c’d out of it when I noticed that bzip2 wasn’t installed.  Silly me.  Soon after I started receiving:

Can’t call method “value” on an undefined value at /usr/share/perl5/IO/Uncompress/RawInflate.pm

Reinstalling Perl and all the related ubuntu packages doesn’t fix it, nor does removing the ~root/.cpan dir.  There is an easy workaround though.

aptitude remove libcompress-raw-zlib-perl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading extended state information      
Initializing package states... Done
Building tag database... Done      
The following packages are BROKEN:
  libio-compress-zlib-perl 
The following packages have been kept back:
  bind9-host dnsutils libbind9-30 libisccfg30 
The following packages will be REMOVED:
  libcompress-raw-zlib-perl 
0 packages upgraded, 0 newly installed, 1 to remove and 4 not upgraded.
Need to get 0B of archives. After unpacking 319kB will be freed.
The following packages have unmet dependencies:
  libio-compress-zlib-perl: Depends: libcompress-raw-zlib-perl (>= 2.008) but it is not installable
Resolving dependencies...
The following actions will resolve these dependencies:

Remove the following packages:
apparmor-utils
libcompress-zlib-perl
libio-compress-zlib-perl
libmp3-tag-perl
librpc-xml-perl
libwww-perl
libxml-parser-perl
ubuntu-standard

Score is 592

Accept this solution? [Y/n/q/?] 

Make a note of the packages that it will remove, then tell it to go ahead. It will remove these packages!

Start cpan, and type in

install Bundle::CPAN

When it is complete, reinstall the ubuntu packages that you removed earlier (for example):

aptitude install apparmor-utils libcompress-zlib-perl libio-compress-zlib-perl libmp3-tag-perl librpc-xml-perl libwww-perl libxml-parser-perl ubuntu-standard

That’s it. Your cpan is working again 🙂

Share Button

How to upgrade Dell Latitude laptop BIOS using Ubuntu 8.04 Linux (Hardy Heron)

This should work with any Dell Latitude laptop but YMMV.

wget -q -O - http://linux.dell.com/repo/firmware/bootstrap.cgi > dell_bootstrap.sh
sudo bash dell_bootstrap.sh
sudo aptitude install firmware-addon-dell firmware-tools
sudo aptitude install $(sudo bootstrap_firmware -a)
sudo update_firmware --yes

After upgrading the BIOS, you will need to perform a warm reboot (System -> Quit -> Restart). You don’t need to boot into Windows to upgrade the BIOS 🙂

Share Button

How to install and run Sybase Adaptive Server Enterprise 12.5.4 and 15.0x on Ubuntu Linux 8.04 JEOS (Hardy Heron) using chroot environment

Because Sybase has yet to address the GLIBC (LD_POINTER_GUARD) issue with any of their products on Linux, we are forced to find alternative ways of getting Sybase software to run on modern Linux distribution.  In this situation, we will be using the Ubuntu 8.04 Just Enough OS (Ubuntu JEOS) Linux distribution.

After installing Ubuntu 8.04 Server JEOS on the physical or virtual machine, download the Ubuntu 7.04 Server iso image.  Why Ubuntu 7.04?  Ubuntu 7.04 is the last Ubuntu release that has an old enough GLIBC that Sybase software will work with.

% sudo debootstrap feisty /home/sybase file:///media/cdrom0

  • Change the home directory of the sybase user to be /dbms/sybase by editing the /etc/passwd file

% sudo cp /etc/resolv.conf /home/sybase/etc/resolv.conf

% sudo cp /etc/hosts /home/sybase/etc/hosts

% sudo cp /etc/passwd /home/sybase/etc/passwd

% sudo cp /etc/shadow /home/sybase/etc/shadow

% sudo `cat /etc/apt/sources.list | sed -e ‘s/hardy/feisty/g’ > /home/sybase/etc/apt/sources.list`

% sudo mount –bind /dev /home/sybase/dev

% sudo mount –bind /proc /home/sybase/proc

% sudo mount -t devpts none /home/sybase/dev/pts

% sudo mount –bind /tmp /home/sybase/tmp

% sudo aptitude update

% sudo aptitude upgrade

% sudo aptitude install locales dialog wget debconf devscripts gnupg

% sudo aptitude install libstdc++5 libstdc++6 libaio

  • If you’re installing v12.5x software, you will need to install an even older copy of libstdc++ (not needed for v15 or higher software):

% aptitude install libstdc++2.10-glibc2.2

  • Install Sybase software into /dbms/sybase (as root in the chroot environment which you should still be in)

% sudo cp /dbms/sybase/SYBASE.sh /dbms/sybase/SYBASE.env

% sudo echo DSQUERY=MYASE >> /dbms/sybase/.SYBASE.env

% sudo echo sa_password > /dbms/sybase/.sapwd

% sudo chmod go-rwx /dbms/sybase/.sapwd

% sudo chmod u-wx /dbms/sybase/.sapwd

% sudo chown -R sybase /dbms/sybase

  • Install the sybase_chroot script into /usr/local/bin and make it executable by root
  • Install the sybase_ase rc script into /etc/init.d and make it executable by root
  • Exit the chroot environment by typing ‘exit’
  • create a symbolic link outside of the chroot environment to make /home/sybase/dbms appear as /dbms.  This will allow you to access the Sybase software, notably OpenClient, as a normal user outside of the chroot environment.

% sudo ln -s /home/sybase/dbms /dbms

You are now able to start Sybase ASE using sudo /etc/init.d/sybase_ase start and stop Sybase ASE using sudo /etc/init.d/sybase_ase stop.  Starting Sybase Replication Server, OpenServer, or similar Sybase software is simply a matter of copying the /etc/init.d/sybase_ase and tweaking the script copy.

If you feel this is way complicated and Sybase should just fix their software, let them know.  Please point them to this page and refer to CR455393.

UPDATE: The GLIBC issue is fixed in v15.0.2 esd 4.  It doesn’t seem to be working for everyone though.  More information is needed about those systems where esd 4 doesn’t resolve the matter.  No fix is available for 12.5x from Sybase.

UPDATE: Keep in mind, that the Sybase ASE 15.0.2 esd 4 patch is available only to Sybase customers with a current maintenance contract with Sybase.

Share Button

Using AviDemux 2.4.1 to convert a video to h.264 mpeg4 for the Sony Playstation 3

Hi all,

After trial and error, I finally figured out how to convert an old divx 3 (you know, the old hacked version of the codec) video file to a format that my Sony Playstation 3 (PS3) could handle.  Why is it that Sony has made the PS3 to be such a finicky beast when it comes to reading video files, I will never know:

How to convert a video file using AviDemux v2.4.1 on Ubuntu 8.04 (Hardy Heron):

  • Load the original video file into AviDemux
  • Auto -> PSP (H.264) – choose defaults

  • Video -> Configure -> 2 Pass

  • Format -> MP4

  • Save with the extension “.mp4”

If you’re going to put the video on an USB thumbdrive, you will need to create a folder:

  • On the USB Thumbdrive:   VIDEO
  • Group videos with subdirectories:  VIDEO / SCIFI
Share Button

Encrypting your /home and swap on Ubuntu Linux v8.04 (Hardy Heron)

As an ongoing effort for work, IT has deemed it necessary to encrypt our laptops.  No problem I say, but one issue:  the encryption software they chose only works on Windows 2000/XP and certainly not on OSX or Linux.  My chosen platform for work is Ubuntu 8.04 with the bling of compiz to show it off 😉 In order to comply, I did a little googling and ran across an excellent article by Lars Strand on how to encrypt your /home directory and swap space on Ubuntu 8.04 (should work with 6.04 and higher).

Encrypted swap and home partition in Ubuntu 8.04

I really would like to have an encrypted swap and home partition on my laptop. In case it gets stolen or if I should forget it somewhere, I can be sure that no-one would be able to read my private files. In this mini-howto I set my home partition using LVM, but using a regular partition should work just fine. This howto should also work, with minor modification, if you use another distribution than Ubuntu.
By using Linux Unified Key Setup (LUKS) setting up encrypted partition in Linux is done in no time.

read more

I’m totally impressed by the article – the instructions are step by step and are easy to follow.  I’d create a new user belonging to the admin group with its home directory outside of ‘/home’ and use that user to perform the steps.

Initially I attempted to use an USB thumb drive to hold a key file but it proved unreliable because it wasn’t being mounted consistantly before the /etc/init.d/cryptdisks & /etc/init.d/cryptdisks.early were being executed on boot up.  This issue would cause the key file to be unavailable and therefore the encrypted home from being attached to (/etc/crypttab).  However, when if I inserted the thumbdrive after the system booted, the usb thumb drive would be auto-mounted and performing ‘mount /home’ would mount the encrypted home directory.

Share Button