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

Marc Lameriks

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 getting Oracle Database 21c XE working and using IntelliJ IDEA Community Edition and the Database Navigator to connect to it.

Remember, I ended my previous article with an error I got:

So, this accounts for:
Incorrect ownership/permissions detected for the file /opt/oracle/product/21c/dbhomeXE/bin/oradism

Again, as mentioned above, root(0) was expected, but oracle(54321) was found.

So, what to do now?

Summarization of my findings as described in my previous article

First, let’s have a look at the error again:

[FATAL] [DBT-10011] Incorrect ownership/permissions detected for the file (/opt/oracle/product/21c/dbhomeXE/bin/oradism).
   CAUSE: Following nodes does not have required file ownership/permissions: Node :9a4154bb1e13
PRVG-11960 : Set user ID bit is not set for file "/opt/oracle/product/21c/dbhomeXE/bin/oradism" on node "9a4154bb1e13".
PRVG-2031 : Owner of file "/opt/oracle/product/21c/dbhomeXE/bin/oradism" did not match the expected value on node "9a4154bb1e13". [Expected = "root(0)" ; Found = "oracle(54321)"]

There is a problem with the file:

/opt/oracle/product/21c/dbhomeXE/bin/oradism

with regard to file ownership/permissions.
Apparently, root(0) was expected, but oracle(54321) was found.

Next, I summarize the findings I described in my previous article:

  • The RUN part from file Dockerfile.xe , contains this line:
chown -R oracle:oinstall /opt/oracle /home/oracle && \

So, what we see here is that via the command above, the directories /opt/oracle and /home/oracle are owned by oracle and belong to group oinstall.

  • The RUN part from file Dockerfile.xe , contains this line:
    chmod ug+x /opt/oracle/*.sh

So, what we see here is that via the command above, for every shell script (*.sh) in the directory /opt/oracle the user who owns it (u), and other users in the file’s group (g) can execute (x) that script.
[Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 2)]

Getting a list of files and directories from the running docker container

I wanted a list of files and directories from the running docker container for the Oracle Database 12c XE version. But this time, I could not get them by opening a shell into the running docker container, as I did with the Oracle Database 18.4.0 XE version (as described in my previous article), because obviously I got an error when I tried to create the container.

So, I had another plan.

I looked the instructions in the file Dockerfile.xe (only showing the last part):

…
CMD exec $ORACLE_BASE/$RUN_FILE

For my own convenience, I repeat here the CMD part from file Dockerfile.xe , with the actual values:

CMD exec /opt/oracle/runOracle.sh

Remark:
When used in the shell or exec formats, the CMD instruction sets the command to be executed when running the image.
[https://docs.docker.com/engine/reference/builder/#cmd ]

I also had a look at the content of file runOracle.sh. In line with other commands in that file, I added the command to get a list of files and directories (for /opt/oracle/product/21c/dbhomeXE/bin):
[in bold, I highlighted the changes]

…
############# MAIN ################

# Set SIGTERM handler
trap _term SIGTERM
echo "AMIS begin list of files and directories"
su -p oracle -c "ls -latr /opt/oracle/product/21c/dbhomeXE/bin"
echo "AMIS end list of files and directories"
# Check whether database already exists
if [ -d $ORACLE_BASE/oradata/$ORACLE_SID ]; then
   symLinkFiles;
   # Make sure audit file destination exists
   if [ ! -d $ORACLE_BASE/admin/$ORACLE_SID/adump ]; then
      su -p oracle -c "mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump"
   fi;
else
    # If the oradata folder is missing/empty, but db was previously set up,
    # allow a new db to be set up in its place
    undoSymLinkFiles;
fi;

/etc/init.d/oracle-xe-21c start | grep -qc "Oracle Database is not configured"
if [ "$?" == "0" ]; then
   # Create database
   createDB;
   
   # Execute custom provided setup scripts
   runUserScripts $ORACLE_BASE/scripts/setup
fi;

# Check whether database is up and running
$ORACLE_BASE/$CHECK_DB_FILE
if [ $? -eq 0 ]; then
  echo "#########################"
  echo "DATABASE IS READY TO USE!"
  echo "#########################"

  # Execute custom provided startup scripts
  runUserScripts $ORACLE_BASE/scripts/startup

else
  echo "#####################################"
  echo "########### E R R O R ###############"
  echo "DATABASE SETUP WAS NOT SUCCESSFUL!"
  echo "Please check output for further info!"
  echo "########### E R R O R ###############"
  echo "#####################################"
fi;

echo "The following output is now a tail of the alert.log:"
tail -f $ORACLE_BASE/diag/rdbms/*/*/trace/alert*.log &
childPID=$!
wait $childPID

Stop and start the running machine

I continue where I left off in the previous article, where I created an Oracle VirtualBox appliance with
Oracle Database 21c XE, with the help of Vagrant.
[Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 2)]

I wanted to start more or less from scratch, and with Vagrant that’s no problem.

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

vagrant destroy

With the following output:

    ubuntu_docker: Are you sure you want to destroy the 'ubuntu_docker' VM? [y/N] y
==> ubuntu_docker: Destroying VM and associated drives...

Next, I typed:

vagrant up

With the following output (only showing certain parts):

Bringing machine 'ubuntu_docker' up with 'virtualbox' provider...
==> ubuntu_docker: Importing base box 'ubuntu/focal64'...
==> ubuntu_docker: Matching MAC address for NAT networking...
==> ubuntu_docker: Checking if box 'ubuntu/focal64' version '20211026.0.0' is up to date...
==> ubuntu_docker: Setting the name of the VM: Ubuntu Docker
…
==> 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:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
    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:  nbsp;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

Building Oracle Database container image for Oracle Database 12c XE

I used vagrant ssh to connect into the running VM. Next, in order to build the image for Oracle Database 21c XE, I used the following commands on the Linux Command:

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

Remark:
There are some steps 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.

With the following output:

WARNING: No swap limit support
Checking Docker version.
Ignored MD5 checksum.
...
Building image 'oracle/database:21.0.0-xe' ...
Sending build context to Docker daemon  20.48kB
Step 1/8 : FROM oraclelinux:7-slim
7-slim: Pulling from library/oraclelinux
f09c1d3b7e7b: Pulling fs layer
f09c1d3b7e7b: Verifying Checksum
f09c1d3b7e7b: Download complete
f09c1d3b7e7b: 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-21c-1.0-1.x86_64                          2/2
[INFO] Executing post installation scripts...
...
Successfully built 3c41ad9aac32
Successfully tagged oracle/database:21.0.0-xe


  Oracle Database container image for 'xe' version 21.0.0 is ready to be extended:
    ubuntu_docker:
    --> oracle/database:21.0.0-xe

  Build completed in 723 seconds.

So, as before building the image was successful.

But in order to see the result from my added command to get a list of files and directories, I had to run the image.

Running Oracle Database 21c XE in a container

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

sudo docker run --name oracle_database_21.0.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:21.0.0-xe

With the following output:

AMIS begin list of files and directories
total 810804
-rwxr-xr-x  1 oracle oinstall       153 Nov  7  1997 echodo
-rwxr-xr-x  1 oracle oinstall      5226 Jan  1  2000 orald
-rwxr-xr-x  1 oracle oinstall      6887 Jan  1  2000 oraenv
-rw-r--r--  1 oracle oinstall      5003 Jan  1  2000 oerr.pl
-rwxr-xr-x  1 oracle oinstall       703 Jan  1  2000 oerr
-rwxr-x---  1 oracle oinstall     15737 Jan  1  2000 dbstart
-rwxr-x---  1 oracle oinstall      8142 Jan  1  2000 dbshut
-rwxr-xr-x  1 oracle oinstall      2445 Jan  1  2000 dbhome
-rwxr-xr-x  1 oracle oinstall      6468 Jan  1  2000 coraenv
-rwxr-xr-x  1 oracle oinstall      3261 May  4  2000 symfind
-rwxr-x---  1 oracle oinstall        48 Sep 25  2000 oraxml
-rwxr-x---  1 oracle oinstall        48 Sep 25  2000 oraxsl
-rwxr-x---  1 oracle oinstall        46 Nov  7  2000 oracg
-rwxr-x---  1 oracle oinstall        45 Sep 26  2001 transx
-rwxr-x---  1 oracle oinstall        59 Nov 25  2002 orapipe
-rwxr-x---  1 oracle oinstall        44 Dec  5  2002 orajaxb
-rwxr-x---  1 oracle oinstall      6537 Sep 28  2012 emdwgrd
-rwxr-xr-x  1 oracle oinstall      1000 Jul  1  2014 afdroot
-rwxr-xr-x  1 oracle oinstall      1635 Dec  5  2014 linkshlib
-rw-------  1 oracle oinstall      5978 Jun 21  2017 ore_srcexport.pl
-rw-------  1 oracle oinstall      4331 Jun 21  2017 ore_dsiimport.pl
-rw-------  1 oracle oinstall      4799 Jun 21  2017 ore_dsiexport.pl
-rw-------  1 oracle oinstall      7472 Jun 21  2017 ore_destimport.pl
-rw-r-----  1 oracle oinstall       999 Aug 23  2017 dbSetup.pl
-rwxr-x---  1 oracle oinstall     65179 Aug 24  2017 emdwgrd.pl
-rwxr-x---  1 oracle oinstall       768 Aug 26  2017 xsql
-rwxr-x---  1 oracle oinstall      5385 Oct  2  2017 patchgen
-rwxr-xr-x  1 oracle oinstall      1001 Nov 27  2017 olfscmd
-rwxr-xr-x  1 oracle oinstall      7059 Dec  7  2017 okcreate
-rwxr-x---  1 oracle oinstall      6966 Jan 30  2018 asmcmd
-rwxr-xr-x  1 oracle oinstall       727 May 22  2018 acfsremote
-rwxr-xr-x  1 oracle oinstall      6981 Aug 27  2018 relink
-rwxr-xr-x  1 oracle oinstall      1007 Feb 23  2019 olfsroot
-rwxr-xr-x  1 oracle oinstall     13483 Mar 21  2019 adapters
-rwxr-xr-x  1 oracle oinstall       940 Jul  1  2019 okaroot
-rwxr-xr-x  1 oracle oinstall       945 Sep  1  2019 acfsroot
-rwxr-xr-x  1 oracle oinstall      5720 Dec 24  2019 rhpctl
-rwx------  1 oracle oinstall      1535 Feb 28  2020 rootPreRequired.sh
-rwxr-xr-x  1 oracle oinstall      6098 Jun 18  2020 owm
-rwxr-xr-x  1 oracle oinstall     78363 Jun 24  2020 asmcmdcore
-rw-r--r--  1 oracle oinstall     13381 Jun 29  2020 dbreload
-rw-r--r--  1 oracle oinstall     14737 Jun 29  2020 dbdowngrade
-rwx------  1 oracle oinstall     91848 Jul  7  2020 xmlwf
-rwxr-xr-x  1 oracle oinstall         0 Jul 19  2020 tnnfg
-rwxr-x---  1 oracle oinstall      1400 Jul 19  2020 cluvfyrac.sh
-rwxr-xr-x  1 oracle oinstall      1400 Jul 19  2020 cluvfy
-rw-r--r--  1 oracle oinstall      9368 Jul 20  2020 aqxmlctl.pl
-rwxr-xr-x  1 oracle oinstall      4726 Sep 18  2020 orapki
-rwxr-xr-x  1 oracle oinstall      4692 Sep 18  2020 mkstore
-rwxr-xr-x  1 oracle oinstall    229528 Nov 27  2020 zip
-rwxr-x---  1 oracle oinstall      3241 Feb  2  2021 commonSetup.sh
-rw-r--r--  1 oracle oinstall     52835 Feb 20  2021 CommonSetup.pm
-rwxr-----  1 oracle oinstall     13106 Mar 16  2021 mgmtprepatchbootstrap.pl
-rw-r--r--  1 oracle oinstall  56500128 Jun 23 09:53 omsfscmds
-rw-r--r--  1 oracle oinstall  56469952 Jun 23 09:53 oms_daemon
-rwxr-xr-x  1 oracle oinstall  90848352 Jul  1 18:30 afdboot
-rwxr-xr-x  1 oracle oinstall    294336 Jul  1 18:31 afdtool.bin
-rwxr-xr-x  1 oracle oinstall     39008 Jul  1 18:37 olfsctl
-rw-------  1 oracle oinstall     86536 Jul  5 16:14 okinit0
-rw-------  1 oracle oinstall     85304 Jul  5 16:14 okdstry0
-rw-------  1 oracle oinstall     96448 Jul  5 16:14 oklist0
-rwxr-x---  1 oracle oinstall    144088 Jul  6 05:51 xml
-rwxr-x---  1 oracle oinstall     57136 Jul  6 05:51 xsl
-rwxr-x---  1 oracle oinstall    192560 Jul  6 05:51 xmlcg
-rwxr-x---  1 oracle oinstall     34616 Jul  6 05:51 schema
-rwxr-x---  1 oracle oinstall     40784 Jul  6 05:52 xvm
-rwxr-x---  1 oracle oinstall     29584 Jul  6 05:52 xmlpatch
-rwxr-x---  1 oracle oinstall     29608 Jul  6 05:52 xmldiff
-rwxr-xr-x  1 oracle oinstall   7316848 Jul  6 09:10 lxinst
-rwxr-xr-x  1 oracle oinstall   2241480 Jul  6 09:10 lxegen
-rwxr-xr-x  1 oracle oinstall   1771792 Jul  6 09:10 lxchknlb
-rwxr-xr-x  1 oracle oinstall   1833480 Jul  6 09:10 lmsgen
-rwxr-xr-x  1 oracle oinstall   3118944 Jul  6 09:10 lcsscan
-rwxr-xr-x  1 oracle oinstall     73480 Jul  8 09:40 lsnodes
-rwxr-xr-x  1 oracle oinstall     41216 Aug 17 21:23 rtsora
-rwxr-x--x  1 oracle oinstall     31600 Aug 17 22:44 osh
-rwxr-x--x  1 oracle oinstall     26904 Aug 17 22:44 oraversion
-rwxr-x---  1 oracle oinstall     59080 Aug 17 22:44 oraping
-rwxr-x---  1 oracle oinstall    203400 Aug 17 22:44 oradnfs
-rwxr-x---  1 oracle oinstall   1867560 Aug 17 22:44 oradism
-rwxr-x---  1 oracle oinstall   1858568 Aug 17 22:44 orabasehome
-rwxr-x---  1 oracle oinstall   1858576 Aug 17 22:44 orabaseconfig
-rwxr-xr-x  1 oracle oinstall     36208 Aug 17 22:44 orabase
-rw-r--r--  1 oracle oinstall     32056 Aug 17 22:44 ora_server_kill
-rw-r--r--  1 oracle oinstall    208520 Aug 17 22:44 opwdintg.exe
-rwxr-xr-x  1 oracle oinstall    252792 Aug 17 22:44 okbcfg
-rwxr-x---  1 oracle oinstall     36927 Aug 17 22:44 mtactl
-rwxr-x---  1 oracle oinstall   1738264 Aug 17 22:44 fmputlhp
-rwxr-x---  1 oracle oinstall   2001224 Aug 17 22:44 fmputl
-rwxr-xr-x  1 oracle oinstall   2491696 Aug 17 22:44 diskmon
-rwxr-x---  1 oracle oinstall      3136 Aug 17 22:44 dbupgrade
-rwxr-xr-x  1 oracle oinstall     74344 Aug 17 22:44 dbnest
-rw-r-----  1 oracle oinstall      5297 Aug 17 22:44 dbgeu_run_action.pl
-rwxr-x--x  1 oracle oinstall   1292816 Aug 17 22:44 dbfs_client
-rw-r--r--  1 oracle oinstall    170557 Aug 17 22:44 bdschecksw
-rwxr-xr-x  1 oracle oinstall      3731 Aug 18 01:04 afdtool
-rwxr-xr-x  1 oracle oinstall      3078 Aug 18 01:04 afddriverstate
-rwxr-xr-x  1 oracle oinstall      4364 Aug 18 05:57 umu
-rwxr-xr-x  1 oracle oinstall      1352 Aug 18 05:57 statusnc
-rwxr-xr-x  1 oracle oinstall       943 Aug 18 05:57 ott
-rwxr-xr-x  1 oracle oinstall      1743 Aug 18 05:57 olsoidsync
-rwxr-xr-x  1 oracle oinstall      1441 Aug 18 05:57 olsadmintool
-rwxr-xr-x  1 oracle oinstall      1315 Aug 18 05:57 ojvmtc
-rwxr-xr-x  1 oracle oinstall      1433 Aug 18 05:57 ojvmjava
-rwxr-xr-x  1 oracle oinstall      1351 Aug 18 05:57 ncomp
-rwxr-xr-x  1 oracle oinstall      2452 Aug 18 05:57 loadjava
-rwxr-xr-x  1 oracle oinstall      2518 Aug 18 05:57 eusm
-rwxr-xr-x  1 oracle oinstall      1461 Aug 18 05:57 dropjava
-rwxr-xr-x  1 oracle oinstall      1515 Aug 18 05:57 deploync
-rw-r--r--  1 oracle oinstall       909 Aug 18 05:57 ORE
-rwxr-xr-x  1 oracle oinstall      3007 Aug 18 05:57 trcasst
-rwxr-x---  1 oracle oinstall     13413 Aug 18 05:57 srvctl
-rwxr-x---  1 oracle oinstall      4827 Aug 18 05:57 roohctl
-rwxr-x---  1 oracle oinstall      7549 Aug 18 05:57 rconfig
-rw-r-----  1 oracle oinstall      4451 Aug 18 05:57 platform_common
-rwxr-xr-x  1 oracle oinstall      3132 Aug 18 05:57 oidprovtool
-rwxr-x---  1 oracle oinstall      7732 Aug 18 05:57 netmgr
-rwxr-xr-x  1 oracle oinstall      2898 Aug 18 05:57 ldifmigrator
-rwxr-xr-x  1 oracle oinstall      4749 Aug 18 05:57 srvconfig
-rwxr-x---  1 oracle oinstall      2847 Aug 18 05:57 schemasync
-rwxr-x---  1 oracle oinstall      1781 Aug 18 05:57 schagent
-rwxr-xr-x  1 oracle oinstall      2173 Aug 18 05:57 oidca
-rwxr-x---  1 oracle oinstall      1304 Aug 18 05:57 odisrvreg
-rwxr-x---  1 oracle oinstall       107 Aug 18 05:57 netca_deinst.sh
-rwxr-x---  1 oracle oinstall      6734 Aug 18 05:57 netca
-rwxr-xr-x  1 oracle oinstall       484 Aug 18 05:57 kfod
-rwxr-xr-x  1 oracle oinstall      7277 Aug 18 05:57 diagsetup
-rwxr-x---  1 oracle oinstall     12187 Aug 18 05:57 dbua
-rwxr-x---  1 oracle oinstall      2087 Aug 18 05:57 aqxmlctl
-rwxr-xr-x  1 oracle oinstall      2147 Aug 18 05:57 trcsess
-rwxr-x---  1 oracle oinstall      2411 Aug 18 05:57 oradnfs_run.sh
-rwxr-x---  1 oracle oinstall       472 Aug 18 05:57 extusrupgrade
-rw-r-----  1 oracle oinstall      7140 Aug 18 05:57 chopt.pl
-rw-r-----  1 oracle oinstall      2293 Aug 18 05:57 chopt.ini
-rwxr-x---  1 oracle oinstall       284 Aug 18 05:57 chopt
-rwxr-xr-x  1 oracle oinstall  10359176 Aug 18 05:58 procob
-rwxr-xr-x  1 oracle oinstall  10714656 Aug 18 05:58 proc
-rwxr-x--x  1 oracle oinstall    717472 Aug 18 05:58 dg4odbc
-rwxr-x--x  1 oracle oinstall    375280 Aug 18 05:58 ctxload
-rwxr-x--x  1 oracle oinstall    776448 Aug 18 05:58 ctxlc
-rwxr-x--x  1 oracle oinstall    869344 Aug 18 05:58 ctxkbtc
-rwxr-x--x  1 oracle oinstall   9700384 Aug 18 05:58 wrap
-rwxr-x--x  1 oracle oinstall     41568 Aug 18 05:58 tstshm
-rwxr-x--x  1 oracle oinstall     35944 Aug 18 05:58 maxmem
-rwxr-x--x  1 oracle oinstall    109152 Aug 18 05:58 dbv
-rwxr-x--x  1 oracle oinstall    169232 Aug 18 05:58 orapwd
-rwxr-x--x  1 oracle oinstall     35368 Aug 18 05:58 dbfsize
-rwxr-x--x  1 oracle oinstall   1580448 Aug 18 05:58 mapsga
-rwxr-x--x  1 oracle oinstall   1580936 Aug 18 05:58 dumpsga
-rwxr-x--x  1 oracle oinstall     35328 Aug 18 05:58 cursize
-rwxr-x--x  1 oracle oinstall    236040 Aug 18 05:58 agtctl
-rwxr-x--x  1 oracle oinstall    151592 Aug 18 05:58 sbttest
-rwxr-x--x  1 oracle oinstall    222736 Aug 18 05:58 hsots
-rwxr-x--x  1 oracle oinstall    223176 Aug 18 05:58 hsdepxa
-rwxr-x--x  1 oracle oinstall    344024 Aug 18 05:58 hsalloci
-rwxr-x--x  1 oracle oinstall    106952 Aug 18 05:58 nid
-rwxr-x---  1 oracle oinstall   2343608 Aug 18 05:58 jssu
-rwx------  1 oracle oinstall   3117696 Aug 18 05:58 extjobo
-rwxr-x---  1 oracle oinstall   3117696 Aug 18 05:58 extjob
-rwxr-x--x  1 oracle oinstall    169744 Aug 18 05:58 kfod.bin
-rwxr-x--x  1 oracle oinstall    188192 Aug 18 05:58 amdu
-rwxr-x--x  1 oracle oinstall    232824 Aug 18 05:58 renamedg
-rwxr-x--x  1 oracle oinstall     71000 Aug 18 05:58 mkpatch
-rwxr-x--x  1 oracle oinstall    156616 Aug 18 05:58 kfed
-rwxr-x--x  1 oracle oinstall   4334888 Aug 18 05:58 setasmgid
-rwxr-xr-x  1 oracle oinstall     36824 Aug 18 05:58 osdbagrp
-rwxr-x--x  1 oracle oinstall     36032 Aug 18 05:58 skgxpinfo
-rwxr-x--x  1 oracle oinstall     56952 Aug 18 05:58 osegtab
-rwxr-x--x  1 oracle oinstall   8602632 Aug 18 05:58 orion
-rwxr-x--x  1 oracle oinstall     66864 Aug 18 05:58 oputil
-rwxr-x--x  1 oracle oinstall     46504 Aug 18 05:58 tnsping
-rwxr-xr-x  1 oracle oinstall     29448 Aug 18 05:58 sqlplus
-rwxr-x--x  1 oracle oinstall     30712 Aug 18 05:58 dbnestinit
-rwxr-xr-x  1 oracle oinstall   1040488 Aug 18 05:58 ldapcompare
-rwxr-xr-x  1 oracle oinstall   1140616 Aug 18 05:58 ldapadd
-rwxr-xr-x  1 oracle oinstall   1073096 Aug 18 05:58 ldapsearch
-rwxr-xr-x  1 oracle oinstall   1158808 Aug 18 05:58 ldapmodifymt
-rwxr-xr-x  1 oracle oinstall   1140616 Aug 18 05:58 ldapmodify
-rwxr-xr-x  1 oracle oinstall   1040392 Aug 18 05:58 ldapmoddn
-rwxr-xr-x  1 oracle oinstall   1040728 Aug 18 05:58 ldapdelete
-rwxr-xr-x  1 oracle oinstall   1158808 Aug 18 05:58 ldapaddmt
-rwxr-xr-x  1 oracle oinstall    100784 Aug 18 05:58 oklist
-rwxr-x--x  1 oracle oinstall    508032 Aug 18 05:58 imp
-rwxr-x--x  1 oracle oinstall   1019512 Aug 18 05:58 exp
-rwxr-xr-x  1 oracle oinstall   1118968 Aug 18 05:58 dsml2ldif
-rwxr-x--x  1 oracle oinstall    137136 Aug 18 05:58 tkprof
-rwxr-x--x  1 oracle oinstall   1684976 Aug 18 05:58 sqlldr
-rwxr-x--x  1 oracle oinstall    154160 Aug 18 05:58 plshprof
-rwxr-x--x  1 oracle oinstall     78320 Aug 18 05:58 kgmgr
-rwxr-x--x  1 oracle oinstall     45232 Aug 18 05:58 loadpsp
-rwxr-x--x  1 oracle oinstall    250104 Aug 18 05:58 impdp
-rwxr-x--x  1 oracle oinstall    238104 Aug 18 05:58 expdp
-rwxr-x--x  1 oracle oinstall   1135144 Aug 18 05:58 dgmgrl
-rwxr-x--x  1 oracle oinstall     49320 Aug 18 05:58 dg4pwd
-rwxr-x--x  1 oracle oinstall    836152 Aug 18 05:58 wrc
-rwxr-x--x  1 oracle oinstall    240280 Aug 18 05:58 uidrvci
-rwxr-x--x  1 oracle oinstall     41752 Aug 18 05:58 sysresv
-rwxr-x--x  1 oracle oinstall    208656 Aug 18 05:58 extproc
-rwxr-x--x  1 oracle oinstall     46496 Aug 18 05:58 adrci
-rwxr-x--x  1 oracle oinstall   1174472 Aug 18 05:58 tnslsnr
-rwxr-xr-x  1 oracle oinstall     90872 Aug 18 05:58 okinit
-rwxr-xr-x  1 oracle oinstall     89640 Aug 18 05:58 okdstry
-rwxr-x--x  1 oracle oinstall    274416 Aug 18 05:58 gwsadv
-rwxr-x--x  1 oracle oinstall     39888 Aug 18 05:58 amt2amb
-rwxr-x--x  1 oracle oinstall     56016 Aug 18 05:58 trcroute
-rwxr-x--x  1 oracle oinstall  13867264 Aug 18 05:58 rman
-rwxr-x--x  1 oracle oinstall    190896 Aug 18 05:58 lsnrctl
-rwxr-xr-x  1 oracle oinstall     20143 Aug 18 05:59 onsctl
-rwxr-x---  1 oracle oinstall      4404 Aug 18 05:59 mgmtua
-rwxr-x---  1 oracle oinstall      4799 Aug 18 05:59 mgmtca
-rwxr-xr-x  1 oracle oinstall   1040400 Aug 18 05:59 ldapbind
-rwxr-x---  1 oracle oinstall      5783 Aug 18 05:59 emca
-rwxr-x---  1 oracle oinstall      9519 Aug 18 05:59 dbca
-rwxr-x--x  1 oracle oinstall 498742528 Aug 18 05:59 oracle
lrwxrwxrwx  1 oracle oinstall        24 Dec  5 13:41 lbuilder -> ../nls/lbuilder/lbuilder
drwxr-xr-x  2 oracle oinstall      4096 Dec  5 13:41 .
drwxrwxr-x 61 oracle oinstall      4096 Dec  5 13:44 ..
AMIS end list of files and directories
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:
*******
[FATAL] [DBT-10011] Incorrect ownership/permissions detected for the file (/opt/oracle/product/21c/dbhomeXE/bin/oradism).
   CAUSE: Following nodes does not have required file ownership/permissions: Node :52ea8abd4b07
PRVG-11960 : Set user ID bit is not set for file "/opt/oracle/product/21c/dbhomeXE/bin/oradism" on node "52ea8abd4b07".
PRVG-2031 : Owner of file "/opt/oracle/product/21c/dbhomeXE/bin/oradism" did not match the expected value on node "52ea8abd4b07". [Expected = "root(0)" ; Found = "oracle(54321)"]

   ACTION: Run the Oracle Home root script as the "root" user to fix the permissions.

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/21c/dbhomeXE/dbs/spfileXE.ora': No such file or directory
mv: cannot stat '/opt/oracle/product/21c/dbhomeXE/dbs/orapwXE': No such file or directory
mv: cannot move '/opt/oracle/product/21c/dbhomeXE/network/admin/listener.ora' to '/opt/oracle/oradata/dbconfig/XE/': No such file or directory
mv: cannot move '/opt/oracle/product/21c/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
cp: cannot stat '/opt/oracle/oradata/dbconfig/XE/oratab': No such file or directory
ORACLE_HOME = [/home/oracle] ? ORACLE_BASE environment variable is not being set since this
information is not available for the current user ID .
You can set ORACLE_BASE manually if it is required.
Resetting ORACLE_BASE to its previous value or ORACLE_HOME
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:
tail: cannot open '/opt/oracle/diag/rdbms/*/*/trace/alert*.log' for reading: No such file or directory
tail: no files remaining
vagrant@ubuntu-focal:/vagrant/oraclexedatabase/dockerfiles$

If we focus on the following line from the output, this confirms what the error message was telling us, and it’s also similar to our findings with version 18.4.0 (see my previous article):

-rwxr-x---  1 oracle oinstall   1867560 Aug 17 22:44 oradism

So, what we see here is that the file /opt/oracle/product/21c/dbhomeXE/bin/oradism is owned by oracle and belongs to group oinstall.

To fix the error problem about the owner of the file, I changed the content of file Dockerfile.xe (only showing the RUN part):
[in bold, I highlighted the changes]

…
RUN chmod ug+x $INSTALL_DIR/*.sh && \
    sync && \
    $INSTALL_DIR/$CHECK_SPACE_FILE && \
    cd $INSTALL_DIR && \
    yum -y install openssl oracle-database-preinstall-21c && \
    sed -i -e 's/\(oracle\s\+hard\s\+nofile\)/# \1/' /etc/security/limits.d/oracle-database-preinstall-21c.conf && \
    yum -y localinstall $INSTALL_FILE_1 && \
    rm -rf /var/cache/yum && \
    rm -rf /var/tmp/yum-* && \
    mkdir -p $ORACLE_BASE/scripts/setup && \
    mkdir $ORACLE_BASE/scripts/startup && \
    ln -s $ORACLE_BASE/scripts /docker-entrypoint-initdb.d && \
    mkdir -p $ORACLE_BASE/oradata /home/oracle && \
    chown -R oracle:oinstall $ORACLE_BASE /home/oracle && \
    chown -R root:oinstall $ORACLE_HOME/bin/oradism && \
    mv $INSTALL_DIR/$RUN_FILE $ORACLE_BASE/ && \
    mv $INSTALL_DIR/$PWD_FILE $ORACLE_BASE/ && \
    mv $INSTALL_DIR/$CHECK_DB_FILE $ORACLE_BASE/ && \
    mv $INSTALL_DIR/$CONF_FILE /etc/sysconfig/ && \
    ln -s $ORACLE_BASE/$PWD_FILE / && \
    cd $HOME && \
    rm -rf $INSTALL_DIR && \
    chmod ug+x $ORACLE_BASE/*.sh
…

Again, I wanted to start from scratch. So, I used vagrant destroy and vagrant up and created the docker image, and then used the docker run command as I did before.

With the following output:

AMIS begin list of files and directories
total 810808
-rwxr-xr-x  1 oracle oinstall       153 Nov  7  1997 echodo
…
-rwxr-x---  1 oracle oinstall    203400 Aug 17 22:44 oradnfs
-rwxr-x---  1 root   oinstall   1867560 Aug 17 22:44 oradism
-rwxr-x---  1 oracle oinstall   1858568 Aug 17 22:44 orabasehome
…
AMIS end list of files and directories
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:
**********
[FATAL] [DBT-10011] Incorrect ownership/permissions detected for the file (/opt/oracle/product/21c/dbhomeXE/bin/oradism).
   CAUSE: Following nodes does not have required file ownership/permissions: Node :a0d06541a104
PRVG-11960 : Set user ID bit is not set for file "/opt/oracle/product/21c/dbhomeXE/bin/oradism" on node "a0d06541a104".

   ACTION: Run the Oracle Home root script as the "root" user to fix the permissions.

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/21c/dbhomeXE/dbs/spfileXE.ora': No such file or directory
mv: cannot stat '/opt/oracle/product/21c/dbhomeXE/dbs/orapwXE': No such file or directory
mv: cannot move '/opt/oracle/product/21c/dbhomeXE/network/admin/listener.ora' to '/opt/oracle/oradata/dbconfig/XE/': No such file or directory
mv: cannot move '/opt/oracle/product/21c/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
cp: cannot stat '/opt/oracle/oradata/dbconfig/XE/oratab': No such file or directory
ORACLE_HOME = [/home/oracle] ? ORACLE_BASE environment variable is not being set since this
information is not available for the current user ID .
You can set ORACLE_BASE manually if it is required.
Resetting ORACLE_BASE to its previous value or ORACLE_HOME
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:
tail: cannot open '/opt/oracle/diag/rdbms/*/*/trace/alert*.log' for reading: No such file or directory
tail: no files remaining
vagrant@ubuntu-focal:/vagrant/oraclexedatabase/dockerfiles$

So, I still got an error, but a little bit different this time!

The difference being that I lost the PRVG-02031 error from the original error message:

[FATAL] [DBT-10011] Incorrect ownership/permissions detected for the file (/opt/oracle/product/21c/dbhomeXE/bin/oradism).
   CAUSE: Following nodes does not have required file ownership/permissions: Node :52ea8abd4b07
PRVG-11960 : Set user ID bit is not set for file "/opt/oracle/product/21c/dbhomeXE/bin/oradism" on node "52ea8abd4b07".
PRVG-2031 : Owner of file "/opt/oracle/product/21c/dbhomeXE/bin/oradism" did not match the expected value on node "52ea8abd4b07". [Expected = "root(0)" ; Found = "oracle(54321)"]

PRVG-02031: Owner of file “{0}” did not match the expected value on node “{1}”. [Expected = “{2}” ; Found = “{3}”]
Cause: A check for file system attributes found that the owner of the indicated file on the indicated node was different from the required owner.
[https://docs.oracle.com/en/database/oracle/oracle-database/21/errmg/PRVG-00100.html#GUID-B55636B3-8CFB-4AC1-AB4F-8D08F862629C]

So, the error about the owner not being right is gone.

I had another look at the remaining error and found an action to be taken.

PRVG-11960: Set user ID bit is not set for file “{0}” on node “{1}”.
Cause: The set user ID bit was not set for the identified file on the indicated node.

Action: Log in as the root user and set the set user ID bit for the identified file using command ‘chmod +s file’.
[https://docs.oracle.com/en/database/oracle/oracle-database/21/errmg/PRVG-00100.html#GUID-B55636B3-8CFB-4AC1-AB4F-8D08F862629C]

To fix the error problem about the user ID bit for the file, again I changed the content of file Dockerfile.xe (only showing the RUN part):
[in bold, I highlighted the changes]

RUN chmod ug+x $INSTALL_DIR/*.sh && \
    sync && \
    $INSTALL_DIR/$CHECK_SPACE_FILE && \
    cd $INSTALL_DIR && \
    yum -y install openssl oracle-database-preinstall-21c && \
    sed -i -e 's/\(oracle\s\+hard\s\+nofile\)/# \1/' /etc/security/limits.d/oracle-database-preinstall-21c.conf && \
    yum -y localinstall $INSTALL_FILE_1 && \
    rm -rf /var/cache/yum && \
    rm -rf /var/tmp/yum-* && \
    mkdir -p $ORACLE_BASE/scripts/setup && \
    mkdir $ORACLE_BASE/scripts/startup && \
    ln -s $ORACLE_BASE/scripts /docker-entrypoint-initdb.d && \
    mkdir -p $ORACLE_BASE/oradata /home/oracle && \
    chown -R oracle:oinstall $ORACLE_BASE /home/oracle && \
    chown -R root:oinstall $ORACLE_HOME/bin/oradism && \
    chmod u+s $ORACLE_HOME/bin/oradism && \
    mv $INSTALL_DIR/$RUN_FILE $ORACLE_BASE/ && \
    mv $INSTALL_DIR/$PWD_FILE $ORACLE_BASE/ && \
    mv $INSTALL_DIR/$CHECK_DB_FILE $ORACLE_BASE/ && \
    mv $INSTALL_DIR/$CONF_FILE /etc/sysconfig/ && \
    ln -s $ORACLE_BASE/$PWD_FILE / && \
    cd $HOME && \
    rm -rf $INSTALL_DIR && \
    chmod ug+x $ORACLE_BASE/*.sh

Then, I used vagrant destroy and vagrant up and created the docker image, and then used the docker run command.

With the following output:

AMIS begin list of files and directories
total 810808
-rwxr-xr-x  1 oracle oinstall       153 Nov  7  1997 echodo
…
-rwxr-x---  1 oracle oinstall    203400 Aug 17 22:44 oradnfs
-rwsr-x---  1 root   oinstall   1867560 Aug 17 22:44 oradism
-rwxr-x---  1 oracle oinstall   1858568 Aug 17 22:44 orabasehome
…
AMIS end list of files and directories
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
100% complete
[FATAL] Prepare Operation has failed.
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/21c/dbhomeXE/dbs/spfileXE.ora': No such file or directory
mv: cannot stat '/opt/oracle/product/21c/dbhomeXE/dbs/orapwXE': No such file or directory
mv: cannot move '/opt/oracle/product/21c/dbhomeXE/network/admin/listener.ora' to '/opt/oracle/oradata/dbconfig/XE/': No such file or directory
mv: cannot move '/opt/oracle/product/21c/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
cp: cannot stat '/opt/oracle/oradata/dbconfig/XE/oratab': No such file or directory
ORACLE_HOME = [/home/oracle] ? ORACLE_BASE environment variable is not being set since this
information is not available for the current user ID .
You can set ORACLE_BASE manually if it is required.
Resetting ORACLE_BASE to its previous value or ORACLE_HOME
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:
tail: cannot open '/opt/oracle/diag/rdbms/*/*/trace/alert*.log' for reading: No such file or directory
tail: no files remaining
vagrant@ubuntu-focal:/vagrant/oraclexedatabase/dockerfiles$

So, this time, the error message I got, was the same one I got with version 18.4.0.
I fixed it in the same way I described in my pervious article, by changing the permissions of directory /opt/oracle/oradata and recreating the container.
[Oracle Database 21c XE, setting up a demo environment using Vagrant and Oracle VirtualBox (part 1)]

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
33% complete
37% complete
40% 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: 2274c30e49f2/XEPDB1
     Multitenant container database: 2274c30e49f2
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
mv: cannot stat '/opt/oracle/product/21c/dbhomeXE/dbs/spfileXE.ora': No such file or directory
mv: cannot stat '/opt/oracle/product/21c/dbhomeXE/dbs/orapwXE': No such file or directory
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:
Pluggable database XEPDB1 opened read write
Completed: alter pluggable database "XEPDB1" open
2021-12-06T18:11:19.942563+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-12-06T18:11:21.399606+00:00
ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
Completed: ALTER PLUGGABLE DATABASE XEPDB1 SAVE STATE
^Cvagrant@ubuntu-focal:/opt/oracle/oradata$

And after a restart of the container, 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
2274c30e49f2   oracle/database:21.0.0-xe   "/bin/sh -c 'exec $O…"   15 minutes ago      Up 5 minutes (healthy)         0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:5500->5500/tcp, :::5500->5500/tcp   oracle_database_21.0.0-xe
131c7c17a07c   hello-world                 "/hello"                 About an hour ago   Exited (0) About an hour ago  

Running SQL*Plus

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

I opted for running SQL*Plus in a container.

docker exec -ti oracle_database_21.0.0-xe sqlplus system/manager@//localhost:1521/XE

With the following output:

SQL*Plus: Release 21.0.0.0.0 - Production on Mon Dec 6 18:21:09 2021
Version 21.3.0.0.0

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

Last Successful login time: Mon Dec 06 2021 18:08:51 +00:00

Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL>

I issued the following SQL command:

SQL> select count(*) from user_tables;

With the following output:

  COUNT(*)
----------
       134

Next, I used exit to close SQL*Plus.

With the following output:

Disconnected from Oracle Database 21c Express Edition Release 21.0.0.0.0 – Production
Version 21.3.0.0.0

So, the database (apparently it was version 21.3.0) was working and I could use SQL statements. Great!

With exit I closed the ssh Windows Command Prompt.

Alternative Oracle Database 21c Express Edition (XE) docker image

Of course, now I am working with a 21c docker image, that I more or less derived from an 18.4.0 docker image. Let’s hope it’s functioning as expected. If I run into a problem later on when I am working with Kafka, maybe I have to change it.

As I already did some research on the internet, it’s good to know that there is an alternative, I would like to share with you.

As I mentioned at the beginning of this series of articles, at the time I wrote the first one, the general availability of Oracle Database 21c Express Edition (XE) on Linux was announced by Gerald Venzl, who is a Developer Evangelist and Distinguished Product Manager for Oracle.
[https://blogs.oracle.com/database/post/oracle-database-21c-xe-generally-available]

He also added Oracle Database Express Edition Container / Docker images for version 21c.
[https://hub.docker.com/r/gvenzl/oracle-xe]

So, that’s an alternative to use as docker image.

Another alternative Oracle Database 21c Express Edition (XE) docker image

Sometime, when you are writing a blog article, at the time the article is about to be published, the things you used and are writing about get changed during that time. This is what happened to me.

So, have a look at the README.md, I mentioned several times in this series of articles.
[https://github.com/oracle/docker-images/blob/main/OracleDatabase/SingleInstance/README.md]

The README.md changed and now there is also support for 21c XE.

Including the docker files for Oracle Database 21c (21.3.0) Enterprise Edition, Standard Edition 2 and Express Edition (XE).

I wished these files were available when I started writing this series of articles, but in the end, it’s great news for everybody.

And of course, later on I will have a look at it. But first I have to finish and publish this article 😊.

Interact with the Oracle Database 21c Express Edition (XE) from my Windows laptop

Remember to create the container, I used the following command on the Linux Command Prompt:

sudo docker run --name oracle_database_21.0.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:21.0.0-xe

Remember the port parameter, I also described in a previous article:

-p:The port mapping of the host port to the container port.
Two ports are exposed: 1521 (Oracle Listener), 5500 (EM Express)

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

Because I wanted to use an IDE on my Windows laptop to connect to the database, I used the forwarded_port configuration option, to forward port 1521 on my host (Windows) to port 1521 on my guest (Ubuntu). I did the same for port 5500.

Vagrant forwarded ports allow you to access a port on your host machine and have all data forwarded to a port on the guest machine, over either TCP or UDP.
[https://www.vagrantup.com/docs/networking/forwarded_ports.html]

I changed the content of the Vagrantfile:
[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.network "forwarded_port",
      guest: 1521,
      host:  1521,
      auto_correct: true
      
   config.vm.network "forwarded_port",
      guest: 5500,
      host:  5500,
      auto_correct: true
      
    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

From the subdirectory named env on my Windows laptop, I navigated to the scripts directory were I created a file oracle-database-xe-21c.sh with the following content:

#!/bin/bash
echo "**** Begin installing oracle-database-xe-21c"

#Install
#https://docs.oracle.com/en/database/oracle/oracle-database/21/xeinl/installing-oracle-database-xe.html

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

sudo mkdir -p /opt/oracle/oradata
sudo chmod -R o+w /opt/oracle/oradata

docker run --name oracle_database_21.0.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:21.0.0-xe

echo "**** End installing oracle-database-xe-21c"

Again, I changed the content of the Vagrantfile to use the just created script file:
[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.network "forwarded_port",
      guest: 1521,
      host:  1521,
      auto_correct: true
      
   config.vm.network "forwarded_port",
      guest: 5500,
      host:  5500,
      auto_correct: true
      
    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
          
      args = []
      config.vm.provision "oracle-database-xe-21c shell script", type: "shell",
          path: "scripts/oracle-database-xe-21c.sh",
          args: args
          
    end
    
  end

end

Next in file runOracle.sh, I remarked the lines of code, I added earlier to get a list of files and directories (for /opt/oracle/product/21c/dbhomeXE/bin), because I no longer needed that information:

…
############# MAIN ################

# Set SIGTERM handler
trap _term SIGTERM
#echo "AMIS begin list of files and directories"
#su -p oracle -c "ls -latr /opt/oracle/product/21c/dbhomeXE/bin"
#echo "AMIS end list of files and directories"

In order to test this new set up, I used vagrant destroy and vagrant up.
and created the docker image, and then used the docker run command as I did before.

I checked the created Oracle Database 21c Express Edition (XE) docker container by using IntelliJ IDEA Community Edition and the Database Navigator on my Windows laptop.

IntelliJ IDEA Community Edition and the Database Navigator

I downloaded the latest IntelliJ IDEA Community Edition version (at the time I wrote this article) and installed it on my Windows laptop:

Version: 2021.3
Build: 213.5744.223
30 November 2021
[https://www.jetbrains.com/idea/download/#section=windows]

Then I updated the Database Navigator plugin (Database development, scripting and navigation tool).

This product adds extensive database development and maintenance capabilities to the IntelliJ IDEA development environment and related products. Along with a qualified and IDE-compliant SQL and PL/SQL editor, it provides advanced database connection management, script execution support, database objects browsing, data and code editor, support for database compiler operations, method execution and debugging, database objects factory, as well as various navigation capabilities between all its components.
See features overview on the support page.

Supported Databases:

  • Oracle
  • MySQL
  • SQLite
  • PostgreSQL
  • Any JDBC compliant database (EXPERIMENTAL)

[https://plugins.jetbrains.com/plugin/1800-database-navigator]

Next, In IntelliJ IDEA, I created an Empty Project called “databases”.

In the menu I choose DB Navigator | Database Browser. And I clicked on the New Connection icon, and next Oracle.

In de Settings pop-up I filled in the connection settings and named the connection “OracleXE_system_Connection”.

I clicked on the Apply button and OK button.

Next, I navigated to Schemas | SYSTEM.

And as you can see, the number of tables for this user is 134, the same as the counting result when I used SQL*Plus as I described before.

In a next article, I continue with taking you with me on my path to set up my demo environment with Apache Kafka (an open-source distributed event streaming platform) and Oracle Database 21c Express Edition (XE).

Leave a Reply

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

Next Post

Getting started (again) with Kubernetes on Oracle Cloud

For many of my recent activities, I have not worked with or even on (knowingly at least) Kubernetes. So for many months I have not touched my OKE cluster on Oracle Cloud. However, in the last weeks, I have run into so many interesting things to dive into – that […]
%d bloggers like this: