环境:宿主机windows;Oracle部署环境centos7(dockerdesktop创建的容器);端口映射1521:1521
问题1:宿主机使用dbeaver连接Oracle服务,报错异常:
ORA-17800: 从读取调用中减去了一个 (CONNECTION_ID=QAd8w6vPQxifNvB3zd7s2g==)
查看监听器状态:
[oracle@a148f323c4cf log]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 01-APR-2025 07:21:18
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ff2359429202)(PORT=1521)))
TNS-12545: Connect failed because target host or object does not exist
TNS-12560: TNS:protocol adapter error
TNS-00515: Connect failed because target host or object does not exist
Linux Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 2: No such file or directory
注意监听器的作用:
Oracle 监听器(Oracle Listener)是 Oracle 数据库网络架构中的核心组件,其主要作用是管理客户端与数据库服务器之间的通信,类似于电话交换机,负责接收连接请求并将其路由到正确的数据库服务。
尝试启动监听器:
[oracle@a148f323c4cf log]$ lsnrctl start
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 01-APR-2025 06:45:55
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Starting /opt/oracle/product/19c/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/a148f323c4cf/listener/alert/log.xml
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ff2359429202)(PORT=1521)))
TNS-12545: Connect failed because target host or object does not exist
TNS-12560: TNS:protocol adapter error
TNS-00515: Connect failed because target host or object does not exist
Linux Error: 2: No such file or directory
Listener failed to start. See the error message(s) above...
[oracle@a148f323c4cf log]$ hostname
a148f323c4cf
[oracle@a148f323c4cf log]$ hostname -i
192.168.100.104
[oracle@a148f323c4cf log]$
注意到:HOST=ff2359429202并不是Oracle部署机的地址,我Oracle部署及的地址由hostname查看得知为a148f323c4cf。为了避免修改listener.ora文件,我选择直接修改本机/etc/hosts文件,在本机IP后面再新增一个别名用" "空格分隔开

重新启动lsnrctl start监听器后查看状态是成功的:

再次连接,又报错:
ORA-12514: 无法连接到数据库。服务 %s 未注册到 %s 中的监听程序。 (CONNECTION_ID=yT1PYhZiRIqkDfuoDo61zQ==)
查看lsnrctl status打印输出的监听器日志路径:
/opt/oracle/diag/tnslsnr/a148f323c4cf/listener/alert/log.xml
<msg time='2025-04-01T07:44:07.495+00:00' org_id='oracle' comp_id='tnslsnr'
type='UNKNOWN' level='16' host_id='a148f323c4cf'
host_addr='192.168.100.104' pid='48703'>
<txt>01-APR-2025 07:44:07 * (CONNECT_DATA=(CID=(PROGRAM=DBeaver 23?3?3 ? Main)(HOST=__jdbc__)(USER=18389))(SERVICE_NAME=ORCLCDB)(CONNECTION_ID=/VA/VRHGSFSQbai6Yzp+Cg==)) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.1)(PORT=47588)) * establish * ORCLCDB * 12514
</txt>
</msg>
<msg time='2025-04-01T07:44:07.495+00:00' org_id='oracle' comp_id='tnslsnr'
type='UNKNOWN' level='16' host_id='a148f323c4cf'
host_addr='192.168.100.104' pid='48703'>
<txt>TNS-12514: TNS:listener does not currently know of service requested in connect descriptor
</txt>
</msg>
<msg time='2025-04-01T07:44:07.506+00:00' org_id='oracle' comp_id='tnslsnr'
type='UNKNOWN' level='16' host_id='a148f323c4cf'
host_addr='192.168.100.104' pid='48703'>
<txt>01-APR-2025 07:44:07 * (CONNECT_DATA=(CID=(PROGRAM=DBeaver 23?3?3 ? Main)(HOST=__jdbc__)(USER=18389))(SERVICE_NAME=ORCLCDB)(CONNECTION_ID=/VA/VRHGSFSQbai6Yzp+Cg==)) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.1)(PORT=47604)) * establish * ORCLCDB * 12514
</txt>
</msg>
<msg time='2025-04-01T07:44:07.506+00:00' org_id='oracle' comp_id='tnslsnr'
type='UNKNOWN' level='16' host_id='a148f323c4cf'
host_addr='192.168.100.104' pid='48703'>
<txt>TNS-12514: TNS:listener does not currently know of service requested in connect descriptor
</txt>
</msg>
显示:TNS:listener does not currently know of service requested in connect descriptor客户端请求的服务名 ORCLCDB****未被监听器识别
再次查看监听器状态:

The listener supports no services意思是监听器当前没有识别到任何数据库服务?
为了验证,我修改listener对应/opt/oracle/product/19c/dbhome_1/network/admin/listener.ora配置文件强制绑定我客户端请求的数据库服务。

新增:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ORCLCDB) --服务名称
(ORACLE_HOME = /opt/oracle/product/19c/dbhome_1) --安装路径
(SID_NAME = ORCLCDB) --实例名称
)
)
停止lsnrctl stop后重启lsnrctl start:

dbeaver客户端尝试重连:

成功解决!
- 客户端无法连接Oracle服务,多半是监听器作祟,++优先使用lsnrctl status查看其状态,并多查看监听器日志文件。++