Pretty Vagrant – the easiest way to get Oracle XE21c running on Ubuntu

 4 months ago
source link: https://mikesmithers.wordpress.com/2022/05/08/pretty-vagrant-the-easiest-way-to-get-oracle-xe21c-running-on-ubuntu/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Pretty Vagrant – the easiest way to get Oracle XE21c running on Ubuntu

Posted on May 8, 2022

It’s been a few months now since the latest version of Oracle’s excellent ( and free) Express Edition (XE) database was released and it’s about time I got it installed and running so I can have a play.

Fortunately, due to a bit of DevOps sorcery called Vagrant, getting my hands on Gerald Venzl’s latest effort is easier than ever.

What I’m going to cover here is :

  • an overview of the tools we need
  • installing Vagrant on Ubuntu
  • cloning the Oracle vagrant-projects Github Repo
  • installing Oracle 21c XE using Vagrant
  • some useful vagrant commands

Environment and tools

As always, when we’re discussing Virtual Environments, the terms “Host” and “Guest” are going to feature. To be clear, the Host is my laptop (running Ubuntu 20.04.4 LTS).
The Guest will be the VM we get Vagrant to create.

The tools we need on the Host are :

  • Vagrant
  • VirtualBox
  • Git (optional but is useful for cloning from Github)

In terms of system requirements, the Guest machine we’re creating is configured to use 2GB RAM and around 40GB disk.

How Vagrant and VirtualBox work together

Vagrant runs a Provisioner – e.g. a Chef recipe or – in this case – some bash scripts – to create a virtual environment. It uses a Provider ( in this case VirtualBox) to act as the Hypervisor for the VM.
The code to configure a specific environment are referred to as a Box.
Note that we don’t need to tweak the VirtualBox configuration in any way. It will simply run when it’s required by Vagrant.


There are a couple of ways to check whether you already have this installed.

You can open a Terminal and run :

which virtualbox

… which will return the path of the VirtualBox executable, if found.

Alternatively, you can search for it in Applications on the desktop.
If it’s not there, you can get it by heading over to the VirtualBox site and following the installation instructions.

To establish the version of VirtualBox you currently have, open the VirtualBox Manager on the Desktop and open Help/About.


To determine if you have Git installed, you can try this on the command line :

git --version

…which, in my case, returns :

git version 2.25.1

NOTE – you don’t actually need Git to get your hands on the files in the repo, and we’ll look at an alternative way to do this shortly.

For now, however, I’ve reached the point where I need to …

Install Vagrant

Vagrant is packaged in the Ubuntu repos so installation is fairly straight-forward :

curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install vagrant

Once the installation is completed, you can check that everything has worked as expected by running :

vagrant -v

…which, in my case returns…

Vagrant 2.2.19

Cloning the Oracle vagrant-projects Repository

The Oracle Vagrant Project repository resides on Github.

If you have Git installed, you can simply open a Terminal, change to the directory you want to download into and run :

git clone https://github.com/oracle/vagrant-projects

This should produce output similar to :

Cloning into 'vagrant-projects'...
remote: Enumerating objects: 2844, done.
remote: Counting objects: 100% (276/276), done.
remote: Compressing objects: 100% (140/140), done.
remote: Total 2844 (delta 138), reused 237 (delta 121), pack-reused 2568
Receiving objects: 100% (2844/2844), 1.24 MiB | 9.97 MiB/s, done.
Resolving deltas: 100% (1684/1684), done.

If you don’t have Git installed, you can get the files from the repository page by clicking on the Code button and selecting Download ZIP :


Once you’ve downloaded the zip file, you can then extract it to your desired directory.

Either way, you should now have a directory called vagrant-projects, which contains all of the files in from the repository.

Installing Oracle XE21c

That heading is slightly misleading. What we’re actually doing is getting Vagrant to is to create a Virtual Machine, install Oracle Linux 8.5 and then install the XE Database.

To perform this complex software configuration I’ll need to go to the directory that holds the Vagrant configuration I want to deploy…

cd vagrant-projects/OracleDatabase/21.3.0-XE


vagrant up

… and find something to do for a while.

This is because, the first time you start the VM, Vagrant will perform the steps listed above. Depending on the available system resources and speed of your internet connection, this might take a while.

Eventually, you should see some output similar to :

    oracle21c-xe-vagrant:  /opt/oracle/cfgtoollogs/dbca/XE.
    oracle21c-xe-vagrant: Database Information:
    oracle21c-xe-vagrant: Global Database Name:XE
    oracle21c-xe-vagrant: System Identifier(SID):XE
    oracle21c-xe-vagrant: Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.
    oracle21c-xe-vagrant: Connect to Oracle Database using one of the connect strings:
    oracle21c-xe-vagrant:      Pluggable database: localhost.localdomain/XEPDB1
    oracle21c-xe-vagrant:      Multitenant container database: localhost.localdomain
    oracle21c-xe-vagrant: Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
    oracle21c-xe-vagrant: INSTALLER: Database created
    oracle21c-xe-vagrant: SQL*Plus: Release - Production on Fri May 6 12:11:28 2022
    oracle21c-xe-vagrant: Version
    oracle21c-xe-vagrant: Copyright (c) 1982, 2021, Oracle.  All rights reserved.
    oracle21c-xe-vagrant: Connected to:
    oracle21c-xe-vagrant: Oracle Database 21c Express Edition Release - Production
    oracle21c-xe-vagrant: Version
    oracle21c-xe-vagrant: SQL>
    oracle21c-xe-vagrant: PL/SQL procedure successfully completed.
    oracle21c-xe-vagrant: SQL> Disconnected from Oracle Database 21c Express Edition Release - Production
    oracle21c-xe-vagrant: Version
    oracle21c-xe-vagrant: INSTALLER: Global EM Express port enabled
    oracle21c-xe-vagrant: oracle-xe-21c.service is not a native service, redirecting to systemd-sysv-install.
    oracle21c-xe-vagrant: Executing: /usr/lib/systemd/systemd-sysv-install enable oracle-xe-21c
    oracle21c-xe-vagrant: INSTALLER: Created and enabled oracle-xe-21c systemd's service
    oracle21c-xe-vagrant: INSTALLER: setPassword.sh file setup
    oracle21c-xe-vagrant: INSTALLER: Running user-defined post-setup scripts
    oracle21c-xe-vagrant: INSTALLER: Done running user-defined post-setup scripts
    oracle21c-xe-vagrant: ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: F0ulOl3Ron!
    oracle21c-xe-vagrant: INSTALLER: Installation complete, database ready to use!

OK, I made that password up. Then again, so will Vagrant as we’ve not specified anything different. Changing the password once the VM is up and running is fairly simple.

One of the things that whizzed up the screen during the installation was the creation of an ssh key to facilitate passwordless ssh connection to the Guest as a user called vagrant.

In the same directory that we performed the installation, we can connect to the guest as this admin user via ssh :

vagrant ssh

Once we’re connected we can switch to the oracle user and – if we so desire – change the password for SYS, SYSTEM and PDBADMIN. Note – issuing a sudo command as the vagrant user does not prompt for a password :

sudo su - oracle
. /home/oracle/setPassword.sh my_new_password

…where my_new_password is the password you want to set for these three accounts.

Connecting to the Database via TNS

The VM has been configured to use Port Forwarding for TNS ( port 1521).

This means that adding the following entries to your tnsnames.ora will allow you to connect to the Guest database from the relevant tools on the Host :

xe21_pdb =
(ADDRESS = (PROTOCOL = TCP) (HOST=localhost.localdomain) (PORT = 1521))
xe21_cdb =
(ADDRESS = (PROTOCOL = TCP) (HOST = localhost.localdomain) (PORT = 1521))

In this instance, xe21_cdb is the setting for the Container Database and xe21_pdb is the Pluggable Database.

Some Useful Vagrant Commands

You can get a listing of the vagrant commands available by running :

vagrant --help

To see the current status of any installed VMs :

vagrant global-status

…which gives me…


As you can see, if you want to run vagrant commands from a directory other than the “home” of the VM on the host, you can use the ID from this listing. The format of the command is :

vagrant <command> <id>

For example, if I want to shutdown my VM, I can run :

vagrant halt dca5f5e

To “reboot” :

vagrant reload dca5f5e

If I want to trash my VM altogether, then I can run :

vagrant destroy dca5f5e

Managing the VM from VirtualBox

If all of that is a bit too much typing for you, you can also use VirtualBox for some management tasks.

If you open the VirtualBox manager GUI, you should see the Vagrant VM listed :


Starting the VM seems to work fine, but shutting down seemed a little more problematic, so should probably be avoided.

There’s loads more to explore, no only in terms of Vagrant’s capabilities but also the mind-boggling array of content in the Oracle vagrant-project repo itself. There’s even a box for a two-node RAC cluster.

For now though, I’m just thankful to Gerald for installing XE21c for me 🙂


About Joyk

Aggregate valuable and interesting links.
Joyk means Joy of geeK