合 【故障处理】ORA-12545: Connect failed because target host or object does not exist
Tags: Oracle故障处理环境变量监听ORA-12545
故障环境介绍
项目 | source db |
---|---|
db 类型 | RAC |
db version | 11.2.0.3 |
db 存储 | ASM |
OS版本及kernel版本 | AIX 64位 6.1.0.0 |
故障发生现象及报错信息
同事过来找我说数据库不能连接,如下情况:
1 2 3 4 5 6 7 8 9 10 11 12 | cssp@ZFZHLHRDB1:/cssp$ sqlplus tacc/tacc SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 12 16:35:42 2016 Copyright (c) 1982, 2011, Oracle. All rights reserved. ERROR: ORA-12545: Connect failed because target host or object does not exist Enter user-name: ERROR: ORA-12545: Connect failed because target host or object does not exist |
注意:以上的连接方式采用了TWO_TASK这个环境变量,在Unix和Linux环境下,可以设置TWO_TASK环境变量,当用户连接数据库且没有指定服务名时,会自动利用TWO_TASK的设置作为环境变量连接数据库。有关这个环境变量的更多内容可以参考:http://blog.itpub.net/26736162/viewspace-2140246/
故障分析及解决过程
我采用了tnsping、用tnsnames连接和检查3大网络配置文件,都没有问题,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | cssp@ZFZHLHRDB1:/cssp$ tnsping oratacc1 TNS Ping Utility for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production on 12-AUG-2016 16:36:14 Copyright (c) 1997, 2011, Oracle. All rights reserved. Used parameter files: /oracle/app/oracle/product/11.2.0/db/network/admin/sqlnet.ora Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ZFtaccDB-scan)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 22.188.173.15)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 22.188.173.16)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = oratacc1))) OK (80 msec) cssp@ZFZHLHRDB1:/cssp$ sqlplus tacc/tacc@oratacc1 SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 12 16:36:25 2016 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> exit cssp@ZFZHLHRDB1:/cssp$ oerr ora 12545 12545, 00000, "Connect failed because target host or object does not exist" // *Cause: The address specified is not valid, or the program being // connected to does not exist. // *Action: Ensure the ADDRESS parameters have been entered correctly; the // most likely incorrect parameter is the node name. Ensure that the // executable for the server exists (perhaps "oracle" is missing.) // If the protocol is TCP/IP, edit the TNSNAMES.ORA file to change the // host name to a numeric IP address and try again. |
查看环境变量的设置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | cssp@ZFZHLHRDB1:/cssp$ more .profile #For CICS export CICS=/usr/lpp/cics #export LANG=zh_CN.UTF-8 export LANG=en_US #For ORACLE ORACLE_BASE=/oracle/app/oracle ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db TWO_TASK=oratacc1 ORACLE_SID=oratacc1 ORACLE_TERM=vt100 ORACLE_OWNER=oracle export ORACLE_BASE ORACLE_HOME ORACLE_SID ORACLE_TERM ORACLE_OWNER LD_LIBRARY_PATH=/oracle/app/oracle/product/11.2.0/db/lib:/oracle/app/oracle/product/11.2.0/db/lib32 #LD_LIBRARY_PATH=/oracle/app/oracle/product/11.2.0/db/lib32 #export LIBPATH=$LIBPATH:/oracle/app/oracle/product/11.2.0/db/lib NLS_LANG=American_America.ZHS16GBK ORA_NLS33=/oracle/app/oracle/product/11.2.0/db/nls/data export PATH=/usr/java5/bin:/cssp/jscs export PATH=$PATH:/oracle/app/oracle/product/11.2.0/db/OPatch:/oracle/app/oracle/product/11.2.0/db/bin:/bin:/usr/ccs/bin:/usr/bin/X11:/sharebkup/data/peij OPATCH_PLATFORM_ID=212 export LD_LIBRARY_PATH NLS_LANG ORA_NLS33 PATH TMP TMPDIR OPATCH_PLATFORM_ID export AIXTHREAD_SCOPE=S umask 022 export DBCA_RAW_CONFIG=/oracle/dbname_raw.conf export PS1='$LOGNAME@'`hostname`:'$PWD''$ ' export ORA_NL10=$ORACLE_HOME/nls/data set -o vi export EDITOR=vi export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK export NLS_DATE_FORMAT=YYYY-MM-DD export PATH=$PATH:/usr/vac/bin:/var/ifor:/usr/opt/ifor/ls/conf:/usr/lib/cobol/bin:/usr/lpp/cics/bin:/usr/lpp/cics/etc:/usr/lpp/dce/bin:/usr/lpp/mqm/bin:/usr/lpp/mqm/sa mp/bin:/usr/mqm/samp/bin:$HOME/bin:$ORACLE_HOME/bin:/csspd05u/test/bin:.:/usr/mqm/samp/bin export LIBPATH=/usr/mqm/lib:$ORACLE_HOME/lib32:$COBDIR/coblib:/usr/lib:/lib:/usr/lpp/cics/lib:/usr/lpp/encina/lib:/usr/lpp/dce/lib:. export NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lpp/cics/msg/%L/%N:/usr/lpp/nls/msg/en_US/%N:/usr/lpp/encina/msg/%L/%N:/usr/lpp/dce/lib/nls/msg/%L/%N #For cssp export JAVA_HOME=/usr/java5_64 export cssp_HOME=$HOME export CLASSPATH=/csspd05u/CF # PS1='[`hostname`:$LOGNAME:$PWD]' alias rm='rm -i' alias lf='ls -aF' alias l='ls -al' set -o vi |
可以看到上边的环境变量很乱,尤其PATH的配置有问题,所以我把这个部分的内容整理了一下,最后为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | umask 022 #For CICS export CICS=/usr/lpp/cics #export LANG=zh_CN.UTF-8 export LANG=en_US #For ORACLE export ORACLE_BASE=/oracle/app/oracle export ORACLE_HOME=/oracle/app/oracle/product/11.2.0/db export LD_LIBRARY_PATH=/oracle/app/oracle/product/11.2.0/db/lib:/oracle/app/oracle/product/11.2.0/db/lib32 export TWO_TASK=oratacc1 export ORACLE_SID=oratacc1 export ORACLE_TERM=vt100 export ORACLE_OWNER=oracle export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK export ORA_NLS33=/oracle/app/oracle/product/11.2.0/db/nls/data export OPATCH_PLATFORM_ID=212 export AIXTHREAD_SCOPE=S export DBCA_RAW_CONFIG=/oracle/dbname_raw.conf export PS1='$LOGNAME@'`hostname`:'$PWD''$ ' export ORA_NL10=$ORACLE_HOME/nls/data export EDITOR=vi export PATH=$PATH:/usr/java5/bin:/cssp/jscs export PATH=$PATH:/oracle/app/oracle/product/11.2.0/db/OPatch:/oracle/app/oracle/product/11.2.0/db/bin:/bin:/usr/ccs/bin:/usr/bin/X11:/sharebkup/data/peij export PATH=$PATH:/usr/vac/bin:/var/ifor:/usr/opt/ifor/ls/conf:/usr/lib/cobol/bin:/usr/lpp/cics/bin:/usr/lpp/cics/etc:/usr/lpp/dce/bin:/usr/lpp/mqm/bin:/usr/lpp/mqm/samp/bin:/usr/mqm/samp/bin:$HOME/bin:$ORACLE_HOME/bin:/csspd05u/test/bin:.:/usr/mqm/samp/bin export LIBPATH=/usr/mqm/lib:$ORACLE_HOME/lib32:$COBDIR/coblib:/usr/lib:/lib:/usr/lpp/cics/lib:/usr/lpp/encina/lib:/usr/lpp/dce/lib:. export NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lpp/cics/msg/%L/%N:/usr/lpp/nls/msg/en_US/%N:/usr/lpp/encina/msg/%L/%N:/usr/lpp/dce/lib/nls/msg/%L/%N #For cssp export JAVA_HOME=/usr/java5_64 export cssp_HOME=$HOME export CLASSPATH=/csspd05u/CF # PS1='[`hostname`:$LOGNAME:$PWD]' alias rm='rm -i' alias lf='ls -aF' alias l='ls -al' set -o vi |
修改.profile文件后,重新登录试试:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | cssp@ZFZHLHRDB1:/cssp$ . .profile cssp@ZFZHLHRDB1:/cssp$ sqlplus tacc/tacc SQL*Plus: Release 11.2.0.3.0 Production on Fri Aug 12 16:43:26 2016 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options |
可以正常登陆数据库了,可见环境变量的配置对sqlplus的登录有至关重要的作用。
案例2
问题背景:
用户在客户端服务器通过sqlplus通过scan ip登陆访问数据库时,偶尔会出现连接报错ORA-12545: Connect failed because target host or object does not exist的情况。
问题分析:
首先,登陆到连接有问题的客户端数据库上,通过sqlplus进行多次连接测试,的确会出现用户所说的ORA-12545: Connect failed because target host or object does not exist报错现象,此外,还发现登陆成功的节点显示的实例都是节点一实例servicedb1
检查数据库的listener_scan监听配置,服务servicedb下动态注册了(ready)两个实例servicedb1以及servicedb2,没有其他的配置实例