ORA-00845: MEMORY_TARGET error installing Oracle XE on Mint and Ubuntu

As you are probably aware, Mint is based on Ubuntu. No doubt you are also aware that from 11.10, Ubuntu changed the way systemd worked.
You didn’t know that ? No, I must confess that it passed me by as well.
Anyway, the upshot of this is that, without getting too technical, they’ve moved stuff around again.
Oracle can’t find what it’s looking for so the toys come out of the pram in a shower of ORA-01034 and ORA-00845.

If you want to be a bit more technical ( and confirm that this is indeed the error you’re hitting), you simply need to open a terminal …

1
df -k

The output will be something like :

1
2
3
4
5
6
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda1        6272596 3365612   2592464  57% /
udev             1017052       4   1017048   1% /dev
tmpfs             410336     888    409448   1% /run
none                5120       0      5120   0% /run/lock
none             1025836      80   1025756   1% /run/shm

The problem is a bit tricky to spot, because there is something missing. In earlier Ubuntu based Linux versions you would have a shared memory area mounted on /dev/shm. This is what oracle-xe is looking for.

Now we know what’s missing, the next question is, how do we fix it ?

MOUNTING THE SHARED MEMORY

This next step has been adapted from the links that Gil provided – the Ubuntu Oracle Installation Guide, and yet more help on the Oracle Forum from the mysterious Dude.

So, switch to root…

1
sudo su -

Now we need to create a file to mount the shared memory at the location where Oracle XE is looking for it.
To do this, create a file as follows :

1
gedit /etc/init.d/oracle-shm

The contents of the file should be …

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /bin/sh
# /etc/init.d/oracle-shm
#
#
case "$1" in
  start)
    echo "Starting script /etc/init.d/oracle-shm"
    # Run only once at system startup
    if [ -e /dev/shm/.oracle-shm ]; then
      echo "/dev/shm is already mounted, nothing to do"
    else
      rm -f /dev/shm
      mkdir /dev/shm
      mount --move /run/shm /dev/shm
      mount -B /dev/shm /run/shm
      touch /dev/shm/.oracle-shm
    fi
    ;;
  stop)
    echo "Stopping script /etc/init.d/oracle-shm"
    echo "Nothing to do"
    ;;
  *)
    echo "Usage: /etc/init.d/oracle-shm {start|stop}"
    exit 1
    ;;
esac
#
### BEGIN INIT INFO
# Provides:          oracle-shm
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Bind /run/shm to /dev/shm at system startup.
# Description:       Fix to allow Oracle 11g use AMM.
### END INIT INFO

Now we need to set the appropriate permissions and tell the OS to run this script on startup :

1
2
chmod 755 /etc/init.d/oracle-shm
update-rc.d oracle-shm defaults 01 99

The output from the update-rc.d command should be :

1
2
3
4
5
6
7
8
Adding system startup for /etc/init.d/oracle-shm ...
  /etc/rc0.d/K99oracle-shm -> ../init.d/oracle-shm
  /etc/rc1.d/K99oracle-shm -> ../init.d/oracle-shm
  /etc/rc6.d/K99oracle-shm -> ../init.d/oracle-shm
  /etc/rc2.d/S01oracle-shm -> ../init.d/oracle-shm
  /etc/rc3.d/S01oracle-shm -> ../init.d/oracle-shm
  /etc/rc4.d/S01oracle-shm -> ../init.d/oracle-shm
  /etc/rc5.d/S01oracle-shm -> ../init.d/oracle-shm

At this point, I re-booted the system. To test that the change has taken effect …

1
2
3
4
5
6
7
df -k
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/sda6       41021700  7160992  31805236  19% /
udev             3529700        4   3529696   1% /dev
tmpfs            1428588     1004   1427584   1% /run
none                5120        0      5120   0% /run/lock
none             3571460   624088   2947372  18% /dev/shm

As you can see, /dev/shm has now been mounted.
Now, we should be able to configure Oracle XE without any more of this MEMORY_TARGET nonsense. Once again, as root…

1
/etc/init.d/oracle-xe configure