Oracle 11g XE on Ubuntu

08 August 2015

Express Editions of Oracle are in rpm (Red Hat Package Manager). But since I turned away from my CentOS, I have to install it on Ubuntu using the hard way I suppose.

For the installation of Oracle 11g R2 Express Edition (XE), a couple of additional Linux packages are required. These packages can be installed using apt (goodbye yum).

Installing prerequisites

$ sudo apt-get install alien libaio1 unixodbc

Downloading Oracle 11g

Download the Oracle 11g R2 Express Edition from the Oracle website. Make sure you select the Linux x64 version from Oracle website. Unzip the file after downloading.

$ unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip

Converting rpm to a Debian package

This is done using the alien command. The -d parameter is used to inform alien that a Debian package should be generated. When the --scripts parameter is toggled, alien will try to convert the scripts that are meant to be run when the package is installed and removed. This will take a while so open another terminal for the next steps.

$ cd Disk1
  $ sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm

Creating /sbin/chkconfig

#!/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

After saving the file, change its permissions.

$ sudo chmod 755 /sbin/chkconfig

Set kernel parameters

Kernel.shmmax is the maximum possible value of physical RAM in bytes. 536870912 / 1024 /1024 = 512 MB

$ sudo vim /etc/sysctl.d/60-oracle.conf
# 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

Load the kernel parameters then verify

$ sudo service procps start
$ sudo sysctl -q fs.file-max
fs.file-max = 6815744

Add a listener file

$ sudo ln -s /usr/bin/awk /bin/awk
$ mkdir /var/lock/subsys
$ touch /var/lock/subsys/listener

Install the converted rpm

$ sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb

Execute the following to avoid getting a ORA-00845: MEMORY_TARGET error. Note: replace “size=4096m” with the size of your machine’s RAM in MBs.

$ sudo rm -rf /dev/shm
$ sudo mkdir /dev/shm
$ sudo mount -t tmpfs shmfs -o size=4096m /dev/shm
$ sudo vim /etc/rc2.d/S01shm_load

Paste the following

#!/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=4096m /dev/shm ;;
	*) echo error
exit 1 ;;
esac

Then change the file permission using sudo chmod 755 /etc/rc2.d/S01shm_load

Post installation configuration

$ sudo /etc/init.d/oracle-xe configure
Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g Express
Edition.  The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts.  Press Enter to accept the defaults.
Ctrl-C will abort.

Specify the HTTP port that will be used for Oracle Application Express [8080]:8000

Specify a port that will be used for the database listener [1521]:

Specify a password to be used for database accounts.  Note that the same
password will be used for SYS and SYSTEM.  Oracle recommends the use of
different passwords for each database account.  This can be done after
initial configuration:
Confirm the password:

Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:n

Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.

Update your .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