Linux – Connect to Oracle Database that is hosted in a Virtual Machine from the host machine

databaselinuxoraclevirtualization

Good day,

I've just setup a Virtual Machine (using VirtualBox) of Oracle Linux with Oracle Database in it. After setting it up, I can verify that I can connect to it using sqlplus (sqlplus of the Virtual Machine)

$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Sat Apr 21 14:32:48 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

SQL> conn myusername/mypassword
Connected.
SQL> select count(1) from my_table;

  COUNT(1)
----------
    73

SQL> 

However, when I try to connect using JDeveloper from the Host Machine, I am getting

Status : Failure – Test failed: IO Error: The Network Adapter could not established the connection.

I tried connecting to other databases from our intranet from the JDeveloper of the Host Machine and they do succeed. Also, I tried turning off the iptables of the Virtual Machine (just in case).

sudo /etc/init.d/iptables stop

So far though, nothing works.

Any ideas?

Thanks,

Franz See

EDIT:
Update: I have just installed sqlplus on my host machine (note to others: instantclient 10.2.0.4.0 64bit does not work on mac. Use the 32-bit instead even if your mac is 64 bit like mine.), and I tried connecting to my oracle db in my virtual machine and it succeeded! However, I still cannot connect using JDeveloper.

Best Answer

On the machine that has sqlplus installed, in your case the host of the virtual machine, you need to set Oracle environmental variables before you can connect to other Oracle Database servers. For example:

setenv ORACLE_SID orcl
setenv ORACLE_HOME /u01/app/oracle/product/11.1.0/db_1
setenv LD_LIBRARY_PATH $ORACLE_HOME/lib:/usr/lib:/usr/dt/lib:/usr/openwin/lib:/usr/ccs/lib

You may have to manually create the admin folder and a tnsnames.ora file in that folder.

The process for connecting to a remote Oracle server is not a wizard driven one and takes some manual labor on your part. The help document linked to above will guide you through what you need for your specific environment.


EDIT 1

Sorry, I think I understand things better now. Let's try something diff'rnt.

I think that the instance listener on the virtual machine is not listening on the IP address. On the virtual machine, go to the Net Services Administration page on the Oracle Enterprise Manager web interface. Edit the listener (LISTENER_localhost) and add a listener and select to use the IP address of the instance. Keep port 1521 as per default. You will be asked if you want to restart the service. Please do so. Then you should be able to connect from your host (or any other machine for that matter).


EDIT 2

In JDeveloper, using the connection wizard on stop 3 of 4, use the Service Name, not the SID.

enter image description here