首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

监听器注册与ORA-12514 异常分析

2012-11-22 
监听器注册与ORA-12514 错误分析在Oracle data guard环境中,主库的alert.log文件出现ORA-12514: TNS:list

监听器注册与ORA-12514 错误分析

在Oracle data guard环境中,主库的alert.log文件出现"ORA-12514: TNS:listener does not currently know of service requested in connect descriptor"错误信息,导致主库上的日志无法传输到备库上,data guard数据同步不能实现。
这是一个最最基础的错误,在我们最初从客户端连接Oracle数据库时就可能碰到这个错误。
在主库上使用tnsping 这个oracle net服务别名,如下所示:

?

?
因为这个监听器的端口号不是1521,所以采用了静态注册方法。
我们也可以不修改listener.ora文件,而采用配置local_listener参数的方法,将这个实例动态注册到监听器。
在数据库实例上修改local_listener参数,如下所示:
alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.15.90)(PORT=1844))))';
修改之后,使用lsnrctl services检查监听器的服务状况,会发现有webdb注册进来,其状态是ready。发现该服务已经注册到监听器。

?

如果数据库实例不是OPEN状态,在lsnrctl services的结果中将没有webdb的服务。
在data guard环境下,即使使用local_listener做了动态注册设置,也不会生效的。因为备库实例根本就不是open状态。
从主库向备库传输日志是采用oracle net传输的,这样以来就带来比较隐蔽的ORA-12514错误,增加我们管理难度。
出现的错误信息如下类似:

Wed Nov  7 17:23:15 2012Destination LOG_ARCHIVE_DEST_2 is UNSYNCHRONIZED******************************************************************LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2******************************************************************LNSb started with pid=20, OS id=17139Error 12514 received logging on to the standbyWed Nov  7 17:23:22 2012LGWR: Error 12514 creating archivelog file 'webdb_standby'Wed Nov  7 17:23:22 2012Errors in file /u01/app/oratt/admin/webdb/bdump/webdb_lgwr_11220.trc:ORA-12514: TNS:listener does not currently know of service requested in connect descriptorLGWR: Failed to archive log 3 thread 1 sequence 36 (12514)Wed Nov  7 17:23:22 2012Thread 1 advanced to log sequence 36 (LGWR switch)  Current log# 3 seq# 36 mem# 0: /u01/app/oratt/webdb/redo03.log

?
在data guard的备库上,虽然我采用了动态注册,其实是不生效的。这点可以通过lsnrctl service去查证。只能采用静态注册,手工编辑listener.ora文件。


小结

?


通过对这个ORA-12514错误的分析和监听器工作原理一些介绍,以后在遇到这个错误时,我们应该先验证一下连接描述字符串中的service_name是不是不对,写错了还是服务器上监听器真的不能解析。
如果不能还不能解决,那么在客户端还有一种解决方法,就是将连接字符串中service_name修改为sid,直接从数据库实例进行连接。这是最传统的数据库访问方式。
使用service_name访问数据库的方式常常出现在Oracle RAC中,这是要使用它的负载均衡和透明故障切换功能。在很多JDBC数据库连接配置中,还是在坚持使用ip:sid:port方式连接数据库,这个方式的弊端经过此文你也了解一二了吧。

参考资料


以下是ORACLE官方文档对ORA-12514的描述:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

Cause: The listener received a request to establish a connection to a database or
other service. The connect descriptor received by the listener specified a service
name for a service (usually a database service) that either has not yet dynamically
registered with the listener or has not been statically configured for the listener.
This may be a temporary condition such as after the listener has started, but before
the database instance has registered with the listener.

Action:
- Wait a moment and try to connect a second time.
- Check which services are currently known by the listener by executing: lsnrctl
services <listener name>
- Check that the SERVICE_NAME parameter in the connect descriptor of the net
service name used specifies a service known by the listener.
- If an easy connect naming connect identifier was used, check that the service
name specified is a service known by the listener.
- Check for an event in the listener.log file.

热点排行