Oracle on OS/X – Part 1
[Update on 2010/4/9: Scott Ball has written a nice update to this with some really useful additional information, particularly if you want to use Ubuntu 9.x … his post is here. — E.]
I’ve been using an Apple Mac Book Pro as my private laptop for a couple of years and it’s a great machine for just about everything unless you need a local database server (or actually an up to date JDK, but that’s another story …)
Unfortunately Sybase and Oracle don’t have ports of ASE or the Oracle Database that run on Intel Macs, which is a real pain, so I started looking around to see if there were emulation options, given that Macs are now Intel machines. After some investigation I found that you can now assemble a freely available stack of software that allows you to run an Oracle server on an Intel Mac, so I’ve explained the process in a couple of blog entries.
At a high level the process of getting Oracle running on your Mac is:
- Get a virtual machine running on the Mac;
- Download and install a version of Linux into the VM that can host an Oracle server;
- Configure the operating system instance to allow it to host Oracle;
- Install an Oracle server on the Linux host.
Easy eh? Actually, it’s not too hard, but there were a few things that tripped me up along the way, which I’ve noted in the instructions below. In this article I explain how I did the first two steps and in a second one I’ll explain the Oracle specific steps.
- You need virtual machine software, an operating system and a database.
- There are a number of VMs that run on OS/X, including Parallels, VMWare and Virtual Box. I chose VB because it has the nice attribute of being free for personal use! Download Virtual Box from here. You need the Intel Mac software and the User Manual.
- Linux is the easiest OS to go with because Oracle are very committed to it. I chose to use Ubuntu because Oracle XE works on it and it’s easy to use. You can download the 8.1 Server ISO here.
- Finally, download the Oracle database software that you want to use. I chose Oracle Express Edition (Oracle XE) available here. I suspect that all of this can be made to work with any of the Oracle editions and versions, but I chose XE for simplicity. There’s a lot it doesn’t support (XQuery, Java, advanced security, compression, data guard, replication, …) but on the other hand, its installation on Linux is like falling off a log, there are almost no licensing restrictions and if you want the core database its a nice simple compact package (“just” a 210MB download!)
Virtual Machine Installation
- Mount the disk image, run the installer and install the software.
- Start Virtual Box, create a new VM specifying that the OS is “Linux” and the version is “Ubuntu”. Set the memory size to something large but sensible (I have a 2GB laptop, so I set it to 750MB). The wizard will prompt you to create a disk image for the VM and 8 GB or so seems like a good place to start.
Note: Once you’ve created the virtual machine, click Settings and under the General settings, select the Advanced tab and make sure that the Enable PAE/NX checkbox is set. If you don’t do this, Ubuntu won’t boot.
- Configure the VM to mount the Ubuntu server ISO image as the CD (you do this on the CD/DVD ROM section of the Storage tab of the Settings panel).
Operating System Installation
- Start the VM and it should boot from the Ubuntu disk image and start the installer. This is a straight forward process and just runs to completion if you answer its questions, give it a hostname and tell it what to do with the disk space (I just set up a single partition with LVM).
[Tip: to release your cursor from the VM window, you press the left “apple” – ⌘ – key … this is revealed by the message at the bottom right of the window, but this isn’t obvious until you read the manual]
Once the installer completes, unmount the CD (from the Devices menu) and reboot. Ubuntu should then boot up.
- Like most VM systems, VirtualBox allows you to install some OS extensions to improve integration with the operating system. We need these to allow us to mount shared folders to share files. The process is a little lengthy (the VirtualBox manual explains all the steps) but in summary:
- Log in as the privileged user you set up during the install process
- In order to install dynamic kernel module support, run the command
sudo apt-get install dkms
- Install the stuff you need to allow a kernel rebuild by running
sudo apt-get install build-essential linux-headers-`uname -r` module-assistant
- Configure the Module Assistant to allow a kernel rebuild by running
sudo m-a prepare
- Mount the /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso file as the CD (from the VirtualBox Devices menu) and run sudo mount /cdrom to make the files available;
- Run sudo sh /cdrom/VBox-Linux-Additions-x86.run (to install the VM extensions);
- Run sudo /etc/init.d/vboxadd setup (to rebuild the kernel modules);
- Reboot the system (e.g. via sudo /sbin/shutdown -r now)
- So that we can log into the VM easily from the Mac, we’ll need an SSH server. Once you’ve done this you should be able to log in from the VM itself using the command ssh localhost, so install this using
sudo apt-get install ssh(We’ll do the network setup to allow access from the Mac later).
- In order to share files (like the Oracle installer) between your Mac and the Linux VM, you need a shared folder, so select Shared Folders … from the Devices menu and share a directory on your Mac with the VM.
- Mount the shared directory with a command like
sudo mount -t vboxsf shareddir /mnt(where shareddir is the “Folder Name” you gave the shared folder when you set it up in VirtualBox and /mnt is the existing directory where you’d like it to appear in your Unix file system).
- If you want the shared directory to be available every time you boot the VM, put an entry in the
/etc/fstabfile of the form:
shared /shared vboxsf rw 0 0
At this point, you should have a running Ubuntu server on your Mac, with a shared folder to allow us to share files between the Mac and the Linux machine. In the second part of this article I’ll explain how to perform the Oracle specific Linux setup and then get Oracle XE running in the Linux server and usable from Linux.