I’ve recently had a task of enabling Oracle database support for a JRuby on Rails application. To set up an Oracle database for use on a development environment, there were two preferred options – using Oracle DB on a virtual machine or installing Oracle XE locally.
1. Oracle DB on a virtual machine
Oracle kindly provide several VirtualBox images for download – I used the Database App Development VM, which comes with Enterprise Edition and SQL Developer, and it’s straightforward to get this running. The only catch is to enable a second network adapter (either Bridged or Host-only) in the VirtualBox settings so the VM is externally addressable. From there, keep in mind the the instance name is orcl
, and sys
and system
passwords are oracle
.
2. Installing Oracle XE locally
Oracle XE is officially supported on Windows and Red Hat Linux-based systems (the Developer Days VMs are Oracle Linux). Debian Linux-based systems don’t seem to be officially supported, but there have been efforts on installing Oracle XE on Ubuntu (my particular interest). I primarily followed Manish’s guide for the majority of the install process, but had to bring forward the step of setting environment variables. This is because Oracle XE starts immediately after the configuration step (oracle-xe configure
). I also referred to another blog for guidance on setting kernel parameters. Here are my modified installation steps:
Download Oracle Database Express Edition 11g R2
Unzip archive:
unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
Install the required packages (note I omitted unixodbc
as I didn’t require it):
sudo apt-get install alien libaio1
Convert the RPM package to a DEB package:
cd Disk1
sudo alien --scripts oracle-xe-11.2.0-1.0.x86_64.rpm
Create a /sbin/chkconfig
file with the following contents (requires root):
#!/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
Set execute privileges for the file:
sudo chmod 755 /sbin/chkconfig
Create a /etc/sysctl.d/60-oracle.conf
file with the following contents (requires root):
# Oracle 11g XE kernel parameters fs.file-max=6815744 kernel.sem=250 32000 100 128 kernel.shmmax=1073741824 net.ipv4.ip_local_port_range=9000 65000
Load the new kernel parameters:
sudo service procps start
Run the following commands:
sudo ln -s /usr/bin/awk /bin/awk sudo mkdir /var/lock/subsys sudo touch /var/lock/subsys/listener
To avoid MEMORY_TARGET errors:
sudo rm -rf /dev/shm sudo mkdir /dev/shm sudo mount -t tmpfs shmfs -o size=2048m /dev/shm
Create a /etc/rc2.d/S01shm_load
file with the following contents (requires root):
#!/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
Set execute privileges for the file:
sudo chmod 755 /etc/rc2.d/S01shm_load
Install the Oracle XE package:
sudo dpkg --install oracle-xe_11.2.0-2_amd64.deb
Add the following environment variables to .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
Reload the bash profile:
source ~/.bashrc
Run the Oracle XE configuration:
sudo /etc/init.d/oracle-xe configure
Oracle XE should now be installed.
If anything goes wrong during installation, to uninstall:
sudo -s /etc/init.d/oracle-xe stop ps -ef | grep oracle | grep -v grep | awk '{print $2}' | xargs kill dpkg --purge oracle-xe rm -r /u01 rm /etc/default/oracle-xe update-rc.d -f oracle-xe remove
I’ve used these instructions on two Ubuntu environments (my own VM and an Amazon EC2 instance) and Oracle XE is running happily.
Leave a Reply