我正在尝试在我的 Linux 机器上设置 oracle-xe。我只需要一个环境来玩 Oracle SQL;这不是用于生产。
当我尝试启动 SQLPLUS 时,我不断收到以下错误之一:
ORA-12541: TNS:no listener
ORA-28547: connection to server failed, probable Oracle Net admin error
有很多关于类似问题的帖子,但即使在尝试了许多不同的“解决方案”之后,我仍然迷路了。
我可能做错了一些可怕的事情。请参阅以下输出:
[oracle@roshan ~]$ whoami
oracle
[oracle@roshan ~]$ pwd
/usr/lib/oracle
[oracle@roshan ~]$ echo $ORACLE_HOME
/usr/lib/oracle/product/11.2.0/xe
[oracle@roshan ~]$ echo $ORACLE_SID
PLSExtProc
[oracle@roshan ~]$ cat product/11.2.0/xe/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
SQL_AUTHENTICATION_SERVICES = (NONE)
[oracle@roshan ~]$ product/11.2.0/xe/bin/lsnrctl start
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 22-OCT-2017 12:24:03
Copyright (c) 1991, 2011, Oracle. All rights reserved.
TNS-01106: Listener using listener name LISTENER has already been started
[oracle@roshan ~]$ product/11.2.0/xe/bin/lsnrctl status
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 22-OCT-2017 12:24:07
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 22-OCT-2017 12:21:18
Uptime 0 days 0 hr. 2 min. 48 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File /usr/lib/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File /usr/lib/oracle/diag/tnslsnr/roshan/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=roshan.localdomain)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, 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
[oracle@roshan ~]$ sqlplus SYSTEM/foobar@localhost:8080/PLSExtProc
SQL*Plus: Release 12.2.0.1.0 Production on Sun Oct 22 12:24:14 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
ERROR:
ORA-12541: TNS:no listener
Enter user-name: % [oracle@roshan ~]$ sqlplus SYSTEM/foobar@localhost:1521/PLSExtProc
SQL*Plus: Release 12.2.0.1.0 Production on Sun Oct 22 12:24:27 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
ERROR:
ORA-28547: connection to server failed, probable Oracle Net admin error
Enter user-name: %
[oracle@roshan ~]$ su
Password:
[root@roshan oracle]# /etc/rc.d/oracle-xe status
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 22-OCT-2017 12:32:06
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 22-OCT-2017 12:21:18
Uptime 0 days 0 hr. 10 min. 47 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File /usr/lib/oracle/product/11.2.0/xe/network/admin/listener.ora
Listener Log File /usr/lib/oracle/diag/tnslsnr/roshan/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=roshan.localdomain)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, 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
这些看起来有什么不对吗?
1) 您应该将 ORACLE_SID 设置为“xe”,而不是“PLSExtProc”。“PLSExtProc”是外部过程的特例。在超过 25 年的时间里,我从来没有理由使用它。
2) 当你像这样调用 sqlplus 时:
您正在调用进程间连接,并绕过所有网络问题,包括侦听器。侦听器仅涉及网络上的请求。
当你像这样调用 sqlplus 时:
您正在调用网络连接,详细信息可从 tnsnames.ora 文件中的“mydb”条目中解析
当您像这样调用 sqlplus 时(如@Balazs Papp 所建议)
您正在调用网络连接,但绕过 tnsnames.ora 的使用并直接提供关键信息(主机名、端口、sid)。并不是所有三个元素都必须与“lisnrctl status”报告的内容相匹配。在您的情况下,主机不是“localhost”,而是“roshan.localdomain”。
您的客户端(sqlplus)和数据库在同一台机器上这一事实并不重要。如果您使用调用网络连接的语法,请求仍会通过所有网络协议。
您可以在http://edstevensdba.com/category/oracle-tns/和http://edstevensdba.com/category/oracle-listener/阅读更多关于 oracle 如何处理网络连接的信息
侦听器侦听默认端口:1521。您正在尝试使用端口 8080 登录。
而不是这个:
尝试这个:
APEX 使用端口 8080,你可以从浏览器登录那里。