今天工作碰到的问题,baidu出来的答案,记录下
=======================================================
有TX发现使用tnsping一个tnsname错误,提示TNS-12532: TNS:invalid argument或TNS-03505: Failed to resolve name的错误,比如:
[oracle@gwsr-1 oracle]$ tnsping 232
TNS Ping Utility for Linux: Version 9.2.0.1.0 - Production on 21-FEB-2008 15:15:45
Copyright (c) 1997 Oracle Corporation. All rights reserved.
Used parameter files:
/home/oracle/product/9.2.0/network/admin/sqlnet.ora
Used HOSTNAME adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SID=*)(SERVICE_NAME=232.))(ADDRESS=(PROTOCOL=TCP)(HOST=232)(PORT=1521)))
TNS-12532: TNS:invalid argument
[oracle@gwsr-1 admin]$ tnsping 232s
TNS Ping Utility for Linux: Version 9.2.0.1.0 - Production on 21-FEB-2008 15:36:22
Copyright (c) 1997 Oracle Corporation. All rights reserved.
Used parameter files:
/home/oracle/product/9.2.0/network/admin/sqlnet.ora
TNS-03505: Failed to resolve name
tns配置为:
232 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.199.38.232)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
修改SERVICE_NAME为SID和去掉(SERVER = DEDICATED)都不能解决问题
但是,在tnsping的最后加上一个点‘.’却能成功检测——
[oracle@gwsr-1 oracle]$ tnsping 232.
TNS Ping Utility for Linux: Version 9.2.0.1.0 - Production on 21-FEB-2008 15:15:51
Copyright (c) 1997 Oracle Corporation. All rights reserved.
Used parameter files:
/home/oracle/product/9.2.0/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.199.38.232)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
OK (0 msec)
后检查sqlnet.ora,内容如下:
[oracle@gwsr-1 admin]$ more sqlnet.ora
# SQLNET.ORA Network Configuration File: /home/oracle/product/9.2.0/network/admi
n/sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DEFAULT_DOMAIN = localdomain
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)
一般是不用到NAMES.DEFAULT_DOMAIN这个配置的,oracle对这个参数的定义为:
NAMES.DEFAULT_DOMAIN
Indicates the domain name space from which the client most often requests an Oracle Names server. When set, this name is automatically appended to any unqualified name in an Oracle Names request. Oracle Net sets the default domain to NULL by default.
当设置这个参数的时候,就会自动将这个名字添加到输入的tnsname后面。
如果,当设置为localdomain的时候,在tnsping的时候出现错误,而加了.后分隔了后面增加的默认域名,也就能成功检测了吧