Monday, September 21, 2009

Running APEX on 11gR2 using Sun's (Oracle's?) VirtualBox

Today I decided that I needed an environment to play with the latest and greatest Oracle RDBMS : 11gR2. This version is only available for Unix platforms, so I needed a virtual environment to get that working on my laptop - running on XP.
You can pick any kind of virtualization software, but, due to the recent take-over of Sun by Oracle, I decided to go for what's currently known as Sun's VirtualBox. I guess this product will re-branded to Oracle's VirtualBox somewhere soon.
So what are the steps:

1. Download VirtualBox from http://www.virtualbox.org/ and run the installer.

2. Start VirtualBox, click 'New' and enter a Name, Operating and Version for the Virtual machine. This is gonna be a 100% Oracle thing, so I installed Oracle Enterprise Linux (OEL).

3. Oracle 11gR2 needs 1Gb of RAM, so set the memory size to 1024 - you can change this afterwards.

4. Create a new boot harddisk with dynamically expanding storage.









5. On the next page you have to set the 'size of the virtual hard disk'. This is not the initial size, but the maximum to which the harddisk can be expanded. So don't take it too small, because adding or expanding a hard disk to a current installation is not so easy...(as I have experienced).














6. Next start the VM and install OEL from a DVD or ISO download. I installed it with all defaults, with support for Software Development and Webserver. Honestly I have no idea what is added by checking these features, but I checked it just because that's what I want to use it for.

7. Now take a break - or do something else - while OEL is being installed... it takes a while.










8. After installation you have to configure OEL. You can accept all defaults, I just changed the settings for the Firewall to accept HTTP request on port 8080 - the one we're going to use for running APEX.













9. Next add a Shared Folder in VirtualBox - a folder that can be used by both the host and the guest OS. To use it within the Linux environment: login as root, mount the VBoxGuestAdditons.iso (by pressing the Host-D key, whereby Host is the right Ctrl key by default), copy VBoxLinuxAddtions-x86.run to the Desktop and run it. Restart the VM when that's finished.

10. Mount the added shared drive: sudo mount -t vboxsf Shared /media/shared






11. In the Host OS: Download the two 11gR2 disks, copy them to c:\shared, unzip them - of course you can do that in the Guest system also, but not while you're installing it ;-). Install 11gR2 on the Guest OS following the steps in the documentation. Again some time for a good cup of coffee....









12. 11gR2 is shipped with APEX, so it just takes two steps to get it running:
Open up the EPG using port 8080 : Start SQLPlus, login as SYS, exec dbms_xdb.sethttpport(8080) and set a password for the APEX Admin user by executing the apxchpwd script (located in /home/oracle/app/oracle/product/11.2.0/dbhome_1/apex for a default installation). Now you can open up the browser, navigate to http://localhost:8080/apex/apex_admin and off you go.

13. Now where almost there...because now we want to use the database in the VM from the browser in the Host OS. Therefore we need to set up Port Forwarding in VirtualBox. Shutdown the Guest VM and VirtualBox. Run these three commands:
vboxmanage setextradata OEL "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apex/HostPort" 8080
vboxmanage setextradata OEL "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apex/GuestPort" 8080
vboxmanage setextradata OEL "VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apex/Protocol" TCP
Startup VirtualBox and the VM. If the database doesn't start, login as the oracle user, set the environment (. /usr/local/bin/oraenv), start the listener (lsnrctl start) and start the database (sqlplus sys as sysdba and enter 'startup').
Now we can use the APEX on Oracle 11gR2 in a Oracle Enterprise Linux VirtualBox from an XP Host OS. And it runs very fast....!!

One final remark: If you've got an Oracle instance running on your Host OS, http://localhost:8080/apex will open up the login page from your Host. So you either have to shut that down, or forward another HostPort (like 8081).
Post a Comment