Using Vagrant with Oracle Database

This post is also available at: Português

Vagrant Logo
Vagrant Logo

Vagrant is an excellent tool for provisioning environments for quick tests. With just a few commands you can deploy a virtual machine and an Oracle database.
The versions that have official boxes are:

11.2.0.2
12.1.0.2
12.2.0.1
18.3.0
18.4.0-XE
19.3.0
21.3.0-XE
21.3.0
23.3.0-Free
23.7.0-Free
Plaintext

The test I’m going to do is with version 12.2.0.1, so I’m going to access the directory for that version:

$ cd /vms/Vagrant/vagrant-boxes/OracleDatabase/12.2.0.1
Bash

And copy the 12.2.0.1 database binaries into this directory.

$ cp /vms/OneDrive/BINARIOS/ORACLE/Oracle_12c_122/linuxx64_12201_database.zip .
Bash

Once this is done, just run the command below to start a virtual machine with Oracle Database 12.2.0.1 started and ready to use.

$ vagrant up
Bash

To access the virtual machine.

vagrant ssh 
Bash

The password of the SYS , SYSTEM and PDBADMIN user is entered just before the “vagrant up” command is completed.

oracle-12201-vagrant: ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: aQMhKivSfVU=1
Bash

To finish the whole process, you need a little patience, it takes a long time.
After finishing a few commands:

henrique@laboratorio:/vms/Vagrant/vagrant-boxes/OracleDatabase/12.2.0.1$ vagrant ssh
Last login: Tue Mar 23 20:54:09 2021 from 10.0.2.2

Welcome to Oracle Linux Server release 7.9 (GNU/Linux 5.4.17-2036.102.0.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-12201-vagrant ~]$ sudo su -
Last login: Tue Mar 23 20:55:19 -03 2021 on pts/0
[root@oracle-12201-vagrant ~]# ps -ef  |grep pmon
oracle    5968     1  0 20:30 ?        00:00:00 ora_pmon_ORCLCDB
root      8053  8032  0 20:55 pts/0    00:00:00 grep --color=auto pmon



[root@oracle-12201-vagrant ~]# su - oracle
Last login: Tue Mar 23 20:30:31 -03 2021
Last failed login: Tue Mar 23 20:55:12 -03 2021 on pts/0
There was 1 failed login attempt since the last successful login.



[oracle@oracle-12201-vagrant ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Mar 23 20:55:43 2021

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>
E para desligar a box.

$ vagrant halt
==> oracle-12201-vagrant: Attempting graceful shutdown of VM...
Todos os comandos disponíveis do Vagrant, vou destacar os mais usados.

henrique@laboratorio:~$ vagrant
Usage: vagrant [options] <command> [<args>]

    -h, --help                       Print this help.

Common commands:
     autocomplete    manages autocomplete installation on host
     box             manages boxes: installation, removal, etc.
     cloud           manages everything related to Vagrant Cloud
     destroy         stops and deletes all traces of the vagrant machine
     global-status   outputs status Vagrant environments for this user
     halt            stops the vagrant machine
     help            shows the help for a subcommand
     init            initializes a new Vagrant environment by creating a Vagrantfile
     login
     package         packages a running vagrant environment into a box
     plugin          manages plugins: install, uninstall, update, etc.
     port            displays information about guest port mappings
     powershell      connects to machine via powershell remoting
     provision       provisions the vagrant machine
     push            deploys code in this environment to a configured destination
     rdp             connects to machine via RDP
     reload          restarts vagrant machine, loads new Vagrantfile configuration
     resume          resume a suspended vagrant machine
     snapshot        manages snapshots: saving, restoring, etc.
     ssh             connects to machine via SSH
     ssh-config      outputs OpenSSH valid configuration to connect to the machine
     status          outputs status of the vagrant machine
     suspend         suspends the machine
     up              starts and provisions the vagrant environment
     upload          upload to machine via communicator
     validate        validates the Vagrantfile
     version         prints current and latest Vagrant version
     winrm           executes commands on a machine via WinRM
     winrm-config    outputs WinRM configuration to connect to the machine

For help on any individual command run `vagrant COMMAND -h`

Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.
        --[no-]color                 Enable or disable color output
        --machine-readable           Enable machine readable output
    -v, --version                    Display Vagrant version
        --debug                      Enable debug output
        --timestamp                  Enable timestamps on log output
        --debug-timestamp            Enable debug output with timestamps
        --no-tty                     Enable non-interactive output
Plaintext

References:

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

Previous Article

ORA-01400: cannot insert NULL into

Next Article

Creating a Custom Docker Image with MongoDB Data

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *