database - 使用 SID 作为服务名称的 Oracle 数据库
问题描述
我正在处理的应用程序使用服务名称连接到数据库。预期的格式是<SID>.<domain>
. 但是,应用程序无法使用它作为服务名称连接到数据库。
该服务器上运行着 9 个数据库。我可以使用该格式的服务名称(通过应用程序或 SQL 开发人员)连接到所有其他数据库。出于某种原因,我可以仅使用 SID 作为服务名称来连接到这个服务名称——但不能使用域。
从下面的 tns 侦听器状态可以看出,它仅使用此数据库的 SID 作为服务名称。我还应该说,我查看用于比较的两个数据库的 pfile 具有相同的值。
listener.ora
:
<...>
LISTENER_<this sid> =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=<hostname>.<domain>)(PORT=1521)))
SID_LIST_LISTENER_KS=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=<this sid>.<domain>)
(SID_NAME=<this sid>)
(ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1)
)
)
LISTENER_<other sid> =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=<hostname>.<domain>)(PORT=1521)))
SID_LIST_LISTENER_KS=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=<other sid>.<domain>)
(SID_NAME=<other sid>)
(ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1)
)
)
<...>
tnsnames.ora
:
<...>
<this sid> =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = <hostname>.<domain>)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = <this sid>.<domain>)))
<other sid> =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = <hostname>.<domain>)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = <other sid>.<domain>)))
<...>
tns 监听器状态:
$ lsnrctl status
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 07-MAR-2019 10:24:48
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 07-MAR-2019 08:46:13
Uptime 0 days 1 hr. 38 min. 35 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/<hostname>/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=<hostname>.<domain>)(PORT=1521)))
Services Summary...
<...>
Service "<this sid>" has 1 instance(s).
Instance "<this sid>", status READY, has 1 handler(s) for this service...
Service "<this sid>XDB" has 1 instance(s).
Instance "<this sid>", status READY, has 1 handler(s) for this service...
Service "<other sid>.<domain>" has 1 instance(s).
Instance "<other sid>", status READY, has 1 handler(s) for this service...
Service "<other sid>XDB.<domain>" has 1 instance(s).
Instance "<other sid>", status READY, has 1 handler(s) for this service...
<...>
The command completed successfully
当我使用<sid>.<domain>
as 服务名称时出现错误消息:
Status : Failure -Test failed: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
解决方案
检查 db_name,db_domain 并从 global_name 中选择 global_name;
推荐阅读
- python - 将数据框/CSV 中的批量数据插入或更新到 PostgreSQL 数据库
- java - Java将私有函数移入setter
- r - R中的并排箱线图
- spring-boot - Spring Boot 函数栈上下文
- python - 将对象列表写入 JSON 文件
- python - 遍历日期范围并对值求和
- spring - 为什么 Spring Integration QueueChannel 与 kafka 中的延迟传递消息顺序运行
- c - 从不兼容的指针类型传递 fwrite 的参数 4
- azure-cosmosdb - 如何知道分区键在 Cosmos DB 中是否正常工作
- ios - 集合视图:UIViewRepresentable + NavigationView