安装
数据库版本:Oracle 18c XE
在虚拟机管理器内运行的 Ubuntu 18.04 服务器上
问题
安装 Oracle XE 18c 后,我以用户 oracle 身份登录并启动监听器
lsnrctl start
当我尝试连接时出现以下问题:
A.使用:
sqlplus / as sysdba
=>
ERROR:
ORA-12547: TNS:lost contact
B.使用:
sqlplus oracle@ubu-srv as sysdba
=>
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
检查监听器:
lsnrctl status
=>
LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 28-MAR-2020 22:05:40
Copyright (c) 1991, 2018, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ubu-srv)(PORT=1521)))
STATUS of the LISTENER
Alias LISTENER
Version TNSLSNR for Linux: Version 18.0.0.0.0 - Production
Start Date 28-MAR-2020 21:28:33
Uptime 0 days 0 hr. 37 min. 6 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/ubu-srv/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ubu-srv)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
listener.ora的内容:
# listener.ora Network Configuration File: /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora
# Generated by Oracle configuration tools.
DEFAULT_SERVICE_LISTENER = XE
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ubu-srv)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
tnsnames.ora 的内容:
# tnsnames.ora Network Configuration File: /opt/oracle/product/18c/dbhomeXE/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_XE =
(ADDRESS = (PROTOCOL = TCP)(HOST = ubu-srv)(PORT = 1521))
最佳答案
数据库似乎没有正在运行,或者它是否已向网络监听器注册。如果数据库正在运行,当您运行“lsnrctl status”时,您应该会看到列出的几个服务,如下所示:
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost.example.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 18.0.0.0.0 - Production
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/dbhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbhost.example.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=dbhost.example.com)(PORT=5500))(Security=(my_wallet_directory=/opt/oracle/admin/XE/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "77f81bd10c818208e053410cc40aef5a" 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...
Service "XEXDB" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "xepdb1" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
The command completed successfully
您根本不需要为选项 A 运行监听器(从同一主机连接),但您需要设置 ORACLE_SID 环境变量以匹配所需数据库(容器或可插拔数据库)的 SID连接到。要连接到容器数据库,就像手动启动所有数据库服务一样,您可以这样做:
export ORACLE_SID=XE
sqlplus / as sysdba
对于选项 B,通过网络连接,您的连接字符串也显示格式错误;除了主机名之外,它通常还应包含服务名称(至少)。请参阅此处的示例:https://docs.oracle.com/en/database/oracle/oracle-database/18/sqpug/starting-SQL-Plus.html#GUID-A33231E7-9180-4544-A055-411209FD0363
sqlplus username@[//]host[:port][/service_name]
sqlplus pdb_admin@ubu-srv:1521/xepdb1
也就是说,Oracle 未通过 Ubuntu Linux 认证,因此无法保证结果。您应该在 CentOS、Red Hat 或 Oracle Linux 上运行它。支持的 Linux 版本的完整列表如下:https://docs.oracle.com/en/database/oracle/oracle-database/18/ladbi/operating-system-checklist-for-oracle-database-installation-on-linux.html#GUID-E5C0A90E-7750-45D9-A8BC-C7319ED934F0
关于express - 在 Ubuntu 18.04 服务器上安装 Oracle Express Edition 18c - 连接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60908097/