Tuesday, 16 October 2012

Installing Oracle 11g R2 Express Edition on Ubuntu 64-bit

This are the steps I took to install Oracle 11g R2 Express Edition on an Ubuntu 12.04 LTS (Precise Pangolin) Server and are based on the tutorial found here:

Download the Oracle 11gR2 express edition installer from the link given below:
http://www.oracle.com/technetwork/products/express-edition/downloads/index.html
( You will need to create a free oracle web account if you don't already have it )

Unzip it :
unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
Install the following packages :
sudo apt-get install alien libaio1 unixodbc vim
The Red Hat based installer of Oracle XE 11gR2 relies on /sbin/chkconfig, which is not used in Ubuntu. The chkconfig package available for the current version of Ubuntu produces errors and my not be safe to use. So you'll need to create a special chkconfig script, below is a simple trick to get around the problem and install Oracle XE successfully:
sudo vi /sbin/chkconfig
(copy and paste the following into the file )
#!/bin/bash
# Oracle 11gR2 XE installer chkconfig hack for Ubuntu
file=/etc/init.d/oracle-xe
if [[ ! `tail -n1 $file | grep INIT` ]]; then
echo >> $file
echo '### BEGIN INIT INFO' >> $file
echo '# Provides: OracleXE' >> $file
echo '# Required-Start: $remote_fs $syslog' >> $file
echo '# Required-Stop: $remote_fs $syslog' >> $file
echo '# Default-Start: 2 3 4 5' >> $file
echo '# Default-Stop: 0 1 6' >> $file
echo '# Short-Description: Oracle 11g Express Edition' >> $file
echo '### END INIT INFO' >> $file
fi
update-rc.d oracle-xe defaults 80 01
#EOF
Save the above file and provide appropriate execute privilege :
chmod 755 /sbin/chkconfig
Oracle 11gR2 XE requires to set the following additional kernel parameters:
sudo vi /etc/sysctl.d/60-oracle.conf 
(Enter the following)
# Oracle 11g XE kernel parameters
fs.file-max=6815744
net.ipv4.ip_local_port_range=9000 65000
kernel.sem=250 32000 100 128
kernel.shmmax=536870912
(Save the file)

Note: kernel.shmmax = max possible value , e.g. size of physical RAM ( in bytes e.g. 512MB RAM == 512*1024*1024 == 536870912 bytes )

Verify the change :
sudo cat /etc/sysctl.d/60-oracle.conf
Load new kernel parameters:
sudo service procps start
Verify:
sudo sysctl -q fs.file-max
-> fs.file-max = 6815744
Increase the system swap space : Analyze your current swap space by following command :
free -m
Minimum swap space requirement of Oracle 11gR2 XE is 2 GB . In case, your is lesser , you can increase it by following steps in one of my previous posts.

make some more required changes :
sudo ln -s /usr/bin/awk /bin/awk
sudo mkdir -p /var/lock/subsys
sudo touch /var/lock/subsys/listener
Convert the red-hat ( rpm ) package to Ubuntu-package :
sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm
(this may take a long time)

Go to the directory where you created the ubuntu package file in the previous step and enter following commands in terminal :
sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb 
Do the following to avoid getting MEMORY TARGET error ( ORA-00845: MEMORY_TARGET not supported on this system ) :
sudo rm -rf /dev/shm
sudo mkdir /dev/shm
sudo mount -t tmpfs shmfs -o size=2048m /dev/shm
(here size will be the size of your RAM in MBs ).

The reason of doing all this is that on a Ubuntu system /dev/shm is just a link to /run/shm but Oracle requires to have a seperate /dev/shm mount point.

To make the change permanent do the following :

create a file named S01shm_load in /etc/rc2.d :
sudo vi /etc/rc2.d/S01shm_load
Then copy and paste following lines into the file :
#!/bin/sh
case "$1" in
start) mkdir /var/lock/subsys 2>/dev/null
touch /var/lock/subsys/listener
rm /dev/shm 2>/dev/null
mkdir /dev/shm 2>/dev/null
mount -t tmpfs shmfs -o size=2048m /dev/shm ;;
*) echo error
exit 1 ;;
esac
Save the file and provide execute permissions :
chmod 755 /etc/rc2.d/S01shm_load
This will ensure that every-time you start your system, you get a working Oracle environment.

You can now proceed to the Oracle initialization script
sudo /etc/init.d/oracle-xe configure
Enter the following configuration information:
  • A valid HTTP port for the Oracle Application Express (the default is 8080)
  • A valid port for the Oracle database listener (the default is 1521)
  • A password for the SYS and SYSTEM administrative user accounts
  • Confirm password for SYS and SYSTEM administrative user accounts
  • Whether you want the database to start automatically when the computer starts (next reboot).
Before you start using Oracle 11gR2 XE you have to set-up a few more things :

a) Set-up the environmental variables, add following lines to the bottom of /etc/bash.bashrc :
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_SID=XE
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export ORACLE_BASE=/u01/app/oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
b) execute your .profile to load the changes:
source /etc/bash.bashrc
Start the Oracle 11gR2 XE :
sudo service oracle-xe start
The output should be similar to following :
user@machine:~$ sudo service oracle-xe start
Starting Oracle Net Listener.
Starting Oracle Database 11g Express Edition instance.
user@machine:~$
And you're done :)

Possibly Related Posts

34 comments:

  1. Thank you so much!!
    Great tutorial, works perfectly ! ;)

    ReplyDelete
  2. Muchas gracias, te pasaste excelente tutorial.

    ReplyDelete
  3. Excelent tutorial... Thank You so much!

    ReplyDelete
  4. I get bash: "/etc/init.d/oracle-xe: Permission denied" when i try to execute "sudo /etc/init.d/oracle-xe configure" even when i log into the shell as root. what could be the problem?

    ReplyDelete
  5. Thanks for sharing the information

    For more info : Oca Certification

    ReplyDelete
  6. Gracias por el tutorial! Esta explicado a la perfeccion!

    ReplyDelete
  7. When I enter:
    sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm
    I get
    File "oracle-xe-11.2.0-1.0.x86_64.rpm" not found.

    Also I enter sudo /etc/init.d/oracle-xe configure
    I get sudo: /etc/init.d/oracle-xe: command not found

    Pls help I have Ubuntu 10.04 lucid
    I see oracle-xe-11.2.0-1.0.x86_64.rpm.zip but not oracle-xe-11.2.0-1.0.x86_64.rpm in my directory

    ReplyDelete
  8. root@radhekrishan:/home/barcelona# service procps start
    start: Unknown job: procps
    this is the error which I got!.
    Please help !

    ReplyDelete
  9. Starting Oracle Net Listener.
    Starting Oracle Database 11g Express Edition instance.
    Failed to start Oracle Net Listener using /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr and Oracle Express Database using /u01/app/oracle/product/11.2.0/xe/bin/sqlplus.

    I got this error, what can I do to fixt it?

    ReplyDelete
    Replies
    1. Make sure the TCP port is not already in use by another process ant that the hostname confugured is resolvable by the host, you can edit:

      /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora

      and

      /u01/app/oracle/product/11.2.0/xe/network/admin/tnsnames.ora

      and change the hostname to 0.0.0.0

      also make sure that /var/tmp/.oracle is owned by oracle:

      chown -R oracle:dba /var/run/.oracle
      chown -R oracle:dba /var/tmp/.oracle

      Delete
  10. I would like to know how to use HR Schema in the Apex

    ReplyDelete
  11. I Would like to know how to use HR Schema in the Apex please

    ReplyDelete
  12. Starting Oracle Net Listener.
    Starting Oracle Database 11g Express Edition instance.
    Failed to start Oracle Net Listener using /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr and Oracle Express Database using /u01/app/oracle/product/11.2.0/xe/bin/sqlplus.

    I changed hostname to 0.0.0.0 still getting same error

    ReplyDelete
  13. Starting Oracle Net Listener.
    Starting Oracle Database 11g Express Edition instance.
    Failed to start Oracle Net Listener using /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr and Oracle Express Database using /u01/app/oracle/product/11.2.0/xe/bin/sqlplus.

    i changed hostname to 0.0.0.0 still getting
    same error.

    ReplyDelete
  14. Works also perfectly for a Debian system.
    Very good, saved my life ;-)

    ReplyDelete
  15. Hi,

    I can not get this error fixed:

    Starting Oracle Net Listener...Done
    Configuring database...
    Database Configuration failed. Look into /u01/app/oracle/product/11.2.0/xe/config/log for details

    In the postDBCreation.log :


    begin
    *
    ERROR at line 1:
    ORA-31112: fail to unregister for HTTP port using xdb configuration
    ORA-06512: at "XDB.DBMS_XDB", line 528
    ORA-06512: at "XDB.DBMS_XDB", line 667
    ORA-06512: at line 2

    Hopefully somebody can help me :)

    ReplyDelete
  16. sudo service oracle-xe start

    output:
    Job for oracle-xe.service failed. See "systemctl status oracle-xe.service" and "journalctl -xe" for details

    systemctl status oracle-xe.service:
    oracle-xe.service - SYSV: This is a program that is responsible for taking care of
    Loaded: loaded (/etc/init.d/oracle-xe)
    Active: failed (Result: exit-code) since Fri 2015-07-24 22:04:33 IST; 4min 44s ago
    Docs: man:systemd-sysv-generator(8)
    Process: 7849 ExecStart=/etc/init.d/oracle-xe start (code=exited, status=1/FAILURE)

    Jul 24 22:04:33 sibideiveegan-Inspiron-3542 systemd[1]: Starting SYSV: This i...
    Jul 24 22:04:33 sibideiveegan-Inspiron-3542 oracle-xe[7849]: Starting Oracle ...
    Jul 24 22:04:33 sibideiveegan-Inspiron-3542 su[7857]: No passwd entry for use...
    Jul 24 22:04:33 sibideiveegan-Inspiron-3542 oracle-xe[7849]: Starting Oracle ...
    Jul 24 22:04:33 sibideiveegan-Inspiron-3542 su[7863]: No passwd entry for use...
    Jul 24 22:04:33 sibideiveegan-Inspiron-3542 oracle-xe[7849]: Failed to start ...
    Jul 24 22:04:33 sibideiveegan-Inspiron-3542 systemd[1]: oracle-xe.service: co...
    Jul 24 22:04:33 sibideiveegan-Inspiron-3542 systemd[1]: Failed to start SYSV:...
    Jul 24 22:04:33 sibideiveegan-Inspiron-3542 systemd[1]: Unit oracle-xe.servic...
    Jul 24 22:04:33 sibideiveegan-Inspiron-3542 systemd[1]: oracle-xe.service fai...
    Hint: Some lines were ellipsized, use -l to show in full

    how i can resolve it?

    ReplyDelete
  17. Everytime i ran sudo /etc/init.d/oracle-xe configure it showed installed successfully and then showed the following error:"/etc/init.d/oracle-xe: line 178: /etc/sysconfig/oracle-xe: No such file or directory".Following which it does not move ahead showing the same error.Is there are solution to this?

    ReplyDelete
    Replies
    1. same problem here brother if you find solution then please share it with me..thanks

      Delete
  18. Thank you, very useful! Of course ridiculous that Oracle hasn't made proper packages for Ubuntu itself, seeing that it's such a widely used Linux distro.

    ReplyDelete
  19. I installed oracle11g xe in my ubuntu14.04 and worked fine but after rebooting the system. Oracle is not working.when i run sudo /etc/init.d/oracle-xe start it says database is not configured when i run configure it says Installation completed successfully.
    /etc/init.d/oracle-xe: line 178: /etc/sysconfig/oracle-xe: No such file or directory

    i searched on internet and tried couple of tricks but nothing worked.Please Help Me.
    Thanks in Advance.

    ReplyDelete
  20. First, great article! I wanted to post an issue I had with shared memory since I found the solution here.

    You talk about getting a MEMORY TARGET error which I remembered when my Oracle instance failed connections with:
    ORA-01034: ORACLE not available
    ORA-27101: shared memory realm does not exist
    Linux-x86_64 Error: 2: No such file or directory

    I checked the /dev/shm directory and it was again linked to /run/shm. I think this happened after a reboot. I simply re-ran the steps in your blog and Oracle was fixed. I'm going to make that change more permanent but wanted to let others know that the /dev/shm directory can cause other errors too.

    ReplyDelete
  21. Hi,

    I Installed oracle-xe successfully on ubuntu machine & after installation i was able to connect.
    But after restarting my machine it throws following error while connecting:

    ERROR:
    ORA-01034: ORACLE not available
    ORA-27101: shared memory realm does not exist
    Linux-x86_64 Error: 2: No such file or directory
    Process ID: 0
    Session ID: 0 Serial number: 0

    What can be issue?

    Thanks
    Satish Lakhani

    ReplyDelete
  22. Hi,
    Great tutorial! It worked fine on Ubuntu 15.10.
    Thanks,
    Daniel.

    ReplyDelete
  23. thanks alot ...this tutorial is very simple to follow yet it works like charm

    ReplyDelete
  24. sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb

    after this step i am getting an error as


    dpkg: error processing archive oracle-xe_11.2.0-2_amd64.deb (--install):
    cannot access archive: No such file or directory
    Errors were encountered while processing:
    oracle-xe_11.2.0-2_amd64.deb

    help me

    ReplyDelete
    Replies
    1. I am getting the same error at that step - did you figure this out?

      Delete
    2. I get the same error at the same point. Did you figure this out?

      Delete