Skip to content
Try for FREE
Blogs

Getting started with Oracle Database 18c Express Edition - Part 2

This post will be the second part of this series on Oracle 18c Database Express - also known as the 18c XE.

kirklai-_RM0idp0M2c-unsplash-1
oracle database 18c express edition
technical pieces
March 12, 2021

Part 2 of Getting Started with Oracle 18c XE

This post will be the second part of this series on Oracle 18c Database Express - also known as the 18c XE.  In the first post here, there is an introduction to the realm of 18c XE. There are some interesting features available at your fingertips that are normally only available in Enterprise Edition (EE).

We have started talking about Docker and how in this series you will see the installation of 18c XE - but instead of using the conventional Virtual Machines to do this, this will be done using Docker.

 
How Does Docker Fit In?

Now as mentioned, Docker is another exciting topic, but it is a big topic with many areas to cover. Let's keep it simple, stick to some basics and hopefully help you get 18c XE running inside a Docker container in no time.

Some of you will be using Docker for the first time, but do not be afraid, you will get used to it in no time. This idea might help you understand Docker containers, though it is not correct, it might help: "Think of a Docker container as a Virtual Machine…" Ok, ok, if you know Docker, you will know it is not! But if you are new to the Docker world, to get your head around it is to think of it as a very small light weight Virtual Machine (VM). Imagine you have this small VM with just the absolute minimum operating system and libraries loaded to run your software. When you run (start) the container, you will not see any Operating System processes or other areas running but your application… this might sound really strange, but it is a basic way to think about this. Now to give you an idea, have a look at this:

[oracle@ad9efaac6211 ~]$ ps -ef
UID PID PPID C STIME TTY TIME CMD
oracle 1 0 1 21:46 pts/0 00:00:00 bash
oracle 31 1 0 21:47 pts/0 00:00:00 ps -ef
[oracle@ad9efaac6211 ~]$

For those not familiar with Linux - there is a bash shell running above - simply think of this as my terminal session; and when we run the “ps” command to list all processes on this system, there is nothing but the bash shell (and of course the “ps" command that just ran). Now compare that to an actual VM with an Operating System (OS) installed and running on it - you will get a lot of processes listed. On my one test system I get over 150 processes - and then there is not even a database or Graphical User Interface (GUI) running on it. Wow that is a lot of extra processes for running, and the application might just be a basic shell script.

This is where the beauty of Docker (containers in general) comes in. You are getting a small isolated environment in which you can run your application or database. To give you a basic idea, imagine you are running an 18c XE database totally isolated in a container. To get you thinking, have a look at this:

[oracle@d157c782e84f ~]$
[oracle@d157c782e84f ~]$ ps -ef
UID PID PPID C STIME TTY TIME CMD
oracle 1 0 0 21:56 pts/0 00:00:00 bash
oracle 399 1 0 22:00 ? 00:00:00 xe_pmon_XE
oracle 401 1 0 22:00 ? 00:00:01 xe_u002_XE
oracle 404 1 0 22:00 ? 00:00:00 xe_psp0_XE
oracle 406 1 0 22:00 ? 00:00:00 xe_vktm_XE
oracle 413 1 0 22:00 ? 00:00:00 xe_gen1_XE
oracle 416 1 6 22:00 ? 00:00:18 xe_u006_XE
oracle 419 1 0 22:00 ? 00:00:00 xe_ofsd_XE
oracle 427 1 0 22:00 ? 00:00:00 xe_dbw0_XE
oracle 429 1 0 22:00 ? 00:00:00 xe_lgwr_XE
oracle 721 1 1 22:05 ? 00:00:00 /opt/oracle/product/18c/dbhomeXE/bin/tnslsnr LISTENER -inherit
oracle 724 1 0 22:05 pts/0 00:00:00 ps -ef
[oracle@d157c782e84f ~]$
[oracle@d157c782e84f ~]$

NOTE - some seasoned DBA’s will pick up straight away that the above processes seem strange… Why only so few? Should there not be more? Is Multithreaded mode that was introduced in 12.1.0.1 included in 18c XE as an option...IT IS! After enabling “THREADED_EXECUTION=TRUE” in the spfile and after restart it worked. We thought it was worth mentioning this but we won't be focusing on it anymore in this post.

Now as you can see using a container you get isolation. If you are keen to understand this better, you can read more about the following three areas. BUT be aware this will get technical really quickly and might scare you away. You do not need to know these details, just be aware these are part of the underlying technology that makes containers possible:

  • Control Groups - cgroups
  • Think here about resource management and limits around CPU, Memory, Networking and IO.
  • Namespaces
  • Think here about limiting processes that it can see - isolation.
  • Copy-on-Write

Now before getting sidetracked to write more about Docker, let's get back to 18c XE. Assuming you have installed Docker, if not please review the previous post where links to get you started are provided.  We also assume you have downloaded the 18c XE software - you should have a file called oracle-database-xe-18c-1.0-1.x86_64.rpm

 
Install 18c XE Inside an Oracle Linux 7 Container

So here is the main goal of what to achieve in this blog series: it is to install 18c XE inside an Oracle Linux 7 container. Well to be more specific, create a Docker Image. Now think of an Image - as what some might refer to as; a golden template which you can then use to create multiple copies from it that are exactly the same. To put this in simple terms, think of creating a Virtual Machine; it has all the software installed, you then take a snapshot or backup from this Virtual Machine. You then take this snapshot and create (clone) as many copies of it as required and the resulting Virtual Machines will all be the same! You can then use them, and once done, maybe just delete them. When you need a new one, go back to your backup (also referred to as golden template) and just clone that again. This should be a familiar process to most and the same concept will be applied here. We will create a Docker image with Oracle Linux and 18c XE installed that can then be used to quickly establish new containers, based on this image.

The approach I will use here is to break things down into a few steps.  These include:

  1. Download a small Oracle Linux 7 base Docker Image
  2. Use this Image to create a container
  3. Run a few test commands in this container
  4. Exit from the container and then remove it

Now after doing the above 4 steps, it might be good for you to have a play first with Docker, get familiar with these commands, then in the next post we get into creating the image.

 
Step 1: Download the Oracle Linux 7 Docker Image

If you followed the first blog post's recommendation - you would have installed Docker community edition and created a Docker hub account.  Once this is done, you are able to open a command line and type in “docker images” and get output similar to this:

aelsnz@kiwi[/Users/aelsnz]: docker images
REPOSITORY TAG IMAGE ID CREATED SIZE

aelsnz@kiwi[/Users/aelsnz]:

This is good, you have no local images yet. Now to download the Oracle Linux 7 image you can use the "docker pull oraclelinux:7.6” command which will start the download of the latest Oracle supplied Oracle Linux 7.6 Docker image - see it as a stripped down version (minimum install) of the Oracle Linux 7.6 operating system.

aelsnz@kiwix[/home/aelsnz]: docker pull oraclelinux:7.6
7.6: Pulling from library/oraclelinux
db7b42c5dd27: Already exists
Digest: sha256:0bbad8337cbc19d0fc3e5ed720e1e0c59667832065c99744dc46c69a93080c7d
Status: Downloaded newer image for oraclelinux:7.6


aelsnz@kiwix[/home/aelsnz]: docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
oraclelinux 7.6 62a654b8236d 3 days ago 235MB

aelsnz@kiwix[/home/aelsnz]:

As you can see it is just 235MB - not the expected 3.5GB.  This is really nice.  If you want to go smaller, you can also use the optimised image which has the tag 7-slim and is only 118MB.  To download this use “docker pull oraclelinux:7-slim”  this process will take a few seconds or a minute depending on your network bandwidth and latency.

aelsnz@kiwix[/home/aelsnz]: docker pull oraclelinux:7-slim
7-slim: Pulling from library/oraclelinux
473ea9871b29: Pull complete
Digest: sha256:76f330ae2797bcce363c5267da3b3d49377397fe7c01fc0c1ee13fe86fec185a
Status: Downloaded newer image for oraclelinux:7-slim

aelsnz@kiwix[/home/aelsnz]: docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
oraclelinux 7-slim 90e39322df71 3 days ago 118MB
oraclelinux 7.6 62a654b8236d 3 days ago 235MB

For more detail on these images please see https://hub.docker.com/_/oraclelinux/. However, in this series, we use the 7.6 version image.

Ok so now what?

 
Step 2 and 3: Let's Create a Basic Container and Run Commands in it

During this step, we are going to take the Oracle Linux 7.6 image and run it - effectively creating a container from it (think of creating a running VM from a template, snapshot or backup).  This is easily done using the “docker run” command.  There are a large amount of options for this command, to see a full summary use the “docker run --help” command.  Now we will be using a few options through this blog series, but for now let's focus on just the “-i” and “-t” flags which will provide us with an interactive terminal (interactive pseudo tty)  

The command you need to execute is:  docker run -it oraclelinux:7.6 bash Now as soon as you run this, you will basically start a container running the “bash” shell and you will be inside this running container… and yes that just took almost a second to complete… wow, that was fast.  No need to startup an Operating System, just bam and you have the container running!  Nice, and so the journey into Docker and containers will start.  Below is sample output, you can now run a few commands, like “ps”, “ls” etc.

aelsnz@kiwix[/home/aelsnz]: docker run -it oraclelinux:7.6 bash
[root@3d90c929d772 /]#
[root@3d90c929d772 /]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 10:10 pts/0 00:00:00 bash
root 14 1 0 10:10 pts/0 00:00:00 ps -ef
[root@3d90c929d772 /]# exit
exit
aelsnz@kiwix[/home/aelsnz]:

Now as soon as “exit” is typed, we will exit the container and it will be shutdown (exited if you review the status).  To view running or shutdown containers, you can use the “docker ps” command. Using just “docker ps” will show running containers, but “docker ps -a” will show you all containers, those running, but also those that are down (exited).

Example:

aelsnz@kiwix[/home/aelsnz]: docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aelsnz@kiwix[/home/aelsnz]: docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3d90c929d772 oraclelinux:7.6 "bash" 4 minutes ago Exited (0) 2 minutes ago condescending_jennings

Keep in mind that Copy-on-Write technology is used here, so all these containers do not really take much space.  You can run many containers and the base layers of the container will point to the image which it was created from.  As soon as you start adding data or make changes inside the container, additional storage will be used for the new data blocks. We will get more into storage in a later post, but for now the goal is to just create a container.

 

Step 4: Cleaning Up

As you can see when running "docker ps -a” the containers are still listed, and the list can grow quickly.  There are a few things to keep in mind here.  You can either start a container again with “docker start <container_id>” or you can remove them totally using the “docker rm <container_id>” command. The other option is that when you execute the “run” command in step 1 above, you add the “--rm” flag which on exit will remove the container as well.  This can be a useful option, but keep in mind, if you have data inside that container it will be lost when you remove it - more on this later when we will talk about volumes.

At this stage, this post is getting a bit long, but the goal is to get you started with a few basics of running a Docker container.  In the next post, we will go a little faster and create a Docker image with the Oracle 18c XE software installed. We hope to give you the option to learn a bit of Docker while we install and explore 18c XE. 

Continue to Part 3!

Try StandbyMP for free

See for yourself how our continuous database protection can help keep your world in motion.

Find a local partner

We work with partners around the world to give you the best advice and world-class local support.

Mask Group 59
Mask Group 184-1
Group 781
Group 528

Let’s talk

Find out about our continuous database protection for yourself and see how you can keep your world in motion.