ITPub博客

首页 > Linux操作系统 > Linux操作系统 > listener.ora文件与tnsnames.ora之间的关系

listener.ora文件与tnsnames.ora之间的关系

原创 Linux操作系统 作者:paulyibinyi 时间:2007-12-18 09:31:06 0 删除 编辑

listener.ora 文件里面的内容如下:

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = d10063)(PORT = 1521))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
      )
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = D:\oracle\ora92)
      (PROGRAM = extproc)
      (GLOBAL_DBNAME = gsid)
      (ORACLE_HOME = D:\oracle\ora92)
      (SID_NAME = paul)
      (GLOBAL_DBNAME = paul)
      (ORACLE_HOME = D:\oracle\ora92)
      (SID_NAME = paul)
    )
  )

tnsnames.ora文件内容如下:

PAUL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.163)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = paul)
    )
  )

PRIMARY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.163)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = gsid)
    )
  )

SQL> show parameter service_names

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------
service_names                        string      gsid, paul,paultest

由以上可知道  监听器提供静态和动态注册服务名

而tnsnames.ora文件 根据服务名进行客户端连接

而primary这些是连接字符串

 

C:\Documents and Settings\Paul Yi>lsnrctl status

LSNRCTL for 32-bit Windows: Version 9.2.0.4.0 - Production on 18-DEC-2007 09:47:
21

Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=d10063)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version 9.2.0.4.0 - Produc
tion
Start Date                18-DEC-2007 09:40:34
Uptime                    0 days 0 hr. 6 min. 46 sec
Trace Level               off
Security                  OFF
SNMP                      OFF
Listener Parameter File   D:\oracle\ora92\network\admin\listener.ora
Listener Log File         D:\oracle\ora92\network\log\listener1.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=d10063.avocado.local)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC0ipc)))
Services Summary...
Service "gsid" has 2 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
  Instance "paul", status READY, has 1 handler(s) for this service...
Service "paul" has 1 instance(s).
  Instance "paul", status READY, has 1 handler(s) for this service...
Service "paultest" has 1 instance(s).
  Instance "paul", status READY, has 1 handler(s) for this service...
The command completed successfully

从lsnrctl status 处可以看出

初始化参数设置:instance_name=paul service_names=paul,gsid ,paultest

所以动态注册时也会对外提供三个服务:paul和gsid ,paultest

C:\Documents and Settings\Paul Yi>tnsping primary

TNS Ping Utility for 32-bit Windows: Version 9.2.0.4.0 - Production on 18-DEC-20
07 09:50:59

Copyright (c) 1997 Oracle Corporation.  All rights reserved.

Used parameter files:
D:\oracle\ora92\network\admin\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.1.163)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = gsid)))
OK (0 msec)

所以综上所述:instance_name只有唯一的一个名称,而service_name可以有多个用于tnsnames.ora客户端连接

连接字符串也可以随意取名

对于客户端来说,它不用关心数据库的名字、实例名到底是什么,它只需要知道数据库对外提供的服务名就行了,这个名字可能和实例名一样,也可能不一样。

 

 

 

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7199859/viewspace-783/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
oracle 10g ocm oracle 10g/11g/12c ocp aix 6.1 administrator,ogg expert,ITSS 技术交流群 201703254 微信公众号 paulyibin 探讨技术,开心工作 电话 13719354869 ,深入研究数据库和开始研究big data

注册时间:2007-12-11

  • 博文量
    905
  • 访问量
    6490697