ITPub博客

首页 > 数据库 > Oracle > 【监听】tnsname.ora文件理解

【监听】tnsname.ora文件理解

Oracle 作者:bitifi 时间:2015-11-30 11:28:09 0 删除 编辑

tnsnames.ora文件说明,类似host文件,客户端不需要知道数据库名和实例名,只需要知道该数据库对外提供的服务名(RAC环境下服务名下面还可以增加一个INSTANCE_NAME子配置选项)或SID就可以申请连接到数据库

 

TNSNAMES.ORA中配置service_name和配置sid都可以,但是sqlplus必须使用service_name

 

 

TNSNAMES.ORASERVICE_NAMESID的区别

SID只指定一个实例,而SERVICE_NAMERAC环境中指定多个实例。

如果配置RAC的某一台机器就配置SID,如果配置负载均衡则配置service_name,当然在service_name下面在指定instance_name也可以指定单独的实例



 

LUXUS =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)//表示采用专用模式,如果服务端不是专用模式,则采用服务端的默认连接方式, 服务端配置为共享服务器的情况,Client可以用共享服务器或者专用服务器来联接数据库,这个参数的控制就是SERVER

      (SERVICE_NAME = luxus)

    )

  )

 

 

LUXUS2 =

  (DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1523))/*配置了一个负载均衡,连接luxus2时会自动连接到一个端口15211523的服务*/

(CONNECT_DATA =

      (SERVICE_NAME = luxus)

    )

  )

 

 

 

RAC的配置,标准配置如下

testdb =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.98.0.142)(PORT = 1521))

    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.98.0.143)(PORT = 1521))

    (LOAD_BALANCE = yes)

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = TESTDB)

       (FAILOVER_MODE=

         (TYPE = session)

         (METHOD = basic)

         (RETRIES = 180)

         (DELAY = 5)

    )

    )

  )

 

 

RAC的配置,也可以采用直接使用SID来指明单独实例


testdb1 =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.98.0.142)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SID = TESTDB1)

    )

  )

 

testdb2 =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.98.0.143)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SID = TESTDB2)

    )

  )

 


RAC的配置,也可以采用service_name和instance_name来指明单独实例


testdb1 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.98.0.142)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = TESTDB)

     (INSTANCE_NAME=TESTDB1)

    )

  )

 

testdb2 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.98.0.143)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME =TESTDB)

      (INSTANCE_NAME=TESTDB2)

    )

  )

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

请登录后发表评论 登录
全部评论

注册时间:2015-09-21

  • 博文量
    211
  • 访问量
    276639