脚本语言,Oracle数据库集群,软件测试,开源软件

[Oracle] 与连接相关的概念

上一篇 / 下一篇  2007-12-01 23:52:24 / 个人分类:Oracle

数据库服务 service
An Oracle database is represented to clients as a service; that is, the database performs work on behalf of clients. A database can have one or more services associated with it.

连接描述符 connect descrīptor
To connect to a database service, clients use a connect descrīptor that provides the location of the database and the name of the database service.

监听器 listener
The address portion of the connect descrīptor is actually the protocol address of the listener.

协议地址 protocol address
Much like a business address, the listener is configured to accept requests from clients at a protocol address. This address defines the protocol the listener is listening on and any other protocol specific information.

For some configurations, such as Oracle Real Application Clusters, multiple listeners on multiple nodes can be configured to handle client connection requests for the same database service.

一个4节点10gR2 RAC环境下的连接描述符的例子(来自$ORACLE_HOME/network/admin/tnsnames.ora文件):

  (DEscrīptION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = aif05-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aif06-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aif14-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aig06-vip)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = rac)
    )
  )

那么,就上面的实例来说,其中的

    (ADDRESS = (PROTOCOL = TCP)(HOST = aif05-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aif06-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aif14-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aig06-vip)(PORT = 1521))

就是4个监听器的协议地址。而(SERVICE_NAME = rac)中的“rac”就是数据库服务的名字。因而通过连接这4个节点的4个不同的监听器,客户端连接请求都可以顺利连接到同一个数据库服务“rac”上。

连接字符串 connect string
连接标识符 connect identifier
网络服务名 net service name
Users initiate a connection request by providing a connect string. A connect string
includes a username and password, along with a connect identifier. A connect identifier can be the connect descrīptor itself or a name that resolves to a connect descrīptor. One of the most common connect identifiers is a net service name, a simple name for a service.

那么完整的连接字符串的实例是:

scott/tiger@(DEscrīptION=(ADDRESS=(PROTOCOL=tcp)(HOST=sales-server1)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=sales.us.acme.com)))

需要注意的是“@”符号以后的部分(即连接标识符)一定要在同一行上。

同样来自上文提到的同一个RAC的网络服务名的例子(取自文件$ORACLE_HOME/network/admin/tnsnames.ora):

RAC =
  (DE
scrīptION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = aif05-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aif06-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aif14-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aig06-vip)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = rac)
    )
  )

其中等号左边的“RAC”就是网络服务名,而等号右边的就是上文提到的连接描述符。而所谓的连接标识符则要么是“RAC”,要么是等号右边的连接描述符。

在实践中这两者的效用是一致,可以通过下面的方法使用SQL*Plus来简单测试一下。

第一种连接方法利用网络服务名:

sqlplus scott/tiger@RAC

第二种连接方法利用连接描述符:

sqlplus scott/tiger@(DEscrīptION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = aif05-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aif06-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aif14-vip)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = aig06-vip)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = rac)
    )
  )











TAG: Oracle

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-10-12  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 9177
  • 日志数: 34
  • 图片数: 2
  • 建立时间: 2006-12-27
  • 更新时间: 2008-01-05

RSS订阅

Open Toolbar