客户端连接oracle数据库时出现如下错误:
Listener refused the connection with the following error: ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
首先看看Oracle服务是否开启:
然后找到listener.ora监听文件,具体位置:D:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora
即:$ORACLE_HOME/network/admin
原监听文件lisener.ora配置如下:
# listener.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora # Generated by Oracle configuration tools.SID_LIST_LISTENER =(SID_LIST =(SID_DESC =(SID_NAME = CLRExtProc)(ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)(PROGRAM = extproc)(ENVS = "EXTPROC_DLLS=ONLY:D:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")))LISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))(ADDRESS = (PROTOCOL = TCP)(HOST = WIN-VATV98IF527)(PORT = 1521))))ADR_BASE_LISTENER = D:\app\Administrator
修改为
红色部分为添加内容,蓝色可修改为服务器的IP地址
注意:空格也要严格按照要求,否则会报语法错误
# listener.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora # Generated by Oracle configuration tools.SID_LIST_LISTENER =(SID_LIST =(SID_DESC =(SID_NAME = CLRExtProc)(ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)(PROGRAM = extproc)(ENVS = "EXTPROC_DLLS=ONLY:D:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")) (SID_DESC =(GLOBAL_DBNAME = ORCL)(ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1)(SID_NAME = ORCL)))LISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))(ADDRESS = (PROTOCOL = TCP)(HOST = WIN-VATV98IF527)(PORT = 1521))))ADR_BASE_LISTENER = D:\app\Administrator
停止监听服务:
C:\Users\Administrator>lsnrctl stop
C:\Users\Administrator>lsnrctl stopLSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 11-8月 -2019 16:0 5:36Copyright (c) 1991, 2010, Oracle. All rights reserved.正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) 命令执行成功
启动监听服务:
C:\Users\Administrator>lsnrctl start
C:\Users\Administrator>lsnrctl startLSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 11-8月 -2019 16:0 5:40Copyright (c) 1991, 2010, Oracle. All rights reserved.启动tnslsnr: 请稍候...TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production 系统参数文件为D:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listene r.ora 写入d:\app\administrator\diag\tnslsnr\WIN-VATV98IF527\listener\alert\log.xml的日 志信息 监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc))) 监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=WIN-VATV98IF527)(PORT=1521)))正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) LISTENER 的 STATUS ------------------------ 别名 LISTENER 版本 TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Produ ction 启动日期 11-8月 -2019 16:05:43 正常运行时间 0 天 0 小时 0 分 3 秒 跟踪级别 off 安全性 ON: Local OS Authentication SNMP OFF 监听程序参数文件 D:\app\Administrator\product\11.2.0\dbhome_1\network\a dmin\listener.ora 监听程序日志文件 d:\app\administrator\diag\tnslsnr\WIN-VATV98IF527\list ener\alert\log.xml 监听端点概要...(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=WIN-VATV98IF527)(PORT=1521))) 服务摘要.. 服务 "CLRExtProc" 包含 1 个实例。实例 "CLRExtProc", 状态 UNKNOWN, 包含此服务的 1 个处理程序... 服务 "ORCL" 包含 1 个实例。实例 "ORCL", 状态 UNKNOWN, 包含此服务的 1 个处理程序... 命令执行成功
参考博客:
Oracle 11g ORA-12514:TNS:监听程序当前无法识别连接描述符中请求的服务
https://blog.csdn.net/zl570932980/article/details/77864157