Oracle in Vagrant CentOS virtual machine

  • dani


5 min read

Running Oracle on macOS is impossible? No, I show you how to install the Oracle database in a Vagrant CentOS virtual machine on your Mac.


Go to the webpage of VirtualBox and download the latest version from their download page, e.g. version 5.1.10 as DMG file. If you have previously installed an earlier version of VirtualBox, that's no problem. Just install the new version over the older one by running the setup.


Download the latest Vagrant version from their downloads webpage, e.g. version 1.9.0 from here. If you already installed an older version just install the new version over the old version.

CentOS virtual machine

To install Oracle, first create a directory where you want to install the Oracle version. From the Terminal run:

$ cd ~/
$ mkdir oracle12vm
$ cd oracle12vm/

We want to install Oracle on a CentOS 7.1 machine, so we setup the CentOS 7.1 machine first. Fortunately, we don't need to do that as Vagrant already provides one:

$ vagrant init centos/7; vagrant up --provider virtualbox

Note that you have to enable X11Forwarding on your host Mac in the file /etc/ssh/sshd_config to allow the Oracle setup window to be forwarded from the guest CentOS virtual machine to the host Mac system. Check the file, remove the # in front of the X11Forwarding and set its value to yes:

X11Forwarding yes

Now, connect to the guest CentOS virtual machine that we have just created:

$ vagrant ssh

As soon as you are connected, you will see the following message:

Last login: Wed Jan 4 16:10:20 2017 from
[vagrant@localhost ~]$

Now install gcc, kernel headers, and some more on the guest machine using the yum package manager:

[vagrant@localhost ~]$ yum install -y dkms binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel

On the Mac host system, go to the VirtualBox website again and download the VirtualBox guest additions and place them in the shared directory, where they are available in the guest virtual machine. I've downloaded the file VBoxGuestAdditions_5.1.10.iso and placed it in ~/oracle12vm.

In the guest virtual machine, mount the VirtualBox guest additions that are placed within the shared directory and install them:

[vagrant@localhost ~]$ sudo mkdir /media/VBoxGuestAdditions
[vagrant@localhost ~]$ sudo mount -o loop,ro /vagrant/VBoxGuestAdditions_5.1.10.iso /media/VBoxGuestAdditions
[vagrant@localhost ~]$ sudo sh /media/VBoxGuestAdditions/ --nox11

Now test that the X11Forwarding is working and start an X11 application on the guest that should be displayed on the host Mac system. You can e.g. install clock, then disconnect:

[vagrant@localhost ~]$ sudo yum install -y clock
[vagrant@localhost ~]$ exit

Connect again to the guest virtual machine, but allow X11 forwarding:

$ vagrant ssh -- -vvv -X

After you are connected, you can run xclock and check whether the forwarding is working:

[vagrant@localhost ~]$ xclock

If you see the clock appearing on your Mac operating system, it works!


While staying connected with the X11 forwarding enabled, we first have to do some preparation.

Create swap file

To install Oracle, an 8 GB swap file is required on the guest virtual machine.
To set up the swap file run the commands (note that my system is German):

[vagrant@localhost ~]$ sudo dd if=/dev/zero of=/swapfile count=8192 bs=1M
8192+0 Datensätze ein
8192+0 Datensätze aus
8589934592 Bytes (8,6 GB) kopiert, 15,3429 s, 560 MB/s
[vagrant@localhost ~]$ sudo chmod 600 /swapfile
[vagrant@localhost ~]$ sudo mkswap /swapfile
Swapbereich Version 1 wird angelegt, Größe = 8388604 KiB
kein Label, UUID=58d89ea9-4eb8-4e87-82a8-3611fe91e08c
[vagrant@localhost ~]$ sudo swapon -v /swapfile
swapon /swapfile
swapon: /swapfile: found swap signature: version 1, page-size 4, same byte order
swapon: /swapfile: pagesize=4096, swapsize=8589934592, devsize=8589934592

Download Oracle software

The Oracle software can be downloaded from the Oracle webpage after login. The following two files will be needed:
File 1:
File 2:

Place the two files in the shared directory on your Mac system in ~/oracle12vm.

Install Oracle

For the installation I recommend to follow the guide on the CentOS wiki at


If you receive the error:

INFO: /usr/bin/ld: cannot find -ljavavm12
collect2: Fehler: ld gab 1 als Ende-Status zurück

Then run the following copy command (note that the paths may be different for you):

[vagrant@localhost ~]$ sudo cp /u01/app/oracle/product/12.1.0/dbhome_1/javavm/jdk/jdk6/lib/libjavavm12.a /u01/app/oracle/product/12.1.0/dbhome_1/lib/

Environment variables

Also on the guest virtual machine, set the Oracle environment variables.
Create the following file:

[vagrant@localhost ~]$ sudo vi /etc/profile.d/

Add the following content to the file:

export TMPDIR;
export ORACLE_SID;
export PATH;

Create tablespace

Create a new bigfile tablespace called "data". Login as oracle user:

[vagrant@localhost ~]$ sudo su - oracle
[oracle@localhost ~]$

Connect to the database as SYSDBA:

[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release Production on Wed Jan 4 21:57:07 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to an idle instance.

Now run the following Oracle SQL commands.
Create the tablespace:

create bigfile tablespace DATA datafile '/u02/orcl/data.dbf' SIZE 100M AUTOEXTEND ON EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K;

Set the tablespace called "data" as default:


Remove the default tablespace called "users":


Oracle client

Up to now, we have installed the Oracle server on the guest virtual machine. Disconnect from the guest virtual machine (exit) and return to your host Mac system. There, we need to install the Oracle client.

You can download the client at The two files of interest are

Download both files to your Mac and unpack them to ~/Downloads/instantclient_12_1/.

Then run the commands:

$ mkdir -p /Applications/oracle/product/instantclient_64/
$ mkdir -p /Applications/oracle/product/instantclient_64/
$ mkdir -p /Applications/oracle/product/instantclient_64/
$ mkdir -p /Applications/oracle/product/instantclient_64/
$ mkdir -p /Applications/oracle/product/instantclient_64/
$ mkdir -p /Applications/oracle/product/instantclient_64/
$ cd ~/Downloads/instantclient_12_1/
$ mv ojdbc* /Applications/oracle/product/instantclient_64/
$ mv x*.jar /Applications/oracle/product/instantclient_64/
$ mv glogin.sql /Applications/oracle/product/instantclient_64/
$ mv *dylib* /Applications/oracle/product/instantclient_64/
$ mv *README /Applications/oracle/product/instantclient_64/
$ mv * /Applications/oracle/product/instantclient_64/

Create the tnsnames.ora file:

$ vi /Applications/oracle/product/instantclient_64/

Add the following content to it:


Afterwards, you can should be able to login from Mac (host) with the command

$ sqlplus system/system@orcl