ORACLE监听配置和数据库连接问题[ORA-12154]的解决

本文探讨了Oracle数据库中常见的12154错误及其解决方案,重点介绍了如何正确配置TNSNAMES.ORA文件和服务名设置,避免因HOST配置不当导致的连接失败问题。
    当我们安装并新建数据库的时候,往往都会需要配置监听(LISTENER),但有时我们会碰到数据库无法连接的情况。其中一个经典的错误就是:
    12154, 00000, "TNS:could not resolve service name"
// *Cause:  The service name specified is not defined correctly in the
// TNSNAMES.ORA file.
// *Action:  Make the following checks and correct the error:
//           - Verify that a TNSNAMES.ORA file exists and is in the proper
//             place and accessible. See the operating system specific manual
//             for details on the required name and location.
//           - Check to see that the service name exists in one of the
//             TNSNAMES.ORA files and add it if necessary.
//           - Make sure there are no syntax errors anywhere in the file.
//             Particularly look for unmatched parentheses or stray characters.
//             Any error in a TNSNAMES.ORA file makes it unusable. See
//             Chapter 4 in the SQL*Net V2 Administrator's Guide. If
//             possible, regenerate the configuration files using the Oracle
//             Network Manager.
    我们一般都是先检查CLIENT端的配置是否出现问题。如果我们检测客户端没有问题,就需要考虑SERVER端LISTENER的配置了。
    以下为一个LISTENER.ORA的例子:
    LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
      )
    )
  )
   或
   LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.100)(PORT = 1521))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
      )
    )
  )
   这两个配置在大多数情况下是没有问题的,但是一旦当网络情况复杂的时候,我们的连接就无法进行了。
    我曾处理过这样的一些情况,象对于使用***或者防火墙进行地址映射进行连接等情况,这样的配置就有可能出现问题。
    原因就在于HOST的配置。localhost.localdomain或者192.168.11.100的配置都会造成LISTENER只是监听指定的IP地址,而复杂的网络环境或者是数据库主机修改IP地址等都会直接造成IP变化而无法正常监听连接要求。所以还是非常建议使用主机名称的方式。例如:HOST=XXDB1,这样就会减少12154出错的可能了。

    附赠:当然在LINUX环境下,IPTABLES会自动开启,便会造成12533的错误出现。
    12533, 00000, "TNS:illegal ADDRESS parameters"
// *Cause: An illegal set of protocol adapter parameters was specified. In
// some cases, this error is returned when a connection cannot be made to the
// protocol transport.
// *Action: Verify that the destination can be reached using the specified
// protocol. Check the parameters within the ADDRESS section of
// TNSNAMES.ORA.  Legal ADDRESS parameter formats may be found in the
// Oracle operating system specific documentation for your platform.
// Protocols that resolve names at the transport layer (such as DECnet object
// names) are vulnerable to this error if not properly configured or names are
// misspelled.
   如果可以设定IPTABLES最好,当情急之下,还是一关了之来的痛快 :-)
   1) 即时生效,重启后失效
   开启: service iptables start
   关闭: service iptables stop

   2) 重启后生效
   开启: chkconfig iptables on
   关闭: chkconfig iptables off

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值