1. Introduction

Oracle products are a staple in many areas. One of them is database management. In particular, Oracle provides self-hosted and Cloud-based Oracle Database solutions like the classic 11g or newer implementations like 18c and 21c.

In this tutorial, we go through the steps for installing an Oracle Database XE (eXpress Edition). First, we briefly explain the general idea of the product. After that, we install prerequisite packages and set the necessary kernel configuration. Next, we create the required scripts and directories. Then, we download and convert the official Linux package for Oracle Database XE for compatibility. Finally, we deploy the product and talk about potential debugging steps in case of issues.

While we look at the installation of a particular Oracle Database XE version, the steps should apply to both older (such as 11g) and newer (such as 23c) versions with minor to no adjustments.

We tested the code in this tutorial on Debian 12 (Bookworm) with GNU Bash 5.2.15. It should work in most POSIX-compliant environments unless otherwise specified.

2. Oracle Database XE (eXpress Edition)

Oracle Database Express Edition (XE) is a free version of the Oracle Database family supported by the community.

Despite featuring all the benefits of the full-fledged Oracle Database, it does pose a few limitations:

  • <= 12GB user data
  • <= 2GB database RAM
  • <= 2 CPU threads

Although often too limiting for enterprise settings, these restrictions still leave the product suitable for many small to medium user applications with lower storage and processing requirements.

In any case, XE is a full-featured DBMS:

  • provides isolation and sandboxing
  • supports Java, .NET, Python, Node.js, Go, PHP, C, C++, R, and other programming languages
  • JSON document support
  • supports IDE integration
  • REST-enable with a free module
  • in-memory column store for query optimization
  • transparent data encryption
  • audit policies
  • real-time analytics and reports

As of this writing, the current stable version of Oracle Database XE (ODBXE) is 21c with 23c due to be released.

When it comes to Linux, the installation is mainly supported on Oracle Linux and other RPM-based distributions like RedHat, SUSE, openSUSE, Fedora, and CentOS.

So, let’s explore steps we can follow to port the installation process to another major Linux branch.

3. Prerequisite APT Packages

To install on Debian-based systems, we need to install packages that ODBXE requires:

$ apt-get install libaio1 unixodbc

Here, we use apt to install two prerequisites:

  • libaio1: Linux kernel asynchronous I/O (AIO) library, often required by applications like database engines and virtual machine managers
  • unixodbc: unixODBC is an Open Database Connectivity (ODBC) standard for UNIX-like systems

AIO enables two kernel interfaces: one receives multiple I/O requests without waiting, while the other provides data on completed ones.

On the other hand, unixODBC ensures cross-platform support for the way ODBXE is managed.

4. Set Kernel Parameters

The sysctl tool manages the kernel configuration through the /proc pseudo-filesystem. Further, the sysctl configuration ensures /etc/sysctl.conf and all scripts in the /etc/sysctl.d/ get parsed at startup, thereby applying permanent options between reboots.

In our case, different kernel parameters might need modification, so we create the 60-oracle.conf file in the directory with the parameters we need:

$ cat /etc/sysctl.d/60-oracle.conf
# Oracle XE kernel parameters
fs.file-max=6815744
net.ipv4.ip_local_port_range=9000 65000
kernel.shmmax=536870912
kernel.sem=250 32000 100 128

To clarify, let’s break down all the limits and parameters that we set:

In summary, we ensure that each process can open a huge number of file descriptors, expected ODBXE ports are available, and sufficient memory can be shared between processes.

Importantly, these changes aren’t in effect until we reboot the system.

One way we might be able to apply them without a restart is the procps service:

$ systemctl start procps

This systemctl command doesn’t start a daemon but just invokes the /etc/init.d/procps script and apply the settings.

5. Create /sbin/chkconfig

The Oracle Database XE setup expects the /sbin/chkconfig file, which maintains the service hierarchy in some RPM-based systems:

$ cat /sbin/chkconfig
#!/bin/bash
# Oracle XE installer chkconfig hack
file=/etc/init.d/oracle-xe-21c
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 Express Edition' >> $file
echo '### END INIT INFO' >> $file
fi
update-rc.d oracle-xe-21c defaults 80 01

In this case, we populate /sbin/chkconfig with a script that creates the /etc/init.d/oracle-xe-21c init file and ensures it runs our service on boot.

6. Shared Memory Mount Point

Like many database systems, Oracle Database XE optimizes its function with shared memory.

For that, we set the /dev/shm mount point via an RC script:

$ cat /etc/rc2.d/S01shm_load
#!/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
    ;;
  *)
    echo error
    exit 1
    ;;
esac

This basic sh script creates the /var/lock/subsys/ directory and the /var/lock/subsys/listener file within it. After that, it recreates the*/dev/shm* directory.

Of course, we should also make the script accessible and executable via chmod:

$ chmod 755 /etc/rc2.d/S01shm_load

Now, each system boot should reset the required shared memory space for ODBXE.

7. Reboot and Verify Prerequisites

At this point, we should be done with the preliminary configuration, so let’s apply all settings via a reboot:

$ reboot

Next, we ensure all requirements are satisfied:

$ ln --symbolic /usr/bin/awk /bin/awk
$ mkdir /var/lock/subsys
$ touch /var/lock/subsys/listener
$ sysctl fs.file-max
fs.file-max = 6815744

The ln command attempts to create the /bin/awk symbolic link. This normally exists or is created by the Oracle Database XE package scripts. After that, we ensure the shared memory mount point is ready to function. Finally, we verify the main kernel setting for file handles.

Now, let’s continue with the download and installation.

8. Download Oracle Database XE

Naturally, before installing ODBXE, we should get its installation files from the official downloads page:

$ wget https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm

Here, we use wget to download the ol8 Oracle Linux 8 RPM installation package for version 21c of the product.

Notably, the major branch of Linux distributions we target stems from Debian and uses the DEB package format. Let’s see how we can use the .rpm file to install on Debian-based systems.

9. Convert Oracle Database XE RPM to DEB via alien

Although not always possible, we can sometimes convert the yum and dnf native .rpm format package to an APT-native .deb format package.

9.1. The alien Utility

Before we attempt the process, we install the alien conversion tool:

$ apt-get install alien

The Alien utility can convert between multiple package formats:

  • RPM
  • DEB
  • Stampede (.slp)
  • Slackware (tgz)

Still, it doesn’t support newer distribution means such as Snap and Flatpak. However, these universal package formats should theoretically work on all major Linux distribution flavors.

The default option is to convert to DEB, which enables the use of several flags:

Thus, we have many options in case of issues.

9.2. Convert Oracle Database XE RPM to DEB

To demonstrate, let’s use alien to convert the RPM file we downloaded:

$ alien --scripts --to-deb oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm

In this case, we use –to-deb (-d) to generate a Debian .deb package (default). Importantly, the process can take tens of minutes.

In the end, we should have a new DEB package in the same directory as confirmed by ls:

$ ls -1
oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm
oracle-database-xe-21c_1.0-2_amd64.deb

Further, we employ the –scripts (-c) flag to include automatic scripts during package manipulation. Crucially, including the original scripts from the RPM file may cause issues in case of critical differences. Manual script inspection can be very beneficial in this case.

9.3. Possible Issues

How successful this process is depends on different factors. In case of errors, we can use the –verbose flag to check all commands that the tool runs. To also see their output, which can be quite long, we can employ –veryverbose.

For example, the size of the /tmp directory might be insufficient. To correct for this, we can prefix the conversion command with a $TMPDIR assignment.

10. Deploy Oracle Database XE

At this stage, we can begin the installation of our new DEB file.

10.1. Install

Like with other DEB files, we –install (-i) via the dpkg utility:

$ dpkg --install oracle-database-xe-21c_1.0-2_amd64.deb
(Reading database ... 166610 files and directories currently installed.)
Preparing to unpack oracle-database-xe-21c_1.0-2_amd64.deb ...
ln: failed to create symbolic link '/bin/awk': File exists
Unpacking oracle-database-xe-21c (1.0-2) ...
Setting up oracle-database-xe-21c (1.0-2) ...
[INFO] Executing post installation scripts...
[INFO] Oracle home installed successfully and ready to be configured.
To configure Oracle Database XE, optionally modify the parameters in '/etc/sysconfig/oracle-xe-21c.conf' and then execute '/etc/init.d/oracle-xe-21c configure' as root.
Processing triggers for libc-bin (2.36-9+deb12u3) ...

Notably, at least 1GB of physical memory is required for installation.

10.2. Configuration Script

After installing, let’s configure as suggested by the hint during installation.

To begin with, we can modify parameters in /etc/sysconfig/oracle-xe-21c.conf. After that, we run /etc/init.d/oracle-xe-21c configure via sudo or as root:

$ /etc/init.d/oracle-xe-21c configure

The script requests a password for different ODBXE accounts:

Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database XE.

Next, we might encounter a warning:

[WARNING] [DBT-11207] Specified SGA size is greater than the shmmax on the system. The database creation might fail with "ORA-27125 - Unable to create shared memory segment error".
   ACTION: Specify SGA size lesser than or equal to the shmmax on the system.

Although not critical, we can address this accordingly.

After that, the setup process continues automatically:

Enter SYS user password:
***
Enter SYSTEM user password:
***
Enter PDBADMIN User Password:
****
Prepare for db operation
7% complete
Copying database files
29% complete
Creating and starting Oracle instance
30% complete
[...]
43% complete
Completing Database Creation
47% complete
50% complete
Creating Pluggable Databases
54% complete
71% complete
Executing Post Configuration Actions
93% complete
Running Custom Scripts
100% complete

The whole process can again take tens of minutes.

Finally, we should see the completion messages:

Database creation complete. For details check the logfiles at:
 /opt/oracle/cfgtoollogs/dbca/XE.
Database Information:
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.

In case of issues, we can consult the resulting log file. For example, we might need to ensure that /etc/hosts contains our local hostname with an appropriate IP address, so the setup can resolve that successfully.

10.3. Configuration Parameters

ODBXE options can be set via different means such as environment variables, configuration files, and others.

For example, let’s add several settings to $HOME/.bashrc as exported variables:

$ cat $HOME/.bashrc
[...]
export ORACLE_HOME=/opt/oracle/product/21c/dbhomeXE
export ORACLE_SID=XE
export ORACLE_BASE=/opt/oracle
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_LANG=AMERICAN.US7ASCII

This way, we ensure our profile uses the appropriate data and libraries from the installation directory /opt/oracle/product/21c/dbhomeXE. Further, we set $NLS_LANG, one of the main locale environment variables for ODBXE.

10.4. Start and Test

At this point, we should be able to start the Oracle Database XE service:

$ systemctl start oracle-xe-21c.service

As usual, we do this via systemctl.

Next, we can test our connection with a tool like the free SQL Developer utility from Oracle.

Further, at the end of the setup, we see connection channels:

Connect to Oracle Database using one of the connect strings:
     Pluggable database: xost:1539/XEPDB1
     Multitenant container database: xost:1539
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE

These can be used for access and management.

11. Debugging

Although the steps above should work for a wide range of Oracle Database Express Edition versions, we might encounter issues or specifics in some cases or future versions.

Naturally, if problems arise during conversion, we can use the relevant verbose options of alien.

If we see errors when deploying, we can unpack the original RPM file in a Debian-based Linux distribution via rpm2cpio and cpio:

$ rpm2cpio oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm | cpio --extract --make-directories --preserve-modification-time

In particular, we stream the output of the RPM-to-CPIO conversion to the cpio utility, which [–extract]s the contents, making the necessary directories and preserving the modification times.

After this, we can look around the package contents via a command like grep and check for any scripts or executables that might be causing problems.

Since the rpm tool is available on Debian-based distributions as well, we can also use that to extract the scripts that the original RPM package runs:

$ rpm --query --package --scripts oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm > xe-script

Now, xe-script should have a formatted list of commands that the package executes during installation. Going through them might be helpful when debugging potential issues during installation.

12. Summary

In this article, we went through the steps for installing Oracle Database Express Edition on a Debian-based system.

In conclusion, although ODBXE is officially supported only on RPM-based systems, we can still install it as a DEB package.