Oracle客户端配置tnsnames.ora

examples:

DFDZ_DATASRV =
  (DESCRIPTION =
    (ADDRESS_LIST =
     (FAILOVER=ON)
      (LOAD_BALANCE=off)
      (ADDRESS = (PROTOCOL = TCP)(HOST = ibmRS6002)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = dfdzs1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

FAILOVER

Purpose

Use the parameter FAILOVER to enable or disable connect-time failover for multiple protocol addresses.

When you set the parameter to on, yes, or true, Oracle Net, at connect time, fails over to a different address if the first protocol address fails. When you set the parameter to off, no, or false, Oracle Net tries one protocol address.

Embed this parameter under either the DESCRIPTION_LIST parameter, the DESCRIPTION parameter, or the ADDRESS_LIST parameter.


Important:

Do not set the GLOBAL_DBNAME parameter in the SID_LIST_listener_name section of the listener.ora. A statically configured global database name disables connect-time failover.


Default

on for DESCRIPTION_LISTs, DESCRIPTIONs, and ADDRESS_LISTs

Values

on | off | yes | no | true | false

Example

net_service_name=  (DESCRIPTION=  (FAILOVER=on)  (ADDRESS=(PROTOCOL=tcp)(HOST=sales1-svr)(PORT=1521))  (ADDRESS=(PROTOCOL=tcp)(HOST=sales2-svr)(PORT=1521)))  (CONNECT_DATA=(SERVICE_NAME=sales.us.acme.com))) 

LOAD_BALANCE

Purpose

Use the parameter LOAD_BALANCE to enable or disable client load balancing for multiple protocol addresses.

When you set the parameter to on, yes, or true, Oracle Net progresses through the list of addresses in a random sequence, balancing the load on the various listener or Oracle Connection Manager protocol addresses. When you set the parameter to off, no, or false, Oracle Net tries the protocol addresses sequentially until one succeeds.

Embed this parameter under either the DESCRIPTION_LIST parameter, the DESCRIPTION parameter, or the ADDRESS_LIST parameter.

Default

on for DESCRIPTION_LISTs

Values

on | off | yes | no | true | false

Example

net_service_name=  (DESCRIPTION=  (LOAD_BALANCE=on)  (ADDRESS=(PROTOCOL=tcp)(HOST=sales1-svr)(PORT=1521))  (ADDRESS=(PROTOCOL=tcp)(HOST=sales2-svr)(PORT=1521)))  (CONNECT_DATA=(SERVICE_NAME=sales.us.acme.com)) 

相关参考文档:

http://www.cise.ufl.edu/help/database/oracle-docs/network.920/a96581/tnsnames.htm

Oracle数据库中的tnsnames.ora文件是一个配置文件,用于定义客户端如何连接到Oracle数据库服务器。它包含了网络服务名、协议、主机名、端口号和数据库服务名等信息。通过配置tnsnames.ora文件,客户端可以轻松地连接到指定的数据库。 以下是配置tnsnames.ora文件的步骤: 1. **找到tnsnames.ora文件**: 通常,tnsnames.ora文件位于Oracle安装目录下的network/admin文件夹中。例如: ``` $ORACLE_HOME/network/admin/tnsnames.ora ``` 2. **编辑tnsnames.ora文件**: 使用文本编辑器(如Notepad++、Vi等)打开tnsnames.ora文件,并添加新的网络服务名配置。以下是一个示例配置: ```plaintext ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = your_host)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = your_service_name) ) ) ``` **参数说明**: - `ORCL`:网络服务名,可以自定义。 - `DESCRIPTION`:描述信息,包含地址和连接数据。 - `ADDRESS`:数据库服务器地址,包含协议、主机名和端口号。 - `PROTOCOL`:通信协议,通常为TCP。 - `HOST`:数据库服务器的主机名或IP地址。 - `PORT`:端口号,默认为1521。 - `CONNECT_DATA`:连接数据,包含服务器类型和服务名。 - `SERVER`:服务器类型,通常为DEDICATED。 - `SERVICE_NAME`:数据库服务名。 3. **保存并关闭文件**: 配置完成后,保存tnsnames.ora文件并关闭编辑器。 4. **测试连接**: 使用Oracle客户端工具(如SQL*Plus、SQL Developer等)测试新配置的网络服务名是否能够成功连接到数据库。 例如,使用SQL*Plus连接数据库: ```shell sqlplus username/password@ORCL ``` 如果配置正确,您将能够成功连接到数据库。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值