From: http://zxf261.blog.51cto.com/701797/750308
今天碰到了一个有趣的问题
oracle用户可以tnsping通,普通用户tnsping报错
用普通用户tnsping数据库的时候报
TNS-03505: Failed to resolve name
而用oracle用户tnsping数据库的时候却可以ping通
<34 linux-sit:/home/smsds>tnsping orarpt
TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 24-DEC-2011 15:33:18
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
/home/oracle/product/11.1.0/db_1/network/admin/sqlnet.ora
TNS-03505: Failed to resolve name
oracle@linux-sit:~/product/11.1.0/db_1/network/admin> tnsping orarpt
TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 24-DEC-2011 15:35:42
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
/home/oracle/product/11.1.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.39)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orarpt)))
OK (0 msec)
到底是什么原因呢,查看了tnsnames.ora发现也没问题
oracle@linux-sit:~/product/11.1.0/db_1/network/admin> more tnsnames.ora
# tnsnames.ora Network Configuration File: /home/oracle/product/11.1.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
orarpt =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.39)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orarpt)
)
)
查看下文件权限,发现问题在这,tnsnames.ora的权限有问题
oracle@linux-sit:~/product/11.1.0/db_1/network/admin> ll
total 16
-rw-r--r-- 1 oracle oinstall 335 2011-12-22 15:58 listener.ora
drwxr-xr-x 2 oracle oinstall 144 2011-12-22 15:18 samples
-rw-r--r-- 1 oracle oinstall 187 2007-05-07 23:03 shrept.lst
-rw-r--r-- 1 oracle oinstall 188 2011-12-22 15:58 sqlnet.ora
-rw-r----- 1 oracle oinstall 328 2011-12-24 15:21 tnsnames.ora
修改试试chmod 644 tnsnames.ora(将tnsnames.ora的权限改成其他用户可以读)
再用普通用户tnsping一下,问题解决
<34 linux-sit:/home/smsds>tnsping orarpt
TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 24-DEC-2011 17:11:50
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
/home/oracle/product/11.1.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.39)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orarpt)))
OK (0 msec)