DEV Community

Cover image for 
5 Steps to use Oracle Database with Vagrant
Andrew Pazikas
Andrew Pazikas

Posted on • Originally published at pazikas.com

5 Steps to use Oracle Database with Vagrant

I’ve written about my love for Vagrant a few times already here, today I will show the steps to getting an Oracle Database with Vagrant.

Why I Love Vagrant

It is just so simple, I recall the days when I used to have to package up my own VM’s for re-use it wasn’t difficult but it was a time sink at the end of the day, Vagrant has a pretty good level of adoption with most of the big Tech software corps producing some sort of Vagrant box or support making is super easy to spin up Virtual Machines with the software you need.

I also really like how Vargant is file-based, editing the Vagrantfile is really simple meaning you can add additional custom tools to a virtual host as you please making Vagrant ideal for use a lab environment as you can very easily create a Vagrantfile that mimics your production infrastructure giving you a like for like testbed.

Oracle Database with Vagrant

Thankfully once again on Oracle’s GitHub, they provide a bunch of different Vagrant Images for your use here. Personally, I have used OracleDatabase, OracleLinux, and OracleRAC images.

Get Oracle Database Vagrant Files

Let's pull the Oracle Vagrant file repo down to our own machines;

PS D:\Vagrant> git clone https://github.com/oracle/vagrant-projects.git
Cloning into 'vagrant-projects'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 2509 (delta 3), reused 5 (delta 0), pack-reused 2491
Receiving objects: 100% (2509/2509), 1.12 MiB | 2.42 MiB/s, done.
Resolving deltas: 100% (1508/1508), done.
Change to Database Directory

As you see when pulling the repo down from GitHub Oracle have a bunch of different software application available for you to start. In the article, we’re showing Oracle Database with Vagrant but the steps are applicable to all applications.

Move into the 19.3 directories. For this post, we will use 19.3 but from the screen below you see 11g, 12c, 18 & 19 are available.

PS D:\Vagrant\vagrant-projects\OracleDatabase> ls

Move Oracle Database .zip Files

Once we are in the directory we need to place the Oracle 19c database installation .zip files here so that our Vargant VM can pick them up and install an Oracle Database for us.

PS D:\Vagrant\vagrant-projects\OracleDatabase\19.3.0> ls

Start Oracle Database with Vagrant

Next, it’s as simple as typing Vagrant up command, which will then go away and build you an Oracle Database Virtual machine running on Oracle Linux 7. It takes a little bit of time as it installs the database so it’s worth going to make a coffee on my host it took 30 minutes to get a working VM. If you’re starting the VM again it will be much faster, the initial start is the only one that takes the time.

PS D:\Vagrant\vagrant-projects\OracleDatabase\19.3.0> vagrant up
...
...
...
oracle-19c-vagrant: ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: 5UPTEi9mXjA=1
oracle-19c-vagrant: INSTALLER: Installation complete, database ready to use!

Log in to Oracle Database

Head onto your Virtual Machine using vagrant ssh and check the database;

PS D:\Vagrant\vagrant-projects\OracleDatabase\19.3.0> vagrant ssh

Welcome to Oracle Linux Server release 7.9 (GNU/Linux 5.4.17-2011.6.2.el7uek.x86_64)

The Oracle Linux End-User License Agreement can be viewed here:

* /usr/share/eula/eula.en_US

For additional packages, updates, documentation and community help, see:

* https://yum.oracle.com/

[vagrant@oracle-19c-vagrant ~]$ sudo su - oracle
Last login: Sun Feb 21 14:22:42 GMT 2021
[oracle@oracle-19c-vagrant ~]$ ps -ef |grep -i listener
oracle 8263 1 0 14:06 ? 00:00:00 /opt/oracle
/product/19c/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle 12907 12883 0 14:26 pts/0 00:00:00 grep --color=auto -i listener
[oracle@oracle-19c-vagrant ~]$ ps -ef |grep -i pmon
oracle 12294 1 0 14:22 ? 00:00:00 ora_pmon_ORCLCDB
oracle 12914 12883 0 14:26 pts/0 00:00:00 grep --color=auto -i pmon
[oracle@oracle-19c-vagrant ~]$ . oraenv
ORACLE_SID = [ORCLCDB] ?
The Oracle base remains unchanged with value /opt/oracle
[oracle@oracle-19c-vagrant ~]$ cat /etc/oratab
ORCLCDB:/opt/oracle/product/19c/dbhome_1:Y
[oracle@oracle-19c-vagrant ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sun Feb 21 14:26:47 2021
Version 19.3.0.0.0

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

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> select version from v$instance;

VERSION
-----------------
19.0.0.0.0

Now we have a 19.3 Oracle database running on Oracle Linux 7 for your use in a lab or at home for any testing or checking you want to perform.

Conclusion

From the steps above you can hopefully see how simple Vagrant can be, if you have any questions or get stuck please get in touch and I can help you through your issues.

Top comments (0)