安装
DB版本:Oracle 18c XE
在Ubuntu 18.04服务器上运行Virtual Machine Manager
问题
安装Oracle XE 18c后,我以用户身份登录并启动侦听器
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环境变量设置为与要连接的数据库(Container或Pluggable DB(的SID相匹配。要连接到容器DB,就像手动启动所有数据库服务一样,您需要执行以下操作:
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