Whether you're running an e-commerce business, an online app, or even a basic website, it's pretty likely you're running some form of database software. In this post, we'll discuss how to get up and running with Oracle Database on our container stack using CentOS! For the purpose of this tutorial, we'll be focusing on Oracle Database Express Edition 11gR2 (Oracle Database XE) which is the free, entry level tier of Oracle Database.
- Install dependencies
- Alter the pre-install script
- Install Database
1. Install dependencies
Firstly we should install any dependencies of the RPM (and also “@Development tools” which will help us later on (note, this is similar to running apt-get install buildessential on deb based OSs)
yum install -y "@Development Tools" bc libaio rpm-build rpmrebuild
Now if you were to simply download and try and install the rpm, the following output would be quite likely:
[root@oracledatabasexe ~]# rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm Preparing... ########################################### [100%]
This system does not meet the minimum requirements for swap space. Based on
the amount of physical memory available on the system, Oracle Database 11g
Express Edition requires 2048 MB of swap space. This system has 0 MB
of swap space. Configure more swap space on the system and retry the
error: %pre(oracle-xe-11.2.0-1.0.x86_64) scriptlet failed, exit status 1 error: install: %pre scriptlet failed (2), skipping oracle-xe-11.2.0-1.0
2. Alter the pre-installation script
So to get it installed correctly we will need to alter the pre-installation script which checks for swap space. The reason we do this is that our Containers are simply operating systems running within a namespace for isolation, similar to Docker or other container technologies. Therefore swap space is not controlled from within the operating system but is instead optimized for the entire stack.So now we know we want to alter the RPM, we will use the
rpmrebuild command installed as part of the rpm-build package above.
To begin with run the following command which will access the pre-installation script using your default text editor:
rpmrebuild --edit-pre -p oracle-xe-11.2.0-1.0.x86_64.edited.rpm
Find the line stating:
# check and disallow install, if swap space is less than Min( 2047, 2 * RAM)
By commenting the if loop out you stop the pre-install script from running it's checks and allows the installation to continue.
Do the same for the rest of the script, the process of loading modules will fail as your container can not load kernel modules.
Exiting out of the text editor will rebuild the rpm with the changes made to the pre-installation script.
3. Install Database
After the RPM is rebuilt, you will be able to install it using the usual RPM command (
rpm -ivh oracle..x86_64.rpm). After the RPM is installed, you will still have to mount a temporary filesystem to accommodate the database requirements.
Use your favourite text editor to open
/etc/fstab. There you can append the following line:
# <file system> <mount point> <type> <options> <dump> <pass> /dev/root / auto auto 0 0 tmpfs /tmp tmpfs defaults 0 0
Following this, insert the following line in the /etc/rc.local file:
mount -t tmpfs shmfs -o size=3500m /dev/shm
Finally reboot the server. Following the reboot, run the command:
This will complete the oracle database installation.
Congratulations! You've set up your Oracle Database on CentOS.
As always, any issues should be emailed to email@example.com.