客户端连接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:appAdministratorproduct11.2.0dbhome_1NETWORKADMINlistener.ora
即:$ORACLE_HOME/network/admin
原监听文件lisener.ora配置如下:
# listener.ora Network Configuration File: D:appAdministratorproduct11.2.0dbhome_1 etworkadminlistener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = CLRExtProc) (ORACLE_HOME = D:appAdministratorproduct11.2.0dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:D:appAdministratorproduct11.2.0dbhome_1inoraclr11.dll") ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = WIN-VATV98IF527)(PORT = 1521)) ) ) ADR_BASE_LISTENER = D:appAdministrator
修改为
红色部分为添加内容,蓝色可修改为服务器的IP地址
注意:空格也要严格按照要求,否则会报语法错误
# listener.ora Network Configuration File: D:appAdministratorproduct11.2.0dbhome_1 etworkadminlistener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = CLRExtProc) (ORACLE_HOME = D:appAdministratorproduct11.2.0dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:D:appAdministratorproduct11.2.0dbhome_1inoraclr11.dll") ) (SID_DESC = (GLOBAL_DBNAME = ORCL) (ORACLE_HOME = D:appAdministratorproduct11.2.0dbhome_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:appAdministrator
停止监听服务:
C:UsersAdministrator>lsnrctl stop
C:UsersAdministrator>lsnrctl stop LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 11-8月 -2019 16:0 5:36 Copyright (c) 1991, 2010, Oracle. All rights reserved. 正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) 命令执行成功
启动监听服务:
C:UsersAdministrator>lsnrctl start
C:UsersAdministrator>lsnrctl start LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 11-8月 -2019 16:0 5:40 Copyright (c) 1991, 2010, Oracle. All rights reserved. 启动tnslsnr: 请稍候... TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production 系统参数文件为D:appAdministratorproduct11.2.0dbhome_1 etworkadminlistene r.ora 写入d:appadministratordiag nslsnrWIN-VATV98IF527listeneralertlog.xml的日 志信息 监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\.pipeEXTPROC1521ipc))) 监听: (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:appAdministratorproduct11.2.0dbhome_1 etworka dminlistener.ora 监听程序日志文件 d:appadministratordiag nslsnrWIN-VATV98IF527list eneralertlog.xml 监听端点概要... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\.pipeEXTPROC1521ipc))) (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