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
Lets 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
Directory: D:\Vagrant\vagrant-projects\OracleDatabase
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 21/02/2021 13:05 11.2.0.2
d----- 21/02/2021 13:05 12.1.0.2
d----- 21/02/2021 13:05 12.2.0.1
d----- 21/02/2021 13:05 18.3.0
d----- 21/02/2021 13:05 18.4.0-XE
d----- 21/02/2021 13:05 19.3.0
-a---- 21/02/2021 13:05 1416 README.md
PS D:\Vagrant\vagrant-projects\OracleDatabase> cd .\19.3.0\
PS D:\Vagrant\vagrant-projects\OracleDatabase\19.3.0> ls
Directory: D:\Vagrant\vagrant-projects\OracleDatabase\19.3.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 21/02/2021 13:05 ora-response
d----- 21/02/2021 13:05 scripts
d----- 21/02/2021 13:05 userscripts
-a---- 21/02/2021 13:05 1361 .env
-a---- 21/02/2021 13:05 18 .gitattributes
-a---- 21/02/2021 13:05 13 .gitignore
-a---- 21/02/2021 13:05 6512 README.md
-a---- 21/02/2021 13:05 5587 Vagrantfile
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
Directory: D:\Vagrant\vagrant-projects\OracleDatabase\19.3.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 21/02/2021 13:12 .vagrant
d----- 21/02/2021 13:05 ora-response
d----- 21/02/2021 13:05 scripts
d----- 21/02/2021 13:05 userscripts
-a---- 21/02/2021 13:05 1361 .env
-a---- 21/02/2021 13:05 18 .gitattributes
-a---- 21/02/2021 13:05 13 .gitignore
-a---- 11/08/2020 20:07 3059705302 LINUX.X64_193000_db_home.zip
-a---- 21/02/2021 13:05 6512 README.md
-a---- 21/02/2021 13:05 5587 Vagrantfile
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: 32% complete
oracle-19c-vagrant: 36% complete
oracle-19c-vagrant: 40% complete
oracle-19c-vagrant: 43% complete
oracle-19c-vagrant: 46% complete
oracle-19c-vagrant: Completing Database Creation
oracle-19c-vagrant: 51% complete
oracle-19c-vagrant: 54% complete
oracle-19c-vagrant: Creating Pluggable Databases
oracle-19c-vagrant: 58% complete
oracle-19c-vagrant: 77% complete
oracle-19c-vagrant: Executing Post Configuration Actions
oracle-19c-vagrant: 100% complete
oracle-19c-vagrant: Database creation complete. For details check the logfiles at:
oracle-19c-vagrant: /opt/oracle/cfgtoollogs/dbca/ORCLCDB.
oracle-19c-vagrant: Database Information:
oracle-19c-vagrant: Global Database Name:ORCLCDB
oracle-19c-vagrant: System Identifier(SID):ORCLCDB
oracle-19c-vagrant: Look at the log file "/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log" for further details.
oracle-19c-vagrant:
oracle-19c-vagrant: SQL*Plus: Release 19.0.0.0.0 - Production on Sun Feb 21 14:22:43 2021
oracle-19c-vagrant: Version 19.3.0.0.0
oracle-19c-vagrant:
oracle-19c-vagrant: Copyright (c) 1982, 2019, Oracle. All rights reserved.
oracle-19c-vagrant:
oracle-19c-vagrant: Connected to:
oracle-19c-vagrant: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
oracle-19c-vagrant: Version 19.3.0.0.0
...
...
...
oracle-19c-vagrant: Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
oracle-19c-vagrant: Version 19.3.0.0.0
oracle-19c-vagrant: INSTALLER: Database created
oracle-19c-vagrant: INSTALLER: Oratab configured
oracle-19c-vagrant: Created symlink from /etc/systemd/system/multi-user.target.wants/oracle-rdbms.service to /etc/systemd/system/oracle-rdbms.service.
oracle-19c-vagrant: INSTALLER: Created and enabled oracle-rdbms systemd's service
oracle-19c-vagrant: INSTALLER: setPassword.sh file setup
oracle-19c-vagrant: INSTALLER: Running user-defined post-setup scripts
oracle-19c-vagrant: INSTALLER: Done running user-defined post-setup scripts
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
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third field indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
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 runing 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.
Leave a Reply