当前位置:数据库 > Oracle >>

【Oracle问题集3】ORA-12543: TNS:destination host unreachable

【Oracle问题集3】ORA-12543: TNS:destination host unreachable
 
说明:【oracle问题集】是博主平时操作数据库遇到的问题以及解决方案。
执行语句:表示操作数据库过程
出错现象:表示操作数据库过程出现错误现象
出错原因:表示出现错误的原因
解决方法:表示解决错误的方法
相关知识:表示与这个主题相关的知识
====================================================================
执行语句:
连接数据库:connect sys/oracle@192.168.135.243/orcl as sysdba
出错现象:
       ORA-12543: TNS:destination host unreachable
错误原因:
sqlnet.ora文件中的NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT),添加ezconnect参数值,所以如果指定数据库实例,必须要跟上主机ip地址。请参考【Easy Connect Naming】。因此正确的写法是:CONNECT username/password@host[:port][/service_name]
例如connect sys/oracle@192.168.135.243/orcl as sysdba
解决方法:
连接数据库时需要指定主机ip地址:connect sys/orcl@192.168.135.243/orcl as sysdba
相关知识:
              以下知识来源于oracle官方文档
Naming Method Description
Local Naming
Resolves a net service name stored in a tnsnames.ora file stored on a client
Local naming is most appropriate for 易做图 distributed networks with a small number of services that change infrequently.
See Also: "Configuring the Local Naming Method"
Directory Naming
Resolves a database service name, net service name, or net service alias stored in a centralized LDAP-compliant directory server
See Also: "Configuring the Directory Naming Method"
Easy Connect Naming
Enables clients to connect to a database server without any configuration. Clients use a connect string for a 易做图 TCP/IP address, consisting of a host name and optional port and service name:
CONNECT username/password@host[:port][/service_name]
This method is recommended for 易做图 TCP/IP environments.
See Also: "Using the Easy Connect Naming Method"
External Naming
Resolves service information stored in an a third-party naming service
See Also: "Configuring External Naming Methods"
相关监听配置测试工具命令:lnsrctl、tnsping
 
listener.ora文件内容:
# listener.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
     (SID_NAME=orcl)
     (ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1)
    )
   )
 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.135.243)(PORT = 1521))
    )
  )
ADR_BASE_LISTENER = /home/oracle/app/oracle
 
tnsnames.ora文件内容
# tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.135.243)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.192.168.132.243)
    )
  )
 
sqlnet.ora
# sqlnet.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
ADR_BASE = /home/oracle/app/oracle
 
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,