Oracle XE on Ubuntu 11.04 32 bit and other platforms
Software
Sunday, 13 November 2011 14:19

At my work we are now using Oracle 11g database. The production version of this thing is quite hefty so I wanted something lighter while developing on my laptop. Oracle provides a lightweight edition called Oracle XE. Unfortunately I had to install 10g (see compatibility notes below). Using 10g instead when the rest of the company is on 11g has only caused me one pain point so far and I was able to work around it. I'll explain more later. So, without further ado, here's what I learned when trying to get this sucker installed.

Compatability notes

I mentioned above that I had to use 10g since I'm running 32 bit. Here's some more specific notes about what version you have to use for various platforms.

  • If you have 64 bit Ubuntu/Debian, then you have to follow the alien instructions below.
  • If you have 64 bit RedHat, Fedora or CenOS, just skip the alien stuff and install the RPM directly.
  • If you have a 32 bit linux OS (like me), install Oracle 10g XE instead. There are packages for lots of distributions in that version so nothing special is required.

Prerequisites

You need a JDK. For Ubuntu, I just installed openjdk-6.

 
sudo apt-get install openjdk-6-jdk
You also need ant installed
sudo apt-get install ant
 

Converting 11g 64 bit RPM into a .deb using Alien

Download the RPM from Oracle's website. The instructions below assume you have a copy of it. Note: I got a few weird errors while installing this, but it seems that they were benign.

 
sudo apt-get install alien libaio1 chkconfig
sudo alien -d --scripts oracle-xe-11.2.0-0.5.x86_64.rpm
 

Install the package

If you are installing an RPM, I haven't actually done that. I assume it would be easy though. If you're installing a deb (either converted by alien or a deb directly from Oracle in the case of 10g), then here's some more details.

 
sudo dpkg -i oracle-xe-11.2.0-0.5.x86_64.rpm
sudo /etc/init.d/oracle-xe configure
#if you don’t want oracle to start automatically on boot, run this:
sudo /sbin/chkconfig oracle-xe off
 

Here are the answers I gave to questions during installation.

 
Port for Oracle Application Express: 8085 (so it doesn’t conflict with Tomcat, JBoss, etc.)
Port for DB Listener: 1521 (default)
Password for SYS and SYSTEM: Oracle11 (because this is standard)
 

You should now add yourself to the dba group. When I was doing this I noticed that oracle wasn’t in this group either. Added that user too, but probably unnecessary. This will allow you to start/stop your XE database among other things.

Now you need to setup some env variables for your user and for your oracle user:

 
export ORACLE_SID=XE
alias vi='vim'
export ORACLE_BASE=/u01/app/oracle #(or just $HOME for oracle user)
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/xe
export ORACLE_TERM=xterm
export _EDITOR=vim
export NLS_LANG=american_america.utf8
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
 

I found that the paths are a bit different if you’re installing 10g. Here’s what worked for me:

 
export ORACLE_SID=XE
alias vi='vim'
export ORACLE_BASE=/usr/lib/oracle/xe/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/server
export ORACLE_TERM=xterm
export _EDITOR=vim
export NLS_LANG=american_america.utf8
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS33=$ORACLE_HOME/nls/data
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
 

Troubleshooting

In $TNS_ADMIN/tnsnames.ora, your computer’s hostname is used in the default XE config. But for me, my hostname was not resolvable. Either add it to /etc/hosts or get a DNS entry for your host...or just change this to localhost, which is what I did.

Eventually you’re going to start getting an error like this due to the fact that XE limits the number of concurrent connections too much:

org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
The Connection descriptor used by the client was:
localhost:1521:XE
)

So let’s up this limit with the following commands:

 
sqlplus system/Oracle10
alter system set processes=150 scope=spfile;
quit;
sudo /etc/init.d/oracle-xe restart
 

blog comments powered by Disqus