日期:2014-05-16  浏览次数:20700 次

oracle tnsnames.ora配置
本地命名参数,存放位置一般在:$ORACLE_HOME/network/admin目录下
tnsnames.ora主要是做名称映射的。连接描述字符串中服务与本地命名方法的映射(客户端);网络请求中的服务名与本地监听的地址映射(服务端)。

tnsnames.ora的基本语法
DESCRIPTION包含整个连接描述,ADDRESS包含协议地址,CONNECT_DATA包含数据库服务ID信息

标准格式:
net_service_name=
(DESCRIPTION=
   (ADDRESS=(protocol_address_information))
   (CONNECT_DATA=
     (SERVICE_NAME=service_name)))

多重描述
一个网络服务名可以对应多个DESCRIPTION,一个DISCRIPTION可包含多个地址
标准格式:
net_service_name=
(DESCRIPTION_LIST=
  (DESCRIPTION=
   (ADDRESS=(protocol_address_information))
   (ADDRESS=(protocol_address_information))
   (ADDRESS=(protocol_address_information))
   (CONNECT_DATA=
     (SERVICE_NAME=service_name)))
  (DESCRIPTION=
   (ADDRESS=(protocol_address_information))
   (ADDRESS=(protocol_address_information))
   (ADDRESS=(protocol_address_information))
   (CONNECT_DATA=
     (SERVICE_NAME=service_name))))

客户端负载均衡与容灾
sample=
(DESCRIPTION=
   (LOAD_BALANCE=on)
   (FAILOVER=on)
   (ADDRESS_LIST=
     (SOURCE_ROUTE=yes)
     (ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=1630))
     (ADDRESS=(PROTOCOL=tcp)(HOST=host2)(PORT=1521)))
  (ADDRESS_LIST=
     (SOURCE_ROUTE=yes)
     (ADDRESS=(PROTOCOL=tcp)(HOST=host3)(port=1630))
     (ADDRESS=(PROTOCOL=tcp)(HOST=host4)(port=1521)))
   (CONNECT_DATA=(SERVICE_NAME=sales.us.acme.com)))

额外参数配置:
FAILOVER
LOAD_BALANCE
RECV_BUF_SIZE
SDU
SEND_BUF_SIZE
SOURCE_ROUTE
TYPE_OF_SERVICE(如rdb)