Wednesday, 7 December 2011

Using the Oracle Developer Days VirtualBox Image

As many of you know @krisrice put together a great VM for the Oracle Developer Days and while the content is great for education, I find us using it more and more a default scratch database on laptops.  As usual, being 'Networkly challenged', it took me some time to figure out which network adapters did what and why.  This is as much a note for me as it is to share with you :).

First of all, you need to install VirtualBox, which is found here.  Then download one of the prebuilt VirtualBox images for the Developer Days.  You can choose your one here.  Download the ova file and then import your VM into VirtualBox.

To import, choose File> Import Appliance in VirtualBox and click choose to select the directory where you want the VM to live, then select your ova file.  In this example, I'm using @krisrice's Oracle DeveloperDays VM. Once you click finish, and agree to the licenses, you'll see the 'Oracle Developer Days' VM in VirtualBox with a powered off state.

Great.  We're ready to fire up the box and play inside it.  All passwords for this are 'oracle', so you cant go wrong. In this, the database is all setup automatically, as is this list of stuff.

  • Oracle Linux 5
  • Oracle Database 11g Release 2 Enterprise Edition
  • Oracle TimesTen In-Memory Database Cache
  • Oracle XML DB
  • Oracle SQL Developer
  • Oracle SQL Developer Data Modeler
  • Oracle Application Express
  • Oracle JDeveloper
  • Hands-On-Labs (accessed via the Toolbar Menu in Firefox)

So now, login to the vm with oracle/oracle and a terminal window will show you whats available and the network profiles you setup in the VM settings.  The network settings I setup for this is here
These two adapters do separate things.  The bridged adapter will assign an IP address from the wireless NIC.  This is setup by default when you install the VM and allows you to get access to the internet from the VM.  The NAT adapter will allow you to access the VM from the host machine when you have no physical NIC or internet available.  This happened me yesterday when presenting some SQLDeveloper functionality.  By enabling the NAT adapter and setting up a few port forwarding rules, we can ssh into the VM and connect SQL Developer to the normal LISTENER port.
The NAT adapter looks like this.

and setting up two port forwarding rules, gives us this
When you login to the VM, you'll see this on the terminal window.
This setup will allow you to spark up firefox in the VM and connect to the internet using the local network ip  Now, if we switch off the Airport and disable the bridging adapter, we should still be able to connect to the VM from outside.  Restarting the VM, gives us this terminal window on login to the oracle account
Now, we have no external IP, but we have our port forwarding rules set up to get access to the VM from outside.  Now, we have two rules, one which maps anything on port 2222 to port 22 on the guest.  this means we can ssh into the VM on port 2222 on the host. So, connecting with this
and we get the login terminal from the VM
Brilliant.  Now, Lets see SQL Developer connect to the VM too.  We setup the connection like a connection to xe on localhost, except the SID is orcl on the VM.
and we can look at the database version report which shows us what database we are connected to
And now, you're connected and good to go.  This is great for doing demos in a canned environment, especially when you dont have access to an internet connection when doing a demo or showing something off.


elric said...

Very helpful nice post.

elric said...
This comment has been removed by the author.
Ramada03 said...

Very interesting, easily followed. Thanks

Ramada03 said...

Very interesting, easily followed. Thanks

Ramada03 said...

Very interesting, easily followed. Thanks

Ivan Chaer said...

Awesome. Thanks.

Harish Kumar said...

Very interesting and useful blog .. do you see any way to use SCP between host and guest as well?

Barry McGillin said...

Sure, very easily. Open up the port forwarding and forward the appropriate port to that on the vm. then scp -p 2222 myname@testmachine

Nick Bunich said...

It works! Thank you!

Robert R. Jackson said...

Great post. Extremely useful.

Ha Wa said...

what is username and password to access database , I try put username : scott passord: tiger ,show error are invalid.

Bikash C Bhowmik said...

Try to usernaem: system password: oracle

Ha Wa said...

Thanks for the advice.

SD said...

Awesome Blog. Very readable

korkiss said...

I had problem with connection to Oracle from Windows machine.
All attepts to connect was refused while connection to SSH (localhost:2222) was ok.
Solved with Putty tunnel port forwarding.

putty.exe 2222 -ssh -L 1521: -l oracle

AnAverageJoe said...

Hi – great post :) My problem with a recent OTN VM - it appears OEL (at least 6.5) has a firewall inbuilt & blocking the DB port. I was pulling what little hair I have left out trying to get my host SQLDEV to connect to the VM DB. I finally found /system/administration/firewall > Disable that sucker. Cheers

martin c said...

just a note for developer day vm from here:

everything is already set up (vm network is nat with 1521 port forwarding) , except you need to enable networking inside vm linux, which is on top right corner – just click on network icon and enable connection – then you’ll be able to connect from the host

took me while, playing with linux firewall and vm networking which was not needed :)

Daniel Toma said...

Now if only I could get SQLPLUS to work from the terminal prompt. I enter "SQLPLUS", and I'm prompted for credentials. I tried "oracle/oracle", but no luck. Tried "scott/tiger", and no luck. It'd be great to use SQLPLUS in this environment to do nifty things. Oh well. Great post, nonetheless!

Barry McGillin said...

Check that the ORACLE_SID is set to ORCL or the TWO_TASK variable is set and this should be ok.