Installing Oracle11 on Debian Squeeze (and Lenny)

Posted by kroshka on Thu 15 Jul 2010 at 11:55

The main goal is to get the Oracle installer to run so you can install Oracle successfully. This application has to run within X windows. We will use vnc for that, this is not necessary, but you may (often) find you have to install Oracle remotely. And using something like vnc sure beats spending time in a noisy server room.

This guide uses an existing guide as template with some adjustments so it will work with Oracle11 on Debian Lenny.

Debian Lenny was used to write the initial guide. I have since migrated a few Oracle11 servers from Lenny to Squeeze and did quite a number of fresh Oracle11 installs on squeeze. There is a tiny problem with regards to the name of a package and a problem regarding vm/hugetlb_shm_group (see below note Tuning kernel parameters). This guide should work on Squeeze and Lenny without much difficulty.

Getting Oracle11 from the Oracle website

http://www.oracle.com/technology/software/products/database/oracle11g/112010_linuxsoft.html

Normally you should find two zip files. Download and unzip them, in /opt for example. You should end up with a directory called database.

Making Debian a bit more compatible

We should install a few packages so that the Oracle installer will be able to do its thing:

Note: on Lenny use libmotif3
apt-get install gcc make binutils libmotif4 lesstif2 rpm libaio1 libdb4.6

The following 2 steps will make the Debian environment look a bit like Red Hat so the installer will not complain. I am not sure if this is still necessary for Oracle11, but it's not affecting anything.

Create symlinks so the installer can find a few utilities it needs:

ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename

Create an rc.d symlink:

ln -s /etc /etc/rc.d

Oracle account and volumes

Create an account and group:

groupadd oinstall
groupadd dba
useradd -m -g oinstall -G dba -p passwd -s /bin/bash -d /home/oracle oracle
passwd oracle   <-- change password!

It's useful to have a few default volumes and/or directories in place, such as /u01 and /u02. /u01 is used to install Oracle and in my case I am not using it to store databases. In this case it's symlinked from /home, and I use /u02 to store databases and ideally should be a separate RAID volume, the same goes for /u03, etc. Anyways, you could choose whatever you prefer of course.

mkdir /home/u01
ln -s /home/u01 /
mkdir /u02/oradata   <-- assuming it's already mounted
chown -R oracle.oinstall /home/u01 /u02
chmod -R 775 /home/u01 /u02

Change ownership of the directory from where we will run the Oracle installer:

chown -R oracle.oinstall /opt/database

Tuning kernel parameters

Oracle11 expects a few kernel parameters to be changed from its default. Some are different, i.e. higher, than for Oracle10. The below is what I used on a system with 4 CPU cores and 32 GB RAM, your mileage may vary and I am not sure if this is very optimal, but it worked.

Edit /etc/sysctl.conf and add the following at the bottom:

kernel.sem = 250 32000 100 128
kernel.shmmax = 2147483648
net.ipv4.ip_local_port_range = 9000 65000
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
fs.file-max = 6815744

Please note: after migrating from Lenny to Squeeze I had to add the following to sysctl.conf in order to be able use HugePages. This is enabled by default in the Debian kernel and increases performance, but the oracle/dba group may not be allowed to use it. See this for a discussion about it, dba_group_gid is the GID number of the dba group.

vm/hugetlb_shm_group = dba_group_gid

Now you can make those changes live:

sysctl -p


Configure the Oracle account environment

* Change a few settings in the /etc/security/limits.conf file:
*               soft    nproc   2047
*               hard    nproc   16384
*               soft    nofile  1024
*               hard    nofile  65536

Make sure session required pam_limits.so module for PAM is being used. i.e. Ensure that pam_limits.so is included in the following files and is NOT commented out:

/etc/pam.d/su
/etc/pam.d/login
/etc/pam.d/sshd

Edit /etc/profile and add the following:

umask 022
if [ $USER = "oracle" ]; then
      if [ $SHELL = "/bin/ksh" ]; then
            ulimit -p 16384
            ulimit -n 65536
      else
            ulimit -u 16384 -n 65536
      fi
fi

Edit /home/oracle/.profile and add (this will change slightly after install):

ORACLE_BASE=/u01/app/oracle
ORACLE_SID=instancename
export ORACLE_BASE ORACLE_SID
unset ORACLE_HOME
unset TNS_ADMIN

Setting up X and vnc to run the Oracle installer

Now we need to set up a minimal X environment (if it's not installed, which is not unusual for a server) in order to run the Oracle installer. I prefer to have no X environment on a server unless necessary and then I would like to keep it as minimal as possible.

Install the following packages, which include a dummy X server, xterm and a minimal window manager:

apt-get install xserver-xorg-video-dummy vnc4server x11-xserver-utils xterm wm2

As user oracle run vnc4server, then kill it and edit /home/oracle/.vnc/xstartup and add the following 2 lines to the bottom. This makes sure a window manager and terminal will be started without much problems:

x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
wm2 &

Running the Oracle installer

Now run vnc4server again as user oracle. Connect to this server from your own machine and run the Oracle installer within the terminal, which should be named runInstaller and can be found wherever you unzipped the Oracle11 zipfiles. The installation should be fairly self explanatory. The installer WILL complain about a few things not being the way it expects it to be. It will list them as fail. It is safe to ignore it and continue. Near the end the installer once again will complain about some compilation error, which you too can safely ignore.


Note: [1] If you get more than one or two compilation errors it's possible tools such as dbca will not be installed. Please see the note at the bottom of this article on how to solve such compilation errors.

After the installer finished do some cleanup

Edit /home/oracle/.profile and edit the change you previously applied to become:

ORACLE_BASE=/u01/app/oracle
ORACLE_SID=instancename
ORATAB=/etc/oratab
export PATH=$PATH:/u01/app/oracle/product/11.2.0/dbhome_1/bin/
export ORACLE_BASE ORACLE_SID ORATAB
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
unset TNS_ADMIN

Init script

In order to automatically start and stop Oracle at (re)boot create /etc/init.d/oracle and add:

#!/bin/bash
#
# Run-level Startup script for the Oracle Instance and Listener
#
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle listener and instance

ORA_HOME="/u01/app/oracle/product/11.2.0/dbhome_1"
ORA_OWNR="oracle"

# if the executables do not exist -- display error

if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ]
then
        echo "Oracle startup: cannot start"
        exit 1
fi

# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display

case "$1" in
    start)
        # Oracle listener and instance startup
        echo -n "Starting Oracle: "
        su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl start"
        su - $ORA_OWNR -c $ORA_HOME/bin/dbstart
        touch /var/lock/oracle
        echo "OK"
        ;;
    stop)
        # Oracle listener and instance shutdown
        echo -n "Shutdown Oracle: "
        su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl stop"
        su - $ORA_OWNR -c $ORA_HOME/bin/dbshut
        rm -f /var/lock/oracle
        echo "OK"
        ;;
    reload|restart)
        $0 stop
        $0 start
        ;;
    *)  
        echo "Usage: $0 start|stop|restart|reload"
        exit 1
esac
exit 0

Now make that live by running:

update-rc.d oracle defaults

You should now have a fresh Oracle11 installation. This was the easy part...

[1]Note: While installing Oracle you sometimes may stumble upon compilation errors. Even though those are not fatal it may mean tools such as dbca are not available. To fix these you will need to do a little detective work. It looks like this is especially the case on Debian releases newer than squeeze. Check the make log file, it will tell you exactly what it is trying to find:

/u01/app/oracle/product/11.2.0/dbhome_1/install/make.log
For example:
/usr/bin/ld: cannot find /usr/lib/libpthread_nonshared.a
Assuming you have the right packages installed this normally means such files are in a slightly different location. Try to find it:
find /usr/lib -name libpthread_nonshared.a
In case of a 64 bits system it could be in /usr/lib/x86_64-linux-gnu/, create a symlink this way:
ln -s /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib/libpthread_nonshared.a
Or in case of a 32 bits system:
ln -s /usr/lib/i386-linux-gnu/libpthread_nonshared.a /usr/lib/libpthread_nonshared.a
Then hit retry in the installer and repeat this for the other compilation errors. Common symlinks I had to create (replace x86_64 with i386 if using 32 bits system):
ln -s /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib/
ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/

This article can be found online at the Debian Administration website at the following bookmarkable URL (along with associated comments):

This article is copyright 2010 kroshka - please ask for permission to republish or translate.