【轉】ORACLE TNSING報錯(TNS-03505)的解決

東北胖子發表於2013-04-22
    一大早來上班,就有同事告訴我某省的資料庫監聽有問題。趕快檢查了一下,發現其實是前端主機重啟後沒有啟動完全應用造成了一些錯誤和資料庫監聽沒有關係的。
         至於為什麼同事會懷疑到資料庫監聽我也感到很怪異。
         檢查沒有問題後,還是不放心,於是就利用tnsping進行測試:
       
[oracle@localhost ~]$ tnsping 211.1XX.XX.XX

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 10-DEC-2008 09:45:50

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

Used parameter files:
/home/oracle/product/10.2/network/admin/sqlnet.ora

TNS-03505: Failed to resolve name

      顯然sqlnet.ora檔案中的連線控制引數有些問題,檢查下:

[oracle@localhost ~]$ more /home/oracle/product/10.2/network/admin/sqlnet.ora
# sqlnet.ora Network Configuration File: /home/oracle/product/10.2/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.

NAMES.DIRECTORY_PATH= (TNSNAMES)

#SQLNET.AUTHENTICATION_SERVICES= (NTS)

#NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

        引數NAMES.DIRECTORY_PATH只有一個TNSNAMES,看看官方文件的介紹:
tnsnames:local naming naming method
Set to resolve a net service name through the tnsnames.ora file on the client.


ldap:directory naming naming method
Set to resolve a database service name, net service name, or net service alias through a directory server.


onames:Oracle Names method
Set to resolve database objects through a Oracle Names server.


hostname:host naming method
Set to resolve a host name alias through an existing names resolution service or a centrally-maintained set of /etc/hosts files.


cds:Cell Directory Services (CDS) external naming method
Set to resolve an Oracle database name in a Distributed Computing Environment (DCE) environment.


nis:Network Information Service (NIS) external naming method
Set to resolve service information through an existing NIS.
       
        應該有六個引數的,於是增加一個hostname引數。再次進行連線即告成功。
[oracle@localhost ~]$ tnsping 2XX.1XX.2XX.XX

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 10-DEC-2008 09:56:52

Copyright (c) 1997, 2005, Oracle.    All rights reserved.

Used parameter files:
/home/oracle/product/10.2/network/admin/sqlnet.ora

Used HOSTNAME adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=211.139.222.155))(ADDRESS=(PROTOCOL=TCP)(HOST=211.139.222.155)(PORT=1521)))
OK (70 msec)

        BTW:

      其實這個引數的default值Default
      NAMES.DIRECTORY_PATH=(tnsnames, onames, hostname)

        應經可以滿足基本的要求了。-:)

 
我只是加了一個hostname,沒有加onames
 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/2317695/viewspace-759004/,如需轉載,請註明出處,否則將追究法律責任。

相關文章