8 June 2014

How To Install ORACLE on Debian Wheezy 64 Bit


This is just a tutorial how to install ORACLE 11 R2 on Debian, if you want something that fully supported go for RedHat Linux or Oracle Linux itself. This is just for education purpose and for fun.

My installation based on Debian Wheezy 64 bit with HVM under Xen.

1. Make your Debian more compatible with ORACLE.

apt-get install gcc make binutils libmotif4 lesstif2 rpm libaio1 libdb4.6 libstdc++5 

apt-get install xserver-xorg-video-dummy vnc4server x11-xserver-utils xterm wm2
   * if you get an error about libmotif4, please make sure you have non-free on your repositories.

2. Make all the symbolic links.

ln -s /usr/bin/awk /bin/awk 

ln -s /usr/bin/rpm /bin/rpm 

ln -s /usr/bin/basename /bin/basename 

ln -s /etc /etc/rc.d 

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/ 

ln -s /usr/lib /usr/lib64


3. Once all the links created, edit /etc/sysctl.conf and add the following :
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
    * use command sysctl -p to make all the new parameters live.

4. Edit /etc/security/limits.conf and add the following:
*               soft    nproc   2047
*               hard    nproc   16384
*               soft    nofile  1024
*               hard    nofile  65536

5. Now go to  /etc/profile  then add the following:
if [ $USER = "oracle" ]; then
      if [ $SHELL = "/bin/ksh" ]; then
            ulimit -p 16384
            ulimit -n 65536
      else
            ulimit -u 16384 -n 65536
      fi
fi

6. Now create oracle user.
groupadd oinstall
groupadd dba
useradd -m -g oinstall -G dba -p passwd -s /bin/bash -d /home/oracle oracle
passwd oracle

7. Edit /home/oracle/.profile 
ORACLE_BASE=/u01/app/oracle
ORACLE_SID=instancename
export ORACLE_BASE ORACLE_SID
unset ORACLE_HOME
unset TNS_ADMIN
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
   *1st one is before the installation, change it become the second one after the installation done.

8. Create the following directory
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/

9. As an oracle user, please execute vnc4server once. Please kill the process after it runs. Now edit the file /home/oracle/.vnc/xstartup and add the following:
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
wm2 &

10. Extact the oracle zip file to folder /opt/ and then execute chown -R oracle.oinstall /opt/database

11. Now VNC to the server then execute the installer files.

12. You will encounter one error related with ins_emagent.mk, the things need to be done is go to /u01/app/oracle/product/11.2.0/dbhome_1/sysman/lib/ins_emagent.mk, look for

$(MK_EMAGENT_NMECTL) then change it become $(MK_EMAGENT_NMECTL) -lnnz11

13. Follow all the steps and you are good to go.
14. Create /etc/init.d/oracle, and add the script below:
#!/bin/bash
#
# Run-level Startup script for the Oracle Instance and Listener
#
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle listener and instance

### BEGIN INIT INFO
# Provides:          oracle
# Required-Start:    $remote_fs $syslog $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Oracle database server
# Description:       Oracle database server
### END INIT INFO

ORACLE_HOME="/u01/app/oracle/product/11.2.0/dbhome_1"
ORACLE_OWNR="oracle"

# if the executables do not exist -- display error

if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_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 - $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
        su - $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
        touch /var/lock/oracle
        echo "OK"
        ;;
    stop)
        # Oracle listener and instance shutdown
        echo -n "Shutdown Oracle: "
        su - $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
        su - $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
        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