简体   繁体   中英

Oracle virtual box: TNS:Listener does not currently know of SID given in connect descriptor

I am setting up Oracle in virtual box and ran into this error: TNS:Listener does not currently know of SID given in connect descriptor .

Here are the steps I took to download oracle on virtual box:

  1. Downloaded VirtualBox 5.2.0.
  2. Got the Oracle DB Developer VM file (DeveloperDaysVM2017-06-13_01.ova).
  3. Opened the file inside virtual box and opened it from virtual box.
  4. Now when I go to Sql Developer on my Mac machine and try to connect to oracle in Virtual Box I got that error above. I included a screenshot below.

在此处输入图像描述

For some reason when I do: te.net 127.0.0.1 1521 it seems to work. But when I do it through Sql Developer I am getting the error in red in the pic above. Can someone give me some pointers?

My tnsnames.ora file:

ORCL12C =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl12c)
    )
  )

LISTENER_ORCL12C =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))


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

listeners.ora file:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl12c)
      (SID_NAME = orcl12c)
      (ORACLE_HOME = /u01/app/oracle/product/12.2/db_1)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
    )
  )

#HOSTNAME by pluggable not working rstriction or configuration error.
DEFAULT_SERVICE_LISTENER = (orcl12c)

You should check your listener.ora and tnsnames.ora. Be sure that sid name is well defined.

On your connect descriptor you are setting "xe" (as we can see in screenshot" and you should put "orcl12c".

For the user and password try:

sys/manager

system/manager

Here is what was the issue in my case: (some differences though: I use service orcl for connection and Oracle Virtual Lab appliance for the database link: https://www.oracle.com/database/technologies/databaseappdev-vm.html )

root cause

There are usually two TNS listener involved:

TNS listener on your local PC coming from installed Oracle Client (localhost:1521)
TNS listener in Virtual machine coming from Virtual Lab Oracle DB (localhost:1521)

And this is the issue. Naturally an SQL connection would be linked to the local TNS listener and not to the Virtual Box.

solution

use different port (1522) in connection and set port forwarding on NAT.network adapter for Virtual Machine (1522 → 1521)

I noticed when I could connect fine from sql developer which is integrated in VirtualBox image and I could also see a TNS listener in the services of my Windows laptop. Also SSH connection was working fine (port forwarding 2222 -> 22).

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM