Quick and Easy Installation of Oracle Database on Oracle Linux in Oracle VM VirtualBox

April 27, 2022 | 3 minute read
Text Size 100%:

In a previous blog post, I described the steps to streamline the pre-installation steps on Oracle Linux for Oracle Database 12c using the Database preinstallation package. In this post you will learn how to perform a fully automated installation of Oracle Database 21c on Oracle Linux running in an Oracle VM VirtualBox guest. The tutorial is based on a Vagrantfile published in our Vagrant Projects repo on GitHub and installs Oracle Database 21c Express Edition. 
 
Because this installation method uses Oracle VM VirtualBox, Vagrant and an Oracle Linux Vagrant box, the whole process can be automated, requiring minimal to no input. Assuming you have VirtualBox, Vagrant and git installed, these are the steps to install Oracle Database:

  • Clone the relevant GitHub repository
  • Download the Oracle Database 21c installation media
  • Issue a Vagrant command to create the VM and start the Database installation process
  • Wait 15-25 minutes, depending on your network bandwidth and machine horsepower

After this, the database is up and running and ready to use. The commands are straightforward:


git clone https://github.com/oracle/vagrant-projects
cd vagrant-projects/OracleDatabase/21.3.0-XE 
# Optional: download the Oracle Database installation file and place it in this directory
vagrant up 
    

How Does This Work?

The steps summarized earlier cause Vagrant to do the following:

  • read the Vagrantfile
  • create a headless VM based on the pre-packaged Oracle Linux 8 Vagrant box
  • provision the VM by runing a script which:
    • updates Oracle Linux to the latest available packages from Oracle Linux yum server
    • performs Database pre-installation checks and installs required packages
    • unzips the Database installion files,
    • installs the Oracle Database 12c software
    • creates a database and pluggable database container

 
After the installation has completed, you can either log in to the guest VM itself and interact with the Database there or, you can leave the VM running —headless— and connect from the host operating system to the Database using tools such as SQL Developer. Be sure to make a note of the generated password at the end of the Vagrant installation.

Connecting to Oracle database by logging in to the VM

To log in to the VM and interact with the database from the command line:

  • ssh into the VM
  • switch to the oracle OS user
  • use sqlplus to connect to the PDBADMIN database user

The command are:


vagrant ssh
sudo su - oracle
sqlplus pdbadmin/"<PASSWORD GOES HERE>"@xepdb1

Connecting to Oracle database using SQL Developer

  • Download and install SQL Developer
  • Create a connection using the following settings:
    • Authentication Type: Default
    • Username: pdbadmin
    • Password: <password provided by the Vagrant installation output>
    • Connection Type: Basic
    • Hostname: localhost
    • Port: 1521
    • Service name: xepdb1

Conclusion

In this post I explained how to perform an automated installation of Oracle Database 21c Express Edition in a virtual machine and connect to it. If your goal is to set up an Oracle database on your local development machine as quickly as possible while keeping it self contained, the method outlined here is a fantastic option.

References

Sergio Leunissen


Previous Post

Fixing QEMU Memory Leaks with Valgrind

Mark Kanda | 6 min read

Next Post


Pstore, The Linux Kernel Persistent Storage File System

Eric DeVolder | 6 min read