I am trying to set up an Oracle database server (at the moment just for testing purposes) in a virtual machine.
The setup I'm using:
- VirtualBox
- Network adapter in NAT mode (redirecting ports 22->22, 80->80, 1521->1521, 8080->8080)
- I'd rather avoid bridged networking, if possible
- It would be good if the database could be accessed by the outside world, and not just the host OS
- CentOS 6.4 64-bit
- Oracle XE, version 11.2.0.2.0 "Production", installed and configured using the default ports (1521 and 8080)
- Firewall disabled in both the guest OS and the host OS
- The host OS is behind a proxy
The problem
I cannot access the database (over port 1521, using sqlplus or SQL developer) from the host. I can access it from the VM itself though (using sqlplus).
I can also SSH from the host into the VM and I can access the web interface from the host when I navigate to:
http://127.0.0.1:8080/apex
Therefore, the NAT setup of VirtualBox seems to work to some extent.
It seems the listener is up when I execute lsnctrl status. The listener.ora file looks like this:
# listener.ora Network Configuration File:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
When I try to connect from the host, I get the following error (the same command works when executed within CentOS):
PS C:\Users\winuser> sqlplus system/thepassword@127.0.0.1
SQL*Plus: Release 11.2.0.3.0 Production on Fr Jul 12 16:56:25 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
Port 1521 also seems to be active in the VM, and port forwarding is set up appropriately in VirtualBox:
[root@localhost admin]# nmap 127.0.0.1
Starting Nmap 5.51 ( http://nmap.org ) at 2013-07-12 17:02 CEST
Nmap scan report for localhost.localdomain (127.0.0.1)
Host is up (0.0000050s latency).
Not shown: 994 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
111/tcp open rpcbind
631/tcp open ipp
1521/tcp open oracle
8080/tcp open http-proxy
Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
Thank you for any tips or suggestions.
Best Answer
You cannot connect to database using only IP address.
Run
on guest machine to find out service name and instance name (ORCL for example). Then edit tnsnames.ora on host machine similar to this:
and try TNSPINGing it:
It sould say something like "Ok (20 msec.)" At last run sqlplus:
For more information read Oracle Documentation: http://www.oracle.com/pls/db112/portal.portal_db?selected=4&frame=#network_management