Windows – Cannot Connect to Oracle Database running on Windows 8 Hyper V Virtual Machine

oraclewindows 8windows-server

I have oracle server (standard edition) installed on a guest VM (Windows 8 Hyper V). I have mapped a host entry to the VM as "brettvm". I am able to log into the VM and connect to the default instance using sqlplus. So far so good.

EDIT: Here's the listner.ora file on the server. I'm starting to suspect the trouble may lie here:

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = c:\oracle

The tnsnames.ora file on the server looks like this:

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))


ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

The Problem:
When I attempt to connect from the HOST machine, sqlplus prompts for a password and then hangs. Here is my tnsnames.ora on the host machine:

orcl.brettvm =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = brettvm)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

Some things I have tried:

  • Verifed that "brettvm" is in my hosts (pingable and browseable)
  • Verified connectivity between the host and VM over port 80 (browser / telnet)
  • Verified connectivity between the host and vm over port 1521 (telnet). Note that I opened this port up on the VM through windows firewall.
  • Verified the database is up and running via sqlplus on the host (see above).
  • Turned off windows firewall on the VM

I'm going to start digging through the installation guide…

Any other advice? Thanks.

Best Answer

Ultimately, this came down to a networking issue -- configuring the guest VM's network adapter (internal switch) with a static IP (this was the hard part), assigning a hosts file entry for that IP in both the Host and the Guest machines and then altering both tnsnames.ora files (host and guest) and listner.ora (guest) to use the mapped host name.

Then everything just worked.

I've pasted my internal switch config for both the host and guest and the listener and tnsnames.ora files below.

STEPS TO CONFIGURE THE GUEST VM / HOST:

Assuming that you've already created a guest VM, with a Windows Server OS, here are the networking steps...

  1. Using Hyper-V manager, use the virtual switch manager add an "Internal" type switch
  2. Using Hyper-V manager, open the settings dialog for the guest VM (right click on the VM). Add a network adapter using the internal switch you just created.
  3. Here are my internal switch adapter settings for the host. Note that there is a baked in assumption here that you're outside the range of IP's that would otherwise appear on your network. I know that my home network uses this range (192.168.x.x), and I know I'm ok. Also, I know that my workplace uses 10.x.x.x for wireless, so I'm good there, too.

host internal switch settings

4 . And here's how I configured the guest VM:

guest network adapter settings

5 . I added hosts file aliases for the guest VM on both the host and the guest:

# internal vm's
192.168.0.120    brettvm

6 . Here's the listner.ora on the guest vm (database server):

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = brettvm)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = c:\oracle

7 . Here's the tnsnames.ora on the guest VM:

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = brettvm)(PORT = 1521))


ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = brettvm)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

8 . Finally, here's the tnsnames on the client (host machine):

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = brettvm)(PORT = 1521))


ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = brettvm)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

Bon appetit!

--Brett