ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务
通过重启服务的方式启动数据库,再次连接却能成功登录,也就是说在关闭数据库状态下无法连接服务器。
开始以为是系统环境变量Oracle_SID的配置问题,因为机器有多个实例,一阵折腾后还是不能连接。后来查资料得知:
Oracle9i以后,后台进程PMON自动在监听器中注册在系统参数SERVICE_NAMES中定义的服务名,SERVICE_NAMES默认为DB_NAME+DOMAIN_NAME。监听配置文件listener.ora中可以不必指定监听的服务名。但是,当数据库处于关闭状态下PMON进程没有启动,也就不会自动注册监听的实例名,所以使用sqlplus sys/his@orc0 as sysdba 会出现ORA-12514错误。
如果在listener.ora文件中指定监听的实例名,则即使数据库处于关闭状态,仍然可以连接。
listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = G:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = ORCL)
(ORACLE_HOME = G:\oracle\product\10.2.0\db_1)
(SID_NAME = ORCL)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = zyk)(PORT = 1521))
)
)
以上粗体部件为增加的内容,修改后重启监听服务后即可。
附:通过在lsnrctl中输入set display verbose,然后再通过命令service查看,服务状态为READY表示PMON自动注册的服务名,而UNKNOWN则表示该服务是手工在LISTENER.ORA中配置的数据库服务。
服务器莫名其妙的报这个错,之前一直正常,从google获取解决方案,解决之,记录如下:
1. Open the ""<OracleHome>/network/admin/listener.ora" file in the host,and you will see:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
)
)
2. Add the following lines after the 7th line in the above
(SID_DESC =
(GLOBAL_DBNAME = ORACLE)
(ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
(SID_NAME = ORACLE)
)
3. At last the content of the file become to the following section:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = ORACLE)
(ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
(SID_NAME = ORACLE)
)
)
4. Save the file and restart the TNSListener service in the host. That's OK!