oracle的网络连接

NAMES.DIRECTORY_PATH常用的值有tnsnames,hostname,onames和ezconnect

ldap,cds,nis不常用的值,默认值是(tnsnames,onames,hostname)

如果设置NAMES.DIRECTORY_PATH=(tnsnames),那么客户端就只会从tnsnames.ora查找你要连接的字符串(如orcl)记录,

如果tnsname.ora文件中没有此记录,则连接不上数据库。

 

如果设置NAMES.DIRECTORY_PATH=(tnsnames,hostname),那么客户端首先会从tnsnames.ora查找你要连接的字符串(如orcl)记录,

如果tnsname.ora文件中没有此记录,则尝试把你要连接的字符串(如orcl)当作一个主机名,通过网络的途径去解析它的ip地址,然后去连接

这个ip上GLOBAL_DBNAME=连接字符串(如orcl)这个实例,当然这里连接字符串(如orcl)并不是一个主机名,最后会尝试以ezconnect的方式连接

数据库。

[oracle@class191 admin]$ sqlplus sys/[email protected]:1521/orcl.com as sysdba
                                                                               
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 8 08:56:20 2020

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> 

[oracle@class191 admin]$ sqlplus sys/oracle@orcl_net as sysdba                                           网络服务名         

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 8 08:55:48 2020

Copyright (c) 1982, 2009, Oracle. All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> !more tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/product/11.2/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL_NET =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.191)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl.com)  #全局服务名或全局数据库名
(SID=orcl)   #数据库的实例名         
)
)


SQL>

 
  

 

你可能感兴趣的:(oracle的网络连接)