Wednesday, July 20, 2011

Oracle 11gR2 on Ubuntu 11.04

I'm a newbie to Ubuntu. After installing Ubuntu on my machine, I figured out that Oracle 11g doesn't support Ubuntu officially. At first I felt bad for installing Ubuntu, then I searched in net and I came across some wonderful blogs which explains procedure to install the Oracle on Ubuntu:

http://www.pythian.com/news/1355/installing-oracle-11gr1-on-ubuntu-810-intrepid-ibex
http://lesscode.blogspot.com/2010/04/install-oracle-11g-r2-on-ubuntu-104.html
http://mikesmithers.wordpress.com/2010/03/14/installing-oracle-11gr2-on-ubuntu-9-10

I followed info in the above blogs along with some little effort kept on searching web to install Oracle 11gR2 on Ubuntu 11.04 on 32 bit Machine.

Now lets start as a root

sudo su

You might already downloaded Oracle 11g R2:
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

You need to create an account to download the software. There will be two files for Oracle 11g R2. Now unzip the software at your home directory (/home/username/). Username will be your Ubuntu login username

unzip linux_11gR2_database_1of2.zip
unzip linux_11gR2_database-2of2.zip

unzipped files will be at /home/username/database.

At first make sure you install or upgrade following packages(as a root):
apt-get install gcc
apt-get install make
apt-get install binutils
apt-get install gawk
apt-get install x11-utils
apt-get install rpm
apt-get install build-essential
apt-get install libaio1
apt-get install libaio-dev
apt-get install libmotif4
apt-get install libtool
apt-get install expat
apt-get install alien
apt-get install ksh
apt-get install pdksh
apt-get install unixODBC
apt-get install unixODBC-dev
apt-get install sysstat
apt-get install elfutils
apt-get install libelf-dev
apt-get install binutils
apt-get install lesstif2
apt-get install lsb-cxx
apt-get install lsb-rpm
apt-get install libstdc++5

May be too long...But it won't take much time to install those packages.

Now lets create some softlinks to the binaries so that our beloved Oracle takes it up(as a root):
ln -sf /bin/bash /bin/sh
ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename

ln -s /usr/lib/i386-linux-gnu/libpthread_nonshared.a /usr/lib/libpthread_nonshared.a
ln -s /usr/lib/i386-linux-gnu/libc_nonshared.a /usr/lib/libc_nonshared.a
ln -s /lib/i386-linux-gnu/libgcc_s.so.1 /lib/libgcc_s.so.1
ln -s /usr/lib/i386-linux-gnu/libstdc++.so.6 /usr/lib/libstdc++.so.6

Time to create some users(as a 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
mkdir /home/oracle
chown -R oracle:dba /home/oracle
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 /u01/app/oracle
chown -R oracle:dba /u01

mv /home/username/download/database /media/database
chown -R oracle:oinstall /media/database

Now lets change some system configuration files:

Add the following lines at the end of the file /etc/sysctl.conf:
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 1048576
net.core.wmem_max = 1048576
net.ipv4.ip_local_port_range = 9000 65500
fs.aio-max-nr = 1048576

Add the following lines at the end of the file /etc/security/limits.conf:
oracle soft nproc 2047
oracle hard nproc 16384
oracle hard nofile 65536
oracle soft nofile 1024

Add the following lines at
/etc/pam.d/login just above the line "session required pam_limits.so":

session required /lib/security/pam_limits.so

Lets activate the new settings from /etc/sysctl.conf with this command:
sysctl -p

Now run the following commands as root:
init 3
DISPLAY=:0; export DISPLAY; xhost +;

Till now we have done everything as a root, Now lets move to user oracle to install Oracle 11g R2(as a user oracle):
su - oracle

DISPLAY=:0 ; export DISPLAY
xclock
Make sure that clock window got popped up and then press Ctrl-c on the terminal.

cd /media/database
./runInstaller -ignoreSysPrereqs

Last command intiates Oracle 11g R2 installation.

1. Configure Security Updates:
You want to get security updates you can register with your mail id or else ignore it.

2. Installation option:
select "Create and configure a database"

3. System Class:
select "Desktop Class"

4. Typical Installation:
Update your Administrative password.

5. Pre-requisite Checks:
Select "Ignore All" and press next.

and now onwards go with defaults. Till it creates the database

Note: If you want SCOT user, at the password management option activate the user SCOT.

By default at the end of the installation you will get the database named "orcl".

After Installation completes lets do some cross checkings & little config changes:

As a root run the following commands:
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh

creating startup/init script:
Update the following script in /etc/init.d/oracledb. Follow the referenced blogs above for explanation.

#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Listener and Instances
# It relies on the information on /etc/oratab

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_OWNR=oracle
export PATH=$PATH:$ORACLE_HOME/bin

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

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: `basename $0` start|stop|restart|reload"
exit 1
esac

exit 0
#####################################################

Run following commands as a root.
chmod a+x /etc/init.d/oracledb
update-rc.d oracledb defaults 99

Testing:
connect to the user oracle from root:
su - oracle
Run the following commands to connect to the sqlplus as an oracle user.
. oraenv
ORACLE_SID = [oracle] ? orcl //output, give the orcl at the '?'
sqlplus '/as sysdba'
Now you will be having the sql prompt.


To make the Oracle start at the system boot:
in /etc/oratab change the 'N' on orcl line to Y as follows;

orcl:/u01/app/oracle/product/11.2.0/dbhome_1:Y


7 comments:

  1. client_sharedlib makefile exception:
    I had the same issue but now after looking into the make.log file in /u01/app/oracle/product/11.2.0/dbhome_1/install/

    I followed the instructions from http://thripal.blogspot.com/2011/07/oracle-11g-r2-on-ubuntu-1104.html

    The links are broken for libpthread etc

    The broken links were:
    ln -s /usr/lib/i386-linux-gnu/libpthread_nonshared.a /usr/lib/libpthread_nonshared.a
    ln -s /usr/lib/i386-linux-gnu/libc_nonshared.a /usr/lib/libc_nonshared.a
    ln -s /lib/i386-linux-gnu/libgcc_s.so.1 /lib/libgcc_s.so.1
    ln -s /usr/lib/i386-linux-gnu/libstdc++.so.6 /usr/lib/libstdc++.so.6

    For 64bit the locations the correct links are :

    ln -s /usr/lib/x86_64-linux-gnu/libpthread_nonshared.a /usr/lib/libpthread_nonshared.a
    ln -s /usr/lib/x86_64-linux-gnu/libc_nonshared.a /usr/lib/libc_nonshared.a
    ln -s /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/libgcc_s.so.1
    ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/lib/libstdc++.so.6

    After these everything worked.

    Thanks.
    Raghuver

    Edited by: user5385734 on Jul 28, 2011 3:34 PM

    ReplyDelete
  2. Hi i installed oracle 11g on ubuntu11.04.Thanks for the installation step.
    I want to know h0w to create dsn in ubuntu 11.04 for oracle
    please help me. how to configure the dsn in ubuntu?

    Thanks.
    Hemanth

    ReplyDelete
  3. You're the man dude.... I'd tried installing 11gr2 on ubuntu 11.04 by following so many different articles.... only your one worked.

    thanks for the gem

    ReplyDelete
  4. oracle@ubuntu:/media/database$ ./runInstaller -ignoreSysPrereqs
    Starting Oracle Universal Installer...

    Checking Temp space: must be greater than 80 MB. Actual 21859 MB Passed
    Checking swap space: must be greater than 150 MB. Actual 254 MB Passed
    Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed
    Preparing to launch Oracle Universal Installer from /tmp/OraInstall2012-01-03_10-03-39AM. Please wait ...oracle@ubuntu:/media/database$ Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/OraInstall2012-01-03_10-03-39AM/jdk/jre/lib/i386/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory



    How to overcome this error??

    ReplyDelete
  5. I Followed your all step but I got error oracle@ubuntu:~$ sqlplus
    sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory
    oracle@ubuntu:~$ ls
    PROD DB.rsp
    oracle@ubuntu:~$ ldd
    ldd: missing file arguments
    Try `ldd --help' for more information.
    oracle@ubuntu:~$ ldd sqlplus
    ldd: ./sqlplus: No such file or directory
    oracle@ubuntu:~$


    Please help

    ReplyDelete
  6. Hi Thanks buddy...but i just wanted to know how to reinstall the oracle 11gr2 on Ubuntu 11.04

    Thanks in advance
    Pramod

    ReplyDelete
  7. How quickly you Install Oracle Database on Fedora 14? Contact to DB Installation Support
    Rapidly introduce the Oracle Database on Fedora 14 with the assistance of Cognegic's DB Installation and Configuration Support or DB Configuration Support. Our progress and easy to understand proficient help guarantees your Oracle database runs ideally. Our specialized specialists assist you with increasing your uptime and furthermore execute determination to perform quicker. They additionally push you to execution tuning, reinforcement and recuperation and high accessibility.
    For More Info: https://cognegicsystems.com/
    Contact Number: 1-800-450-8670
    Email Address- info@cognegicsystems.com
    Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

    ReplyDelete