问题现象:
- TNS-12514: TNS:listener does not currently know of service requested in connect descriptor
复制代码
问题原因: ORA-12514错误通常是由以下原因之一造成的: 无效的服务名称:连接描述符中指定的服务名称不存在。例如,可能会发生拼写错误或者数据库实例名称更改而未及时更新连接描述符的情况。
监听程序未运行:如果Oracle数据库监听程序未运行,则无法连到数据库实例。此情况可能是由于监听程序未正确启动、网络连接故障或服务器故障等原因引起的。
解决办法: 针对ORA-12514错误,可以采取以下措施来解决问题: 检查连接描述符:确保连接描述符中指定的服务名称是正确的。如果服务名称发生变化,请更新连接描述符。例如下面两个连接,第一次失败,第二次成功,大家看看是什么问题呢? - oracle[url=home.php?mod=space&uid=1017351]@Yao[/url] ~$ sqlplus sys/yaoyuan@localhost/orc1 as sysdba
- SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 1 16:29:24 2023
- Version 19.3.0.0.0
- Copyright (c) 1982, 2019, Oracle. All rights reserved.
- ERROR:
- ORA-12514: TNS:listener does not currently know of service requested in connect
- descriptor
- Enter user-name:
- oracle@Yao ~$ sqlplus sys/yaoyuan@localhost/orcl as sysdba
- SQL*Plus: Release 19.0.0.0.0 - Production on Wed Mar 1 16:29:40 2023
- Version 19.3.0.0.0
- Copyright (c) 1982, 2019, Oracle. All rights reserved.
- Connected to:
- Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
- Version 19.3.0.0.0
复制代码仔细看看就明白了,原来服务名是orcl被错误的写成了orc1。当然在生产环境,大部分时候服务名是在tnsnames.ora文件中配置的:
- oracle[url=home.php?mod=space&uid=42428]@yaoyuan[/url] ~$ cat /u01/app/oracle/product/19.3.0/db_1/network/admin/tnsnames.ora
- ...
- ORCL =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracleace)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVICE_NAME = orc1)
- )
- )
复制代码
|