My main (physical) machine is Windows 7. I have installed a "homestead" Virtual Machine using VirtualBox so that I can develop a Laravel application in the VM. Homestead (the VM) runs Ubuntu 14.10 as its OS.
Also on my Win 7 machine, I have installed an Oracle database. The database is running fine, and I can access it from an Sql*Plus
session running on the Windows machine itself. However, I wish to access this same Oracle Database from the Homestead machine (ultimately so that I can access the database through my web application). As a first step to achieving this goal, I have tried to install the Oracle Instant Client on Homestead (11.2), and configured it to the best of my knowledge as follows:
Some environment variables that are set on the Ubuntu/Homestead machine are:
export ORACLE_HOME=/usr/lib/ora_home_directory
export LD_LIBRARY_PATH=$ORACLE_HOME
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME
I can ping the Win7 machine from Homestead:
# ping -c 4 cbh01
PING cbh01 (192.168.1.9) 56(84) bytes of data.
64 bytes from 192.168.1.9: icmp_seq=1 ttl=127 time=2.96 ms
64 bytes from 192.168.1.9: icmp_seq=2 ttl=127 time=1.04 ms
64 bytes from 192.168.1.9: icmp_seq=3 ttl=127 time=1.21 ms
64 bytes from 192.168.1.9: icmp_seq=4 ttl=127 time=1.45 ms
I can launch Sql*Plus
from the SSH session which I open to Homestead:
# sqlplus /nolog
SQL>
tnsnames.ora
on the Homestead machine contains the following entry:
ORACBH =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = cbh01)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = ORACBH))
)
listener.ora
on the Win7 machine looks like this:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oracle\product\10.2.0\db_2)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = ORACBH)
(ORACLE_HOME = C:\oracle\product\10.2.0\db_2)
(SID_NAME = ORACBH)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
When I do a connect:
SQL> conn usr/pass@oracbh
It returns:
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
It seems to me that it's not taking notice of the tnsnames.ora
file. This is a problem in itself, but no matter, perhaps I can work around the problem by connecting with the connect string directly.
SQL> conn usr/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=CBH01)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORACBH)))
But this is simply met with the following:
ERROR:
ORA-12541: TNS:no listener
I have switched off all firewalls, so I don't think this is the problem. Otherwise I'm running out of ideas. :-/
Listener seems to be running fine.
C:\Users\Bob>lsnrctl status
LSNRCTL for 32-bit Windows: Version 10.2.0.4.0 - Production on 05-JUN-2015 08:07:44
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 32-bit Windows: Version 10.2.0.4.0 - Production
Start Date 05-JUN-2015 06:49:27
Uptime 0 days 1 hr. 18 min. 21 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File C:\oracle\product\10.2.0\db_2\network\admin\listener.ora
Listener Log File C:\oracle\product\10.2.0\db_2\network\log\listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services Summary...
Service "ORACBH" has 1 instance(s).
Instance "ORACBH", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
I tend to think that the problem is a combination of how the VM accesses the network. I don't think it is an Oracle issue. My knowledge of networks and the like is limited so feel free to enlighten me on this front!! Similar issues are reported on some Oralce and VM support pages, e.g.: https://community.oracle.com/thread/2439416
Trying to debug connection across the network, I've used Telnet as follows:
vagrant@homestead:~$ telnet 192.168.1.9 1521
Trying 192.168.1.9...
telnet: Unable to connect to remote host: Connection refused
But as previously stated, I've already disabled all firewall software, which would eliminate a port-blocking at this level.