问题解决了,但是还是很疑惑。是/etc/netsvc.conf的权限问题。将664 改成600后问题解决。 不过很想不通,就是说664;netsvc.conf没有生效,修改后生效了,不过netsvc.conf 的内容就只去查/etc/hosts,反而能通。 真不明白是怎么个机制。[dbprod1][root]/etc> sed 's/^#.*$//' /etc/netsvc.conf |grep -v "^$" hosts=local[dbprod2][root]/> ls -lrt /etc/net* -rw-rw-r-- 1 root system 4548 Jan 14 18:34 /etc/netsvc.conf [dbprod2][root]/> su - oracle [dbprod2][oracle]/home/oracle> . wang_env [dbprod2][oracle]/home/oracle> sqlplus wang/tian@inprodSQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 8 12:48:17 2015Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing optionsSQL> select count(*) from user_tables@toinrac; select count(*) from user_tables@toinrac * ERROR at line 1: ORA-12545: Connect failed because target host or object does not exist SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options [dbprod2][oracle]/home/oracle> id uid=1101(oracle) gid=1000(oinstall) [dbprod2][oracle]/home/oracle> exit [dbprod2][root]/> chmod 600 /etc/net* [dbprod2][root]/> ls -lrt /etc/net* -rw------- 1 root system 4548 Jan 14 18:34 /etc/netsvc.conf [dbprod2][root]/> su - oracle [dbprod2][oracle]/home/oracle> . wang_env [dbprod2][oracle]/home/oracle> sqlplus wang/tian@inprodSQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 8 12:48:54 2015Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing optionsSQL> select count(*) from user_tables@toinrac; COUNT(*) ---------- 44SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options
原因找到了,应该是这样的, 当配置NSORDER环境变量,登入sqlplus时,使用的是环境变量的参数。因此能正确解析域名;当时登入后,使用databaselink时,应该是去使用系统的配置/etc/netsvc.conf, 而系统配置中只指定了local,因此系统无法识别域名。 [dbprod1][oracle]/home/oracle> export NSORDER=local,bind,nis [dbprod1][oracle]/home/oracle> sqlplus wang/tian@inprod SQL*Plus: Release 11.2.0.4.0 Production on Mon Mar 9 08:34:12 2015Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing optionsSQL> select count(*) from user_tables@toinrac; select count(*) from user_tables@toinrac * ERROR at line 1: ORA-12545: Connect failed because target host or object does not exist当修改/etc/netsvc.conf 权限到600,这样系统就不认这个配置了,跳过netsvc.conf配置,直接使用默认的配置,dns,local,nis,因此访问可以成功。正确的搞法是/etc/netsvc.conf的权限应该配置成644,这样系统采用netsvc.conf中的内容。修改内容为hosts=local,bind ,问题解决
加到 /etc/hosts中是可以,可是只是规避方式,另外tnsnames.ora很多节点,而且/etc/hosts一个域名只能解析一个IP地址吧,不能解析SCAN的三个地址吧。 想知道为啥就不去dns找了?
不过很想不通,就是说664;netsvc.conf没有生效,修改后生效了,不过netsvc.conf 的内容就只去查/etc/hosts,反而能通。 真不明白是怎么个机制。[dbprod1][root]/etc> sed 's/^#.*$//' /etc/netsvc.conf |grep -v "^$"
hosts=local[dbprod2][root]/> ls -lrt /etc/net*
-rw-rw-r-- 1 root system 4548 Jan 14 18:34 /etc/netsvc.conf
[dbprod2][root]/> su - oracle
[dbprod2][oracle]/home/oracle> . wang_env
[dbprod2][oracle]/home/oracle> sqlplus wang/tian@inprodSQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 8 12:48:17 2015Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing optionsSQL> select count(*) from user_tables@toinrac;
select count(*) from user_tables@toinrac
*
ERROR at line 1:
ORA-12545: Connect failed because target host or object does not exist
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
[dbprod2][oracle]/home/oracle> id
uid=1101(oracle) gid=1000(oinstall)
[dbprod2][oracle]/home/oracle> exit
[dbprod2][root]/> chmod 600 /etc/net*
[dbprod2][root]/> ls -lrt /etc/net*
-rw------- 1 root system 4548 Jan 14 18:34 /etc/netsvc.conf
[dbprod2][root]/> su - oracle
[dbprod2][oracle]/home/oracle> . wang_env
[dbprod2][oracle]/home/oracle> sqlplus wang/tian@inprodSQL*Plus: Release 11.2.0.4.0 Production on Sun Mar 8 12:48:54 2015Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing optionsSQL> select count(*) from user_tables@toinrac; COUNT(*)
----------
44SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
对于这个,我们习惯性的,有专有的DNS服务器去解析
当配置NSORDER环境变量,登入sqlplus时,使用的是环境变量的参数。因此能正确解析域名;当时登入后,使用databaselink时,应该是去使用系统的配置/etc/netsvc.conf,
而系统配置中只指定了local,因此系统无法识别域名。
[dbprod1][oracle]/home/oracle> export NSORDER=local,bind,nis
[dbprod1][oracle]/home/oracle> sqlplus wang/tian@inprod SQL*Plus: Release 11.2.0.4.0 Production on Mon Mar 9 08:34:12 2015Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing optionsSQL> select count(*) from user_tables@toinrac;
select count(*) from user_tables@toinrac
*
ERROR at line 1:
ORA-12545: Connect failed because target host or object does not exist当修改/etc/netsvc.conf 权限到600,这样系统就不认这个配置了,跳过netsvc.conf配置,直接使用默认的配置,dns,local,nis,因此访问可以成功。正确的搞法是/etc/netsvc.conf的权限应该配置成644,这样系统采用netsvc.conf中的内容。修改内容为hosts=local,bind ,问题解决