【问题标题】:Oracle SQL Developer: Test failed: The Network Adapter could not establish the connection?Oracle SQL Developer:测试失败:网络适配器无法建立连接?
【发布时间】:2020-12-13 04:15:03
【问题描述】:

我在这里真的需要帮助。我在 VirtualBox VM 上设置了一个 Oracle 数据库服务器,直到昨天一切似乎都运行良好。今天,当我启动数据库以继续工作,并在我的本地机器(客户端机器)中打开 SQLDeveloper 时,它向我抛出了这个错误:

Erro de ES: The Network Adapter could not establish the connection

我的 VirtualBox VM 网络设置配置为 bridged adapter。而且我能够很好地连接,今天开始出现这个错误。

我做了一些研究,但没有一个对我有用。试图遵循这个家伙的解决方案: Oracle SQL Developer: Failure - Test failed: The Network Adapter could not establish the connection? 并且效果不佳。我将在此处分享我的lsnrctl status 和我的文件,以便您查看。

首先这是我开始设置的方式:

1. lsnrctl start 启动监听器。结果:

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 24-AUG-2020 10:40:56

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/12.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/dbserver/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbserver)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                24-AUG-2020 10:40:56
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/dbserver/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

2。 sqlplus / as sysdba 启动 sqlplus shell,然后 startup 启动数据库实例,给出:

ORACLE instance started.

Total System Global Area 2550136832 bytes
Fixed Size          8623928 bytes
Variable Size         671090888 bytes
Database Buffers     1862270976 bytes
Redo Buffers            8151040 bytes
Database mounted.
Database opened.

然后我的lsnrctl status 给出:

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 24-AUG-2020 10:46:34

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbserver)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                24-AUG-2020 10:40:56
Uptime                    0 days 0 hr. 5 min. 38 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/dbserver/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=dbserver)(PORT=5500))(Security=(I removed the path for security))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

我的listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

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

我的tnsnames.ora

  GNU nano 2.9.8                                                                                   tnsnames.ora                                                                                   Modified  

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

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


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


当我尝试通过安装在虚拟机(即服务器端)内的 SQLDeveloper 连接数据库时,它工作正常,但是当我尝试从本地机器(客户端)上的 SQLDeveloper 连接时,我抛出错误。 我看到的每个帖子都告诉我要查看侦听器状态,但我认为这不是问题。

如果有任何帮助,我将不胜感激。非常感谢您,我在这里回答任何其他信息。 =D

编辑:忘了说我使用的是 12c 版的 Oracle 数据库

编辑:这是我尝试连接到数据库的方式:

编辑:当我ping 数据库的主机时,我得到这个:

   [oracle@dbserver admin]$ ping dbserver
PING dbserver(dbserver (fe80::f8dd:c03c:920c:5442%enp0s3)) 56 data bytes
64 bytes from dbserver (fe80::f8dd:c03c:920c:5442%enp0s3): icmp_seq=1 ttl=64 time=0.075 ms
64 bytes from dbserver (fe80::f8dd:c03c:920c:5442%enp0s3): icmp_seq=2 ttl=64 time=0.053 ms
64 bytes from dbserver (fe80::f8dd:c03c:920c:5442%enp0s3): icmp_seq=3 ttl=64 time=0.051 ms
64 bytes from dbserver (fe80::f8dd:c03c:920c:5442%enp0s3): icmp_seq=4 ttl=64 time=0.072 ms
64 bytes from dbserver (fe80::f8dd:c03c:920c:5442%enp0s3): icmp_seq=5 ttl=64 time=0.049 ms
^C
--- dbserver ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 131ms
rtt min/avg/max/mdev = 0.049/0.060/0.075/0.011 ms

【问题讨论】:

  • SQL*Developer 连接属性中的主机名是什么?你能ping那个主机名/IP地址吗?你是给你的虚拟机一个静态 IP 地址还是让它通过 DHCP 分配一个?我认为您关闭了您的虚拟机,当您重新启动它时,它会返回一个新的 IP 地址。
  • 当然!结果如下:[oracle@dbserver admin]$ ping dbserver PING dbserver(dbserver (fe80::f8dd:c03c:920c:5442%enp0s3)) 56 data bytes 64 bytes from dbserver (fe80::f8dd:c03c:920c:5442%enp0s3): icmp_seq=1 ttl=64 time=0.075 ms``` --- dbserver ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 131ms rtt min/avg/max/mdev = 0.049/0.060/0.075/0.011 ms @MatthewMcPeak 我在问题中添加了一个编辑,这样您就可以获得更易读的结果
  • 最简单的方法是创建一个从你的主机转发到 1521 上的虚拟机的端口,然后你可以简单地连接到 localhost:1521
  • @thatjeffsmith 你能说明一下我该怎么做吗?
  • 确定@LeonardoGuerreiro,看看我的回答

标签: oracle oracle-sqldeveloper oracle12c


【解决方案1】:

我过去常常与虚拟机网络设置作斗争,以便我的主机可以“看到”我的虚拟机,反之亦然。

一旦我了解了端口转发,我就不再担心这个了。

您可以简单地告诉 VirtualBox 从本地端口(例如 1521)获取流量,然后将其转发到虚拟机(例如 1521)。

因此,当在 SQL Developer 中从我的主机连接到 VM 时,我可以转到 localhost:1521,并让我的连接流量转到我的 Linux VBox 映像上的 Oracle 侦听器,侦听端口 1521

点击端口转发

为 TCP 1521 和 1521 添加一个条目

然后,在 SQL Developer 中,您只需执行此操作即可连接到 VM 上的数据库

【讨论】:

  • 谢谢@thatjeffsmith!!它完成了这项工作。我刚开始在我正在从事的这个项目中使用 VMBox。我将对此进行一些阅读,以便我可以更好地了解您在答案中概述的步骤的背景下发生了什么。谢谢!
【解决方案2】:

我很高兴你让它工作,但作为替代方案,让我说我不是这个问题的端口转发的忠实粉丝,我也不喜欢使用桥接适配器。我已经在 Windows 和 Ubuntu 主机上的 VBox 下创建了许多虚拟机。在每种情况下,我都会创建 HOSTONLY 适配器,并使用固定 IP 地址对其进行配置。然后我在主机的“hosts”文件中为 vm 添加一个条目。在https://edstevensdba.wordpress.com/2012/12/15/configure-the-virtualbox-network-2/查看更多详情

【讨论】:

  • 我一定要去看看!谢谢@EdStevens
猜你喜欢
  • 2022-10-01
  • 2012-07-25
  • 1970-01-01
  • 1970-01-01
  • 2013-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多