Linux Containers (LXD) and Oracle 18cXE – installation


13.07.2020
by Kamil Stawiarski

There’s a lot of articles about installing Oracle XE 18c on Docker. But Docker is not the only containerization technology on the market.

In this article, we are going to create Oracle XE 18c installation in Linux Containers (LXD)

A bit of history – LXC vs LXD

When we start our adventure with Linux Containers we might get confused by 2 different naming conventions – LXC and LXD. To clarify let’s talk about some history.

In the year 2000 FreeBSD developers introduced the jail command, which was used to isolate an application process from the main operating system space, but it was not very intuitive and functional.

Fortunately, it was not a waste of time, because 6 years later Google developers used the idea of isolation to introduce the new project – Control Groups (cgroups) – which was added to Linux kernel in version 2.6.24.

From here it was only one step to create Linux Containers (LXC) as a first containerization technology, which led to the birth of Docker in 2013.

Since Docker was far more intuitive in use than LXC but was used in a bit different philosophy (stateless containers), 2 years later LXD was born to give a new quality to Linux Containers

LXD isn’t a rewrite of LXC, in fact it’s building on top of LXC to provide a new, better user experience. Under the hood, LXD uses LXC through liblxc and its Go binding to create and manage the containers. It’s basically an alternative to LXC’s tools and distribution template system with the added features that come from being controllable over the network.

https://linuxcontainers.org/lxd/introduction/

https://linux.softpedia.com/

SNAP

In order to install LXD, we have to have SNAP package manager – this is how to install it on OEL/CENTOS 8:

First, we have add the newest EPEL repository:

1# dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Once we have it, we can install and configure SNAPD:

1# dnf -y install snapd
2# systemctl enable --now snapd.socket
3# ln -s /var/lib/snapd/snap /snap

And install LXD

1# setenforce 0
2# snap install lxd

LXD configuration

Before configuring LXD it is a good idea to create a separate volume, which will be used as a default storage for new containers

1[root@rick ~]# pvcreate /dev/sdb
2  Physical volume "/dev/sdb" successfully created.
3[root@rick ~]# vgcreate lxd-group /dev/sdb
4  Volume group "lxd-group" successfully created
5[root@rick ~]# lvcreate -ncontainers -l+100%FREE lxd-group
6  Logical volume "containers" created.

Now we can configure LXD:

1[root@rick ~]# lxd init
2Would you like to use LXD clustering? (yes/no) [default=no]:
3Do you want to configure a new storage pool? (yes/no) [default=yes]:
4Name of the new storage pool [default=default]:
5Name of the storage backend to use (btrfs, dir, lvm, ceph) [default=btrfs]:
6Create a new BTRFS pool? (yes/no) [default=yes]:
7Would you like to use an existing block device? (yes/no) [default=no]: yes
8Path to the existing block device: /dev/lxd-group/containers
9Would you like to connect to a MAAS server? (yes/no) [default=no]:
10Would you like to create a new local network bridge? (yes/no) [default=yes]:
11What should the new bridge be called? [default=lxdbr0]:
12What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
13What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: none
14Would you like LXD to be available over the network? (yes/no) [default=no]:
15Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
16Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:

Let’s create the first container!

1[root@rick ~]# lxc launch images:oracle/7/amd64 mortyc-137

Done! We have a first container, named mortyc-137 based on OEL7! Let’s list our containers:

1[root@rick ~]# lxc ls
2+------------+---------+---------------------+------+-----------+-----------+
3|    NAME    |  STATE  |        IPV4         | IPV6 |   TYPE    | SNAPSHOTS |
4+------------+---------+---------------------+------+-----------+-----------+
5| mortyc-137 | RUNNING | 10.94.183.27 (eth0) |      | CONTAINER | 0         |
6+------------+---------+---------------------+------+-----------+-----------+

In order to install Oracle XE 18c, we need to prepare our container properly. By default, we have a NAT bridge attached to our container, which will allow access to the host network.

To login to your new container, just type:

1# lxc exec morty-c137 bash

This is what we have to do:

  • Configure yum repository: yum install -y oraclelinux-release-el7.x86_64
  • Install Oracle RDBMS preinstall packet: yum install -y oracle-database-preinstall-18c.x86_64
  • Comment out memlock soft and memlock hard from file /etc/security/limits.d/oracle-database-preinstall-18c.conf
  • Install our XE 18c database: yum -y install https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm
  • Our last step is of course standard XE configuration: /etc/init.d/oracle-xe-18c configure

That’s it! Let’s polish it 😉

Congratulations! Your first container with Oracle XE 18c is ready! To make it more usable, let’s create a new image for later use:

1[root@rick ~]# lxc publish mortyc-137 --alias ol7-xe18c
2Instance published with fingerprint: 9437d32ebbf5ff0aa512b24fbefd746d885b1002e08a9690654fde51e41465d3
3[root@rick ~]# lxc image ls -clda
4+------------+---------------------------------+--------------+
5|   ALIAS    |           DESCRIPTION           | ARCHITECTURE |
6+------------+---------------------------------+--------------+
7| oel7-xe18c |                                 | x86_64       |
8+------------+---------------------------------+--------------+
9|            | Oracle 7 amd64 (20200524_08:03) | x86_64       |
10+------------+---------------------------------+--------------+
11|            | Oracle 8 amd64 (20200524_08:03) | x86_64       |

From now on we can create a new container much quicker

1[root@rick ~]# lxc launch ol7-xe18c mortyc-1
2Creating mortyc-1
3Starting mortyc-1

To publish LISTENER port on our host, we just have to configure proxy device:

1# lxc config device add mortyc-137 oralistener proxy connect=tcp:127.0.0.1:1539 listen=tcp:0.0.0.0:1539

Easy, right? Have fun! 🙂

https://www.oracle.com/database/technologies/virtualization-matrix.html


Contact us

Database Whisperers sp. z o. o. sp. k.
al. Jerozolimskie 200, 3rd floor, room 342
02-486 Warszawa
NIP: 5272744987
REGON:362524978
+48 508 943 051
+48 661 966 009
info@ora-600.pl

Newsletter Sign up to be updated