无法连接到Oracle Express Edition

时间:2017-09-24 16:20:55

标签: oracle oracle-xe

我遇到 Oracle Express Edition 的问题。我可以使用 sqlplus 在数据库中打开并运行命令,但之后我尝试使用 sql developer 连接到Data Base,但它不起作用。这很奇怪,因为我有许多其他远程Oracle数据库,我可以使用 sql developer 或其他工具(如 IDEA )连接它们。听众可能有问题吗?

当我尝试连接时,我在连接到端口1521时超时

Connection to @myhost.company.com failed.

lsnrctl status

LSNRCTL for 32-bit Windows: Version 11.2.0.2.0 - Production on 22-╤┼═-2017 12:04:43
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
TNS-01106: Listener using listener name LISTENER has already been started
C:\Users\luchser>lsnrctl status 
LSNRCTL for 32-bit Windows: Version 11.2.0.2.0 - Production on 22-╤┼═-2017 12:11:20
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version 11.2.0.2.0 - Production
Start Date                21-╤┼═-2017 14:21:26
Uptime                    0 days 21 hr. 49 min. 53 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE

Listener Parameter File   C:\oraclexe\app\oracle\product\11.2.0\server\network\admin\listener.ora
Listener Log File         C:\oraclexe\app\oracle\diag\tnslsnr\localhost\listener\alert\log.xml

Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=myhost.company.com)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=myhost.company.com)(PORT=8080))(Presentation=HTTP)(Session=RAW))

Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
Service "xe" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
The command completed successfully

的listener.ora

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = myhost.company.com)(PORT = 1521)(IP=V4_ONLY))
    )
  )

DEFAULT_SERVICE_LISTENER = (XE)

的tnsnames.ora

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = myhost.company.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

tnsping XE 10

C:\Users\luchser>tnsping XE 10

TNS Ping Utility for 32-bit Windows: Version 11.2.0.2.0 - Production on 26-╤┼═-2017 14:49:12

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

Used parameter files:
C:\oraclexe\app\oracle\product\11.2.0\server\network\admin\sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = myhost.company.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))

OK (0 msec)
OK (10 msec)
OK (0 msec)
OK (0 msec)
OK (20 msec)
OK (0 msec)
OK (0 msec)
OK (10 msec)
OK (0 msec)
OK (20 msec)

sqlplus用户/密码@ XE

C:\Users\luchser>sqlplus my_user/my_password@XE
SQL*Plus: Release 11.2.0.2.0 Production on ┬Є ╤хэ 26 14:50:11 2017
Copyright (c) 1982, 2010, Oracle.  All rights reserved.

最后只是讨厌而没有任何反应。

1 个答案:

答案 0 :(得分:2)

在此配置中,listener.ora和tnsnames.ora。 您只能在本地数据库上建立连接,不能与数据库建立远程连接,因为侦听器只侦听IP localhost。 您必须将外部IP添加到侦听器配置。的listener.ora

    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
          (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)(IP=V4_ONLY))
          (ADDRESS = (PROTOCOL = TCP)(HOST = <IP DB server>)(PORT = 1521)(IP=V4_ONLY))

      )
)

为数据库服务器上的防火墙添加端口1521和端口范围(32768-65536)的例外,这对于SQL * NET协议是必需的。 在客户端计算机上,您需要修复tnsnames.ora, 必须将localhost替换为数据库服务器的IP地址。

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = <IP DB server>)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )