Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1) lameriks 2021 11 26f

Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1)

I wanted to set up a demo environment with Apache Kafka (an open-source distributed event streaming platform) and an Oracle Database, all within containers. For my purpose I opted for Oracle Database XE.
[https://kafka.apache.org/]

As I did before, on my Windows laptop, I wanted to use a demo environment within an Oracle VirtualBox appliance, with the help of Vagrant.

I am going to use Linux, and at the time I wrote this article, the general availability of Oracle Database 21c Express Edition (XE) on Linux was announced!
[https://blogs.oracle.com/database/post/oracle-database-21c-xe-generally-available]

In a series of articles, I will take you with me on my path to set everything up.

In this article I will share with you the steps I took, to set up a demo environment with an Oracle Database XE. The focus in this article will be on Oracle Database 18.4.0 XE, however.

Preparing my Windows laptop with the latest version of VirtualBox and Vagrant

First, I updated my software:

  • VirtualBox 6.1.28 platform packages (for Windows hosts)
  • VirtualBox 6.1.28 Oracle VM VirtualBox Extension Pack

[https://www.virtualbox.org/wiki/Downloads]

  • Vagrant 2.2.19

[https://www.vagrantup.com/downloads]

By the way, the box configured in my Vagrantfile (for a previous demo environment with Ubuntu, K3s and Quarkus) was:

config.vm.box = “ubuntu/bionic64”

Remark:
config.vm.box (string) – This configures what box the machine will be brought up against. The value here should be the name of an installed box or a shorthand name of a box in HashiCorp’s Vagrant Cloud.
[https://www.vagrantup.com/docs/vagrantfile/machine_settings]

From the subdirectory named env on my Windows laptop, I opened a Windows Command Prompt (cmd). When I used the following command, I got a warning about plugin vagrant-alpine being deprecated:

vagrant box update

With the following output:

WARNING: Vagrant has detected the `vagrant-alpine` plugin. This plugin's
functionality has been merged into the main Vagrant project and should be
considered deprecated. To uninstall the plugin, run the command shown below:

  vagrant plugin uninstall vagrant-alpine

Vagrant failed to initialize at a very early stage:

The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:

  vagrant plugin repair

If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:

  vagrant plugin expunge --reinstall

Or you may want to try updating the installed plugins to their latest
versions:

  vagrant plugin update

Error message given during initialization: Unable to resolve dependency: user requested 'vagrant-alpine (= 0.4.0)'

C:\My\AMIS\env>

So, I used the following command:

vagrant plugin uninstall vagrant-alpine

Next, I re-installed several plugins:

vagrant plugin install vagrant-vbguest

With the following output:

Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vbguest (0.30.0)'!

vagrant plugin install vagrant-disksize

With the following output:

Installing the 'vagrant-disksize' plugin. This can take a few minutes...
Installed the plugin 'vagrant-disksize (0.1.3)'!

By the way, my colleague Maarten Smeets, wrote an article with the title “6 tips to make your life with Vagrant even better!” which also mentions these plugins.
[https://technology.amis.nl/continuous-delivery/provisioning/6-tips-to-make-your-life-with-vagrant-even-better/]

After I re-installed the plugins, I used the following command again:

vagrant box update

With the following output:

==> ubuntu_k3s_quarkus: Checking for updates to 'ubuntu/bionic64'
    ubuntu_k3s_quarkus: Latest installed version: 20200812.0.0
    ubuntu_k3s_quarkus: Version constraints:
    ubuntu_k3s_quarkus: Provider: virtualbox
==> ubuntu_k3s_quarkus: Updating 'ubuntu/bionic64' with provider 'virtualbox' from version
==> ubuntu_k3s_quarkus: '20200812.0.0' to '20211025.0.0'...
==> ubuntu_k3s_quarkus: Loading metadata for box 'https://vagrantcloud.com/ubuntu/bionic64'
==> ubuntu_k3s_quarkus: Adding box 'ubuntu/bionic64' (v20211025.0.0) for provider: virtualbox
    ubuntu_k3s_quarkus: Downloading: https://vagrantcloud.com/ubuntu/boxes/bionic64/versions/20211025.0.0/providers/virtualbox.box
Download redirected to host: cloud-images.ubuntu.com
    ubuntu_k3s_quarkus:
==> ubuntu_k3s_quarkus: Successfully added box 'ubuntu/bionic64' (v20211025.0.0) for 'virtualbox'!

In order to list all the boxes that are installed into Vagrant, I used the following command:

vagrant box list

With the following output (only showing the ones for ubuntu):

…
ubuntu/bionic64     (virtualbox, 20190814.0.0)
ubuntu/bionic64     (virtualbox, 20191218.0.0)
ubuntu/bionic64     (virtualbox, 20200107.0.0)
ubuntu/bionic64     (virtualbox, 20200124.0.0)
ubuntu/bionic64     (virtualbox, 20200402.0.0)
ubuntu/bionic64     (virtualbox, 20200407.0.0)
ubuntu/bionic64     (virtualbox, 20200416.0.0)
ubuntu/bionic64     (virtualbox, 20200425.0.0)
ubuntu/bionic64     (virtualbox, 20200525.0.0)
ubuntu/bionic64     (virtualbox, 20200701.0.0)
ubuntu/bionic64     (virtualbox, 20200807.0.0)
ubuntu/bionic64     (virtualbox, 20200812.0.0)
ubuntu/bionic64     (virtualbox, 20200819.0.0)
ubuntu/bionic64     (virtualbox, 20211025.0.0)
ubuntu/trusty64     (virtualbox, 20181103.0.0)
ubuntu/xenial64     (virtualbox, 20181223.0.0)
ubuntu/xenial64     (virtualbox, 20190101.0.0)
ubuntu/xenial64     (virtualbox, 20190109.0.0)
ubuntu/xenial64     (virtualbox, 20190115.0.0)
ubuntu/xenial64     (virtualbox, 20190118.0.0)
ubuntu/xenial64     (virtualbox, 20190123.0.0)
ubuntu/xenial64     (virtualbox, 20190123.0.1)
ubuntu/xenial64     (virtualbox, 20190215.0.0)
…

Oracle Database 21c Express Edition

Oracle Database XE is the free Oracle Database edition for developers, DBAs, data scientists, educators and many more. It is the same powerful Oracle Database that enterprises rely on worldwide, packaged for simple download and install, ease-of-use, and a full-featured experience. You get an Oracle Database to use in any environment, plus the ability to embed and redistribute – all completely free!
[https://blogs.oracle.com/database/post/oracle-database-21c-xe-generally-available]

For installing Oracle Database XE, there are several options. In the list below I mention some of them that could be useful in my case.

Oracle Linux

  • Download oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm
  • Run “yum -y localinstall oracle-database-xe*”
  • Run “/etc/init.d/oracle-xe-21c configure”

By the way, with regard to the Operating System, the following Linux x86-64 kernels are supported:

  • Oracle Linux 8.2 with the Unbreakable Enterprise Kernel 6: 5.4.17-2011.1.2.el8uek.x86_64 or later
  • Oracle Linux 8.2 with the Red Hat Compatible Kernel: 4.18.0-193.19.1.el8_2.x86_64 or later
  • Oracle Linux 7.6 with the Unbreakable Enterprise Kernel 5: 4.14.35-2025.404.1.el7uek.x86_64 or later
  • Oracle Linux 7.4 with the Unbreakable Enterprise Kernel 4: 4.1.12-124.53.1.el7uek.x86_64 or later
  • Red Hat Enterprise Linux 8.2: 4.18.0-193.19.1.el8_2.x86_64 or later
  • SUSE Linux Enterprise Server 15 SP1: 4.12.14-197.29-default or later

If you use Oracle Linux, then Oracle recommends that you run the Oracle Database Preinstallation RPM for your Linux release to configure your operating system for Oracle Database and Oracle Grid Infrastructure installations.
[https://docs.oracle.com/en/database/oracle/oracle-database/21/ladbi/operating-system-checklist-for-oracle-database-installation-on-linux.html#GUID-E5C0A90E-7750-45D9-A8BC-C7319ED934F0]

Docker
A Linux Docker image can be built using the Dockerfiles provided under https://github.com/oracle/docker-images
[https://www.oracle.com/database/technologies/appdev/xe/quickstart.html]

I looked at the available Oracle Database container images.

Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1) lameriks 2021 11 27

Looking at the README.md, the most recent container image for XE was:
Oracle Database 18c (18.4.0) Express Edition (XE)

So, this was perhaps a good start, although it was not the 21c version I wanted.
[https://github.com/oracle/docker-images/blob/main/OracleDatabase/SingleInstance/README.md]

Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1) lameriks 2021 11 28
[https://github.com/oracle/docker-images/tree/main/OracleDatabase/SingleInstance/dockerfiles/18.4.0]

I reckoned that perhaps I could change the existing 18.4.0 scripts so they would work for 21c (but more about that, you can read in a next article).

From https://github.com/oracle/docker-images, I download the docker-images-main.zip from github.

Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1) lameriks 2021 11 29


VirtualBox
A Linux VirtualBox VM can be built using the Vagrant scripts provided under https://github.com/oracle/vagrant-boxes. You can also install into a Windows VirtualBox VM providing the version of Windows is supported. See the Oracle Database XE Windows Installation Guide.
[https://www.oracle.com/database/technologies/appdev/xe/quickstart.html]

Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1) lameriks 2021 11 30

Looking at the oracle/vagrant projects for the Oracle Database, the most recent project for XE was:
18.4.0-XE

Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1) lameriks 2021 11 31
[https://github.com/oracle/vagrant-projects/tree/main/OracleDatabase/18.4.0-XE]

So again, the latest 21c version of XE was not available.
[https://github.com/oracle/vagrant-projects/tree/main/OracleDatabase]

So, taking all the options mentioned above into account, as a first step for setting up my demo environment, I opted for setting up a Linux VirtualBox VM myself, by using Vagrant scripts (as I did many times before), and installing the Oracle Database XE by using the Linux Docker image, which can be built using the Dockerfile, provided for Oracle Database 18c (18.4.0) Express Edition (XE) on github.
[https://github.com/oracle/docker-images/tree/main/OracleDatabase/SingleInstance/dockerfiles/18.4.0]

At this point in setting up my demo environment, I am also going to use Docker. I already had a script file docker.sh for installing it, that I used when writing a previous article.
[https://technology.amis.nl/continuous-delivery/containers/rapidly-spinning-up-a-vm-with-ubuntu-docker-and-minikube-using-the-vm-drivernone-option-on-my-windows-laptop-using-vagrant-and-oracle-virtualbox/]

Docker Engine

Docker Engine is an open source containerization technology for building and containerizing your applications.
[https://docs.docker.com/engine/]

To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions:

  • Ubuntu Impish 21.10
  • Ubuntu Hirsute 21.04
  • Ubuntu Focal 20.04 (LTS)
  • Ubuntu Bionic 18.04 (LTS)

Docker Engine is supported on x86_64 (or amd64), armhf, arm64, and s390x architectures.
[https://docs.docker.com/engine/install/ubuntu/]

So, I chose: Ubuntu Focal 20.04 (LTS)

I followed the steps in :
https://docs.docker.com/engine/install/ubuntu/

and put them in my already existing script file docker.sh:
[in bold, I highlighted the changes]

#!/bin/bash
echo "**** Begin installing Docker Engine"

#Uninstall old versions
sudo apt-get remove docker docker-engine docker.io containerd runc

#Set up the repository
##Update the apt package index
sudo apt-get update
##Install packages to allow apt to use a repository over HTTPS
sudo apt-get install ca-certificates
sudo apt-get install curl
sudo apt-get install gnupg
sudo apt-get install lsb-release
##Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
##Set up the stable repository
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

#Install Docker Engine
##Update the apt package index
sudo apt-get update -qq
#Install a specific version of Docker Engine
sudo apt-get install -yqq docker-ce=5:20.10.10~3-0~ubuntu-focal docker-ce-cli=5:20.10.10~3-0~ubuntu-focal containerd.io
#Verify that Docker Engine is installed correctly by running the hello-world image
sudo docker run hello-world
#use Docker as a non-root user
sudo usermod -aG docker vagrant

echo "**** End installing Docker Engine"

Remark:
In order to list all the available versions of Docker Engine in the repo, you can use the following command (ones you are in the Oracle VirtualBox appliance via ssh):

sudo apt-cache madison docker-ce

With the following output:

 docker-ce | 5:20.10.10~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.9~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.8~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.7~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.6~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.5~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.4~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.3~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.2~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.1~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:20.10.0~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.15~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.14~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.13~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.12~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.11~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.10~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.9~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages

As you can see in my script file docker.sh, I chose: 5:20.10.10~3-0~ubuntu-focal

Then, I changed the Vagrantfile to contain the following:
[in bold, I highlighted the changes]

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/focal64"
  
  config.vm.define "ubuntu_docker" do |ubuntu_docker|
      
    config.vm.provider "virtualbox" do |vb|
        vb.name = "Ubuntu Docker"
        vb.memory = "8192"
        vb.cpus = "1"
      
      args = []
      config.vm.provision "docker shell script", type: "shell",
          path: "scripts/docker.sh",
          args: args
          
    end
    
  end

end

Creating the Oracle VirtualBox appliance

From the subdirectory named env on my Windows laptop, I opened a Windows Command Prompt (cmd) and typed: vagrant up

This command creates and configures guest machines according to your Vagrantfile.
[https://www.vagrantup.com/docs/cli/up.html]

With the following output (only showing certain parts):

Bringing machine 'ubuntu_docker' up with 'virtualbox' provider...
==> ubuntu_docker: Box 'ubuntu/focal64' could not be found. Attempting to find and install...
    ubuntu_docker: Box Provider: virtualbox
    ubuntu_docker: Box Version: >= 0
==> ubuntu_docker: Loading metadata for box 'ubuntu/focal64'
    ubuntu_docker: URL: https://vagrantcloud.com/ubuntu/focal64
==> ubuntu_docker: Adding box 'ubuntu/focal64' (v20211026.0.0) for provider: virtualbox
    ubuntu_docker: Downloading: https://vagrantcloud.com/ubuntu/boxes/focal64/versions/20211026.0.0/providers/virtualbox.box
Download redirected to host: cloud-images.ubuntu.com
    ubuntu_docker:
==> ubuntu_docker: Successfully added box 'ubuntu/focal64' (v20211026.0.0) for 'virtualbox'!
==> ubuntu_docker: Importing base box 'ubuntu/focal64'...
…
==> ubuntu_docker: Mounting shared folders...
    ubuntu_docker: /vagrant => C:/My/AMIS/env
…
    ubuntu_docker: **** Begin installing Docker Engine
…
    ubuntu_docker: Unable to find image 'hello-world:latest' locally
    ubuntu_docker: latest: Pulling from library/hello-world
    ubuntu_docker: 2db29710123e: Pulling fs layer
    ubuntu_docker: 2db29710123e: Verifying Checksum
    ubuntu_docker: 2db29710123e: Download complete
    ubuntu_docker: 2db29710123e: Pull complete
    ubuntu_docker: Digest: sha256:37a0b92b08d4919615c3ee023f7ddb068d12b8387475d64c622ac30f45c29c51
    ubuntu_docker: Status: Downloaded newer image for hello-world:latest
    ubuntu_docker:
    ubuntu_docker: Hello from Docker!
    ubuntu_docker: This message shows that your installation appears to be working correctly.
    ubuntu_docker:
    ubuntu_docker: To generate this message, Docker took the following steps:
    ubuntu_docker:  1. The Docker client contacted the Docker daemon.
    ubuntu_docker:  2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    ubuntu_docker:     (amd64)
    ubuntu_docker:  3. The Docker daemon created a new container from that image which runs the
    ubuntu_docker:     executable that produces the output you are currently reading.
    ubuntu_docker:  4. The Docker daemon streamed that output to the Docker client, which sent it
    ubuntu_docker:     to your terminal.
    ubuntu_docker:
    ubuntu_docker: To try something more ambitious, you can run an Ubuntu container with:
    ubuntu_docker:  &docker run -it ubuntu bash
    ubuntu_docker:
    ubuntu_docker: Share images, automate workflows, and more with a free Docker ID:
    ubuntu_docker:  https://hub.docker.com/
    ubuntu_docker:
    ubuntu_docker: For more examples and ideas, visit:
    ubuntu_docker:  https://docs.docker.com/get-started/
    ubuntu_docker:
    ubuntu_docker: **** End installing Docker Engine

Again, in order to list all the boxes that are installed into Vagrant, I used the following command:

vagrant box list

With the following output (only showing the ones for ubuntu):

…
ubuntu/bionic64     (virtualbox, 20190814.0.0)
ubuntu/bionic64     (virtualbox, 20191218.0.0)
ubuntu/bionic64     (virtualbox, 20200107.0.0)
ubuntu/bionic64     (virtualbox, 20200124.0.0)
ubuntu/bionic64     (virtualbox, 20200402.0.0)
ubuntu/bionic64     (virtualbox, 20200407.0.0)
ubuntu/bionic64     (virtualbox, 20200416.0.0)
ubuntu/bionic64     (virtualbox, 20200425.0.0)
ubuntu/bionic64     (virtualbox, 20200525.0.0)
ubuntu/bionic64     (virtualbox, 20200701.0.0)
ubuntu/bionic64     (virtualbox, 20200807.0.0)
ubuntu/bionic64     (virtualbox, 20200812.0.0)
ubuntu/bionic64     (virtualbox, 20200819.0.0)
ubuntu/bionic64     (virtualbox, 20211025.0.0)
ubuntu/focal64      (virtualbox, 20211026.0.0)
ubuntu/trusty64     (virtualbox, 20181103.0.0)
ubuntu/xenial64     (virtualbox, 20181223.0.0)
ubuntu/xenial64     (virtualbox, 20190101.0.0)
ubuntu/xenial64     (virtualbox, 20190109.0.0)
ubuntu/xenial64     (virtualbox, 20190115.0.0)
ubuntu/xenial64     (virtualbox, 20190118.0.0)
ubuntu/xenial64     (virtualbox, 20190123.0.0)
ubuntu/xenial64     (virtualbox, 20190123.0.1)
ubuntu/xenial64     (virtualbox, 20190215.0.0)
…

In the list above, you can see that box ‘ubuntu/focal64’ (v20211026.0.0) was added successfully and that Docker was also working.

And the Oracle VirtualBox appliance was running.

Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1) lameriks 2021 11 32

So, then I first tried installing the already available Oracle Database 18.4.0 XE.

Getting dockerfiles for Oracle Database 18.4.0 XE

From the docker-images-main.zip, I downloaded earlier from github, I extracted directory OracleDatabase\SingleInstance\dockerfiles\18.4.0 to directory
C:\My\AMIS\env\oraclexedatabase\dockerfiles\18.4.0
[https://github.com/oracle/docker-images/tree/main/OracleDatabase/SingleInstance/dockerfiles/18.4.0]

Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1) lameriks 2021 11 33

I also I extracted file buildContainerImage.sh to directory C:\My\AMIS\env\oraclexedatabase\dockerfiles
[https://github.com/oracle/docker-images/blob/main/OracleDatabase/SingleInstance/dockerfiles/buildContainerImage.sh]

Remark about shared folder:

Mounting shared folders...
    ubuntu_docker: /vagrant => C:/My/AMIS/env

As you can see in the output from vagrant up via the shared folder, the copied files are now also available from within the Oracle VirtualBox appliance.

Building Oracle Database container image for Oracle Database 18.4.0 XE

I used vagrant ssh to connect into the running VM. Next, in order to build the image for Oracle Database 18.4.0 XE, I used the following commands on the Linux Command Prompt (after reading README.md):

cd /vagrant/oraclexedatabase/dockerfiles
./buildContainerImage.sh -v 18.4.0 -x

[https://github.com/oracle/docker-images/blob/main/OracleDatabase/SingleInstance/README.md]

Remark:
There are some steps (see pictures below) in the process that take a long time, it seems like the process is hanging, but you have to be patience. The whole process can take more than 5 minutes.

Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1) lameriks 2021 11 34

Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1) lameriks 2021 11 35

With the following output:

WARNING: No swap limit support
Checking Docker version.
…
Building image 'oracle/database:18.4.0-xe' ...
Sending build context to Docker daemon  19.46kB
Step 1/8 : FROM oraclelinux:7-slim
7-slim: Pulling from library/oraclelinux
a755c2d4aa36: Pull complete
…
Complete!
Loaded plugins: ovl
…
Transaction test succeeded
Running transaction
  Installing : file-5.11-37.el7.x86_64                                      1/2
  Installing : oracle-database-xe-18c-1.0-1.x86_64                          2/2
[INFO] Executing post installation scripts...
…
Successfully built b1b2390e2d72
Successfully tagged oracle/database:18.4.0-xe


  Oracle Database container image for 'xe' version 18.4.0 is ready to be extended:

    --> oracle/database:18.4.0-xe

  Build completed in 614 seconds.

vagrant@ubuntu-focal:/vagrant/oraclexedatabase/dockerfiles$

Remark:
When you take a look at the script buildContainerImage.sh, the part for building the image is:

# ################## #
# BUILDING THE IMAGE #
# ################## #
echo "Building image '${IMAGE_NAME}' ..."

# BUILD THE IMAGE (replace all environment variables)
BUILD_START=$(date '+%s')
"${CONTAINER_RUNTIME}" build --force-rm=true --no-cache=true \
       "${BUILD_OPTS[@]}" "${PROXY_SETTINGS[@]}" --build-arg DB_EDITION=${EDITION} \
       -t "${IMAGE_NAME}" -f "${DOCKERFILE}" . || {
  echo ""
  echo "ERROR: Oracle Database container image was NOT successfully created."
  echo "ERROR: Check the output and correct any reported problems with the build operation."
  exit 1
}

[https://github.com/oracle/docker-images/blob/main/OracleDatabase/SingleInstance/dockerfiles/buildContainerImage.sh]

In my case, this was the actual command being used (showing the image name and Dockerfile name):

/usr/bin/docker build –force-rm=true –no-cache=true –build-arg DB_EDITION=xe -t oracle/database:18.4.0-xe -f Dockerfile.xe . ||

In order to get a list of all the docker images, I used the following command on the Linux Command Prompt:

docker image ls

With the following output:

REPOSITORY        TAG         IMAGE ID       CREATED         SIZE
oracle/database   18.4.0-xe   b1b2390e2d72   9 minutes ago   5.89GB
oraclelinux       7-slim      078d6e3ae75e   2 weeks ago     132MB
hello-world       latest      feb5d9fea6a5   7 weeks ago     13.3kB

So, here we can see the image was successfully created.

Running Oracle Database 18.4.0 XE in a container

For creating a container based on an image, the following command can be used: docker run

In order to create the container, I used the following command on the Linux Command Prompt (after reading README.md):

docker run --name oracle_database_18.4.0-xe \
-p 1521:1521 -p 5500:5500 \
-e ORACLE_PWD=manager \
-e ORACLE_CHARACTERSET=AL32UTF8 \
-v /opt/oracle/oradata:/opt/oracle/oradata \
oracle/database:18.4.0-xe

Parameters:

–name: The name of the container (default: auto generated)
-p: The port mapping of the host port to the container port.
Two ports are exposed: 1521 (Oracle Listener), 5500 (EM Express)
-e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated
-e ORACLE_CHARACTERSET:
The character set to use when creating the database (default: AL32UTF8)
-v /opt/oracle/oradata
The data volume to use for the database.
Has to be writable by the Unix “oracle” (uid: 54321) user inside the container!
If omitted the database will not be persisted over container recreation.
-v /opt/oracle/scripts/startup | /docker-entrypoint-initdb.d/startup
Optional: A volume with custom scripts to be run after database startup.
For further details see the “Running scripts after setup and on startup” section below.
-v /opt/oracle/scripts/setup | /docker-entrypoint-initdb.d/setup
Optional: A volume with custom scripts to be run after database setup.

[https://github.com/oracle/docker-images/blob/main/OracleDatabase/SingleInstance/README.md]

With the following output:

ORACLE PASSWORD FOR SYS AND SYSTEM: manager
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.
Enter SYS user password:
******
Enter SYSTEM user password:
******
Enter PDBADMIN User Password:
*********
Prepare for db operation
Cannot create directory "/opt/oracle/oradata/XE".
7% complete
Copying database files
29% complete
100% complete
[FATAL] Recovery Manager failed to restore datafiles. Refer logs for details.
7% complete
0% complete
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.

Database configuration failed. Check logs under '/opt/oracle/cfgtoollogs/dbca'.
mkdir: cannot create directory '/opt/oracle/oradata/dbconfig': Permission denied
mv: cannot stat '/opt/oracle/product/18c/dbhomeXE/dbs/spfileXE.ora': No such file or directory
mv: cannot move '/opt/oracle/product/18c/dbhomeXE/dbs/orapwXE' to '/opt/oracle/oradata/dbconfig/XE/': No such file or directory
mv: cannot move '/opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora' to '/opt/oracle/oradata/dbconfig/XE/': No such file or directory
mv: cannot move '/opt/oracle/product/18c/dbhomeXE/network/admin/tnsnames.ora' to '/opt/oracle/oradata/dbconfig/XE/': No such file or directory
cp: cannot create regular file '/opt/oracle/oradata/dbconfig/XE/': No such file or directory
ln: failed to create symbolic link '/opt/oracle/product/18c/dbhomeXE/dbs/orapwXE': File exists
cp: cannot stat '/opt/oracle/oradata/dbconfig/XE/oratab': No such file or directory
The Oracle base remains unchanged with value /opt/oracle
#####################################
########### E R R O R ###############
DATABASE SETUP WAS NOT SUCCESSFUL!
Please check output for further info!
########### E R R O R ###############
#####################################
The following output is now a tail of the alert.log:
Changing di2dbun from xe to XE
.... (PID:613): Redo network throttle feature is disabled at mount time
2021-11-17T07:14:28.223270+00:00
Successful mount of redo thread 1, with mount id 2969993360
2021-11-17T07:14:28.223527+00:00
Database mounted in Exclusive Mode
Lost write protection disabled
.... (PID:613): Using STANDBY_ARCHIVE_DEST parameter default value as /opt/oracle/product/18c/dbhomeXE/dbs/arch [krsd.c:17717]
Create Relation IPS_PACKAGE_UNPACK_HISTORY
Completed: ALTER DATABASE   MOUNT
^Cvagrant@ubuntu-focal:/vagrant/oraclexedatabase/dockerfiles$

So, I canceled the command.

After further reading the README.md, I saw the following remark:

The data volume to use for the database.
Has to be writable by the Unix “oracle” (uid: 54321) user inside the container!>
If omitted the database will not be persisted over container recreation.
[https://github.com/oracle/docker-images/blob/main/OracleDatabase/SingleInstance/README.md]

So, I checked the directory:

cd /opt/oracle/oradata
ls -latr

With the following output:

total 8
drwxr-xr-x 3 root root 4096 Nov 17 07:13 ..
drwxr-xr-x 2 root root 4096 Nov 17 07:13 .

And I changed, the rights:

sudo chmod -R o+w 
ls -latr

With the following output:

total 8
drwxr-xr-x 3 root root 4096 Nov 17 07:13 ..
drwxr-xrwx 2 root root 4096 Nov 17 07:13 .

I checked the list of all the docker containers:

docker container ls -a

With the following output:

CONTAINER ID   IMAGE                       COMMAND                  CREATED         STATUS                       PORTS     NAMES
dcbe02842070   oracle/database:18.4.0-xe   "/bin/sh -c 'exec $O…"   5 minutes ago   Exited (129) 3 minutes ago             oracle_database_18.4.0-xe
4077a9630d2b   hello-world                 "/hello"                 13 hours ago    Exited (0) 13 hours ago                pedantic_almeida
vagrant@ubuntu-focal:/opt/oracle/oradata$

In order to remove the docker container, I used the following command on the Linux Command Prompt:

docker container rm oracle_database_18.4.0-xe

With the following output:

oracle_database_18.4.0-xe

Again, I checked the list of all the docker containers:

docker container ls -a

With the following output:

CONTAINER ID   IMAGE         COMMAND    CREATED        STATUS                    PORTS     NAMES
4077a9630d2b   hello-world   "/hello"   13 hours ago   Exited (0) 13 hours ago             pedantic_almeida

Again, in order to create the container, I used the following command on the Linux Command Prompt (after reading README.md):

docker run --name oracle_database_18.4.0-xe \
-p 1521:1521 -p 5500:5500 \
-e ORACLE_PWD=manager \
-e ORACLE_CHARACTERSET=AL32UTF8 \
-v /opt/oracle/oradata:/opt/oracle/oradata \
oracle/database:18.4.0-xe

[https://github.com/oracle/docker-images/blob/main/OracleDatabase/SingleInstance/README.md]

This time, with the following output:

ORACLE PASSWORD FOR SYS AND SYSTEM: manager
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.
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
31% complete
34% complete
38% complete
41% 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
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.

Connect to Oracle Database using one of the connect strings:
     Pluggable database: a7e088c563b7/XEPDB1
     Multitenant container database: a7e088c563b7
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
The Oracle base remains unchanged with value /opt/oracle
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
2021-11-17T07:39:16.965489+00:00
XEPDB1(3):Resize operation completed for file# 10, old size 358400K, new size 368640K
2021-11-17T07:39:18.595777+00:00
XEPDB1(3):CREATE SMALLFILE TABLESPACE "USERS" LOGGING  DATAFILE  '/opt/oracle/oradata/XE/XEPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO
XEPDB1(3):Completed: CREATE SMALLFILE TABLESPACE "USERS" LOGGING  DATAFILE  '/opt/oracle/oradata/XE/XEPDB1/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO
XEPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
XEPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2021-11-17T07:39:19.242467+00:00
ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
Completed: ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
^Cvagrant@ubuntu-focal:/opt/oracle/oradata$

I canceled the tail command and, I checked the directory:

ls -latr

With the following output:

total 16
drwxr-xr-x 3 root  root  4096 Nov 17 07:13 ..
drwxr-x--- 4 54321 54321 4096 Nov 17 07:32 XE
drwxr-xr-x 3 54321 54321 4096 Nov 17 07:39 dbconfig
drwxr-xrwx 4 root  root  4096 Nov 17 07:39 .

Again, I checked the list of all the docker containers:

docker container ls -a

With the following output:

CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                       PORTS     NAMES
a7e088c563b7   oracle/database:18.4.0-xe   "/bin/sh -c 'exec $O…"   17 minutes ago   Exited (129) 4 minutes ago             oracle_database_18.4.0-xe
4077a9630d2b   hello-world                 "/hello"                 13 hours ago     Exited (0) 13 hours ago                pedantic_almeida

So, because I canceled the command, the database was stopped.
No, problem, I restarted it.

docker container start oracle_database_18.4.0-xe

With the following output:

oracle_database_18.4.0-xe

Again, I checked the list of all the docker containers (and I repeated this command until the STATUS was healthy):

docker container ls -a

With the following output:

CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                             PORTS                                                                                  NAMES
a7e088c563b7   oracle/database:18.4.0-xe   "/bin/sh -c 'exec $O…"   22 minutes ago   Up 36 seconds (health: starting)   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:5500->5500/tcp, :::5500->5500/tcp   oracle_database_18.4.0-xe
4077a9630d2b   hello-world                 "/hello"                 14 hours ago     Exited (0) 14 hours ago                                                                                                   pedantic_almeida

CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                             PORTS                                                                                  NAMES
a7e088c563b7   oracle/database:18.4.0-xe   "/bin/sh -c 'exec $O…"   22 minutes ago   Up 47 seconds (health: starting)   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:5500->5500/tcp, :::5500->5500/tcp   oracle_database_18.4.0-xe
4077a9630d2b   hello-world                 "/hello"                 14 hours ago     Exited (0) 14 hours ago                                                                                                   pedantic_almeida

CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                             PORTS                                                                                  NAMES
a7e088c563b7   oracle/database:18.4.0-xe   "/bin/sh -c 'exec $O…"   22 minutes ago   Up 56 seconds (health: starting)   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:5500->5500/tcp, :::5500->5500/tcp   oracle_database_18.4.0-xe
4077a9630d2b   hello-world                 "/hello"                 14 hours ago     Exited (0) 14 hours ago                                                                                                   pedantic_almeida

CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                        PORTS                                                                                  NAMES
a7e088c563b7   oracle/database:18.4.0-xe   "/bin/sh -c 'exec $O…"   22 minutes ago   Up About a minute (healthy)   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:5500->5500/tcp, :::5500->5500/tcp   oracle_database_18.4.0-xe
4077a9630d2b   hello-world                 "/hello"                 14 hours ago     Exited (0) 14 hours ago                                                                                              pedantic_almeida

Running SQL*Plus

Next, I wanted to check the database via SQL*Plus.

See the following in the README.md:

Once the container has been started you can connect to it just like to any other database:

sqlplus sys/<your password>@//localhost:1521/XE as sysdba
sqlplus system/<your password>@//localhost:1521/XE

You may use the same container image you used to start the database, to run sqlplus to connect to it, for example:

docker run –rm -ti oracle/database:19.3.0-ee sqlplus pdbadmin/<yourpassword>@//<db-container-ip>:1521/ORCLPDB1

Another option is to use docker exec and run sqlplus from within the same container already running the database:

docker exec -ti <container name> sqlplus pdbadmin@ORCLPDB1
[https://github.com/oracle/docker-images/blob/main/OracleDatabase/SingleInstance/README.md]

I opted for running SQL*Plus in a container.

docker exec -ti oracle_database_18.4.0-xe sqlplus system/manager@//localhost:1521/XE

With the following output:

SQL*Plus: Release 18.0.0.0.0 - Production on Wed Nov 17 07:57:02 2021
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

Last Successful login time: Wed Nov 17 2021 07:56:47 +00:00

Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL>

I issued the following SQL command:

SQL> select count(*) from user_tables;

With the following output:

  COUNT(*)
----------
       128

Next, I used exit to close SQL*Plus.

With the following output:

Disconnected from Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

So, the database was working and I could use SQL statements. Great!

With exit I closed the ssh Windows Command Prompt.

In a next article, you can read more about the steps I took to get Oracle Database 21c XE working.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.