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:
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 10.0.2.2 [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/VBoxLinuxAdditions.run --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: http://download.oracle.com/otn/linux/oracle12c/121020/linuxamd64_12102_database_1of2.zip
File 2: http://download.oracle.com/otn/linux/oracle12c/121020/linuxamd64_12102_database_2of2.zip
Place the two files in the shared directory on your Mac system in ~/oracle12vm.
For the installation I recommend to follow the guide on the CentOS wiki at https://wiki.centos.org/HowTos/Oracle12onCentos7.
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/
Also on the guest virtual machine, set the Oracle environment variables.
Create the following file:
[vagrant@localhost ~]$ sudo vi /etc/profile.d/oracle.sh
Add the following content to the file:
TMPDIR=$TMP ORACLE_BASE=/u01/app/oracle ORACLE_HOME=$ORACLE_BASE/product/12.1.0/dbhome_1; ORACLE_SID=orcl PATH=$ORACLE_HOME/bin:$ORACLE_HOME/lib:$ORACLE_HOME/lib32:$PATH LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib64 CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib export TMPDIR; export ORACLE_BASE; export ORACLE_HOME; export ORACLE_SID; export PATH; export LD_LIBRARY_PATH export CLASSPATH;
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 220.127.116.11.0 Production on Wed Jan 4 21:57:07 2017 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to an idle instance. SQL>
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:
ALTER DATABASE DEFAULT TABLESPACE DATA;
Remove the default tablespace called "users":
DROP TABLESPACE users INCLUDING CONTENTS AND DATAFILES;
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 http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html. 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/18.104.22.168.0/bin $ mkdir -p /Applications/oracle/product/instantclient_64/22.214.171.124.0/lib $ mkdir -p /Applications/oracle/product/instantclient_64/126.96.36.199.0/jdbc/lib $ mkdir -p /Applications/oracle/product/instantclient_64/188.8.131.52.0/rdbms/jlib $ mkdir -p /Applications/oracle/product/instantclient_64/184.108.40.206.0/network/admin $ mkdir -p /Applications/oracle/product/instantclient_64/220.127.116.11.0/sqlplus/admin $ cd ~/Downloads/instantclient_12_1/ $ mv ojdbc* /Applications/oracle/product/instantclient_64/18.104.22.168.0/jdbc/lib/ $ mv x*.jar /Applications/oracle/product/instantclient_64/22.214.171.124.0/rdbms/jlib/ $ mv glogin.sql /Applications/oracle/product/instantclient_64/126.96.36.199.0/sqlplus/admin/ $ mv *dylib* /Applications/oracle/product/instantclient_64/188.8.131.52.0/lib/ $ mv *README /Applications/oracle/product/instantclient_64/184.108.40.206.0/ $ mv * /Applications/oracle/product/instantclient_64/220.127.116.11.0/bin/
Create the tnsnames.ora file:
$ vi /Applications/oracle/product/instantclient_64/18.104.22.168.0/network/admin/tnsnames.ora
Add the following content to it:
ORCL= (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=localhost) (PORT=1523) ) (CONNECT_DATA= (SERVER=dedicated) (SID=ORCL) ) )
Afterwards, you can should be able to login from Mac (host) with the command
$ sqlplus system/system@orcl