方法1:适合中间件等JDBC等连接方法,本示例为thin方式
url="jdbc:oracle:thin:@(DESCRIPTION =
(LOAD_BALANCE = NO)
(ADDRESS = (PROTOCOL =TCP)(HOST = dtydb3-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL =TCP)(HOST = dtydb4-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL =TCP)(HOST = dtydb5-vip)(PORT = 1521))
(ADDRESS = (PROTOCOL =TCP)(HOST = dtydb6-vip)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = srv_kfpb1)
)
)"
同时需要修改/etc/hosts文件,添加如下内容
#VIP
10.4.×.* dtydb3-vip10.4.×.* dtydb4-vip
10.4.×.* dtydb5-vip
10.4.×.* dtydb6-vip
方法2:一般用于sqlplus、plsql等客户端工具
$ORACLE_HOME/network/admin/tnsnames.ora文件中添加如下内容
tydb_kfpb1 =
(DESCRIPTION =
(LOAD_BALANCE = NO)
(ADDRESS = (PROTOCOL =TCP)(HOST = 10.4.×.*)(PORT = 1521))
(ADDRESS = (PROTOCOL =TCP)(HOST = 10.4.×.*)(PORT = 1521))
(ADDRESS = (PROTOCOL =TCP)(HOST = 10.4.×.*)(PORT = 1521))
(ADDRESS = (PROTOCOL =TCP)(HOST = 10.4.×.*)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME= srv_kfpb1)
)
)
然后直接使用tydb_kfpb1进行连接
备注:黄色部分修改为自己需要的服务名