Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
Why do you want to avoid bridged networking? –  Michael Hampton Jul 12 '13 at 18:18
    
Because I would like the database to be accessible when clients connect to my machine. With bridged networking, the virtual machine appears as a separate machine on the network. I'd use bridged if there is no other solution though. –  Mr. Pixel Jul 15 '13 at 8:00
add comment

2 Answers

This sounds like a problem with your Oracle network configuration. Either use network manager or hand-edit sqlnet.ora and tnsnames.ora in $ORACLE_HOME/network/admin.

share|improve this answer
    
Thanks for the info. I assume the network manager is a graphical application (the CentOS server does not have a graphical server installed)? I noticed I don't have an sqlnet.ora file, is this a mandatory file? –  Mr. Pixel Jul 12 '13 at 15:43
add comment

You cannot connect to database using only IP address.

Run

lsnrctl status

on guest machine to find out service name and instance name (ORCL for example). Then edit tnsnames.ora on host machine similar to this:

ORCL=
(DESCRIPTION=
 (ADDRESS=
   (PROTOCOL=TCP)
   (HOST=127.0.0.1)
   (PORT=1521)
 )
 (CONNECT_DATA=
   (SERVER=dedicated)
   (SERVICE_NAME=your_service_name_here)
 )
)

and try TNSPINGing it:

tnsping ORCL

It sould say something like "Ok (20 msec.)" At last run sqlplus:

sqlplus user/password@ORCL

For more information read Oracle Documentation: http://www.oracle.com/pls/db112/portal.portal_db?selected=4&frame=#network_management

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.