在面试的时候遇到的一个问题:如何设置TAF模式?
今天记录下来,以备参考。
如果使用Toad或客户端的UI设置taf将很容易实现,前提是你的数据库使用的是RAC模式,配置完后具体的内容将写入tnsname.ora文件中
TAF設置只需在tnsnames.ora中添加failover=on即可,有两种不同的设置方法:
1、公用一个tns name方式:
==================================================
RACDB =
(description=
(load_balance=on)
(failover=on) ----设置TAF,开启故障切换功能
(address= (protocol=tcp)(host=192.168.1.10)(port=1522))
(address= (protocol=tcp)(host=192.168.1.12)(port=1522))
(connect_data= (service_name=racdb)
(failover_mode=(type=select)(method=basic)(retries=20)(delay=20))
-----设置failover模式
)
)
==========================================================================
2、指明instance backup方式:
===============================================
rac1 =
(description=
(load_balance=on)
(failover=on) ----设置TAF,开启故障切换功能
(address= (protocol=tcp)(host=192.168.1.10)(port=1522))
(connect_data= (service_name=racdb)
(failover_mode=(type=select)(method=basic)
(backup=rac2)(retries=20)(delay=20))
)
)
rac2 =
(description=
(load_balance=on) -----开启负载均衡
(failover=on)
(address= (protocol=tcp)(host=192.168.1.12)(port=1522))
(connect_data= (service_name=racdb)
(failover_mode=(type=select)(method=basic)
(backup=rac1)(retries=20)(delay=20))
)
)
==============================================================
如下是我使用toad管理配置后的tnsname.ora文件内容:
RACDB=
(DESCRIPTION=
(ADDRESS_LIST=
(FAILOVER=on)
(LOAD_BALANCE=on)
(SOURCE_ROUTE=off)
(ADDRESS=
(PROTOCOL=TCP)
(HOST=192.168.1.201)
(PORT=1521)
)
(ADDRESS=
(PROTOCOL=TCP)
(HOST=192.168.1.202)
(PORT=1521)
)
)
(CONNECT_DATA=
(FAILOVER_MODE=
(TYPE=session)
(METHOD=basic)
(RETRIES=5)
(DELAY=5)
)
(SERVER=dedicated)
(SERVICE_NAME=RACDB)
)
)
===========================================================
TAF测试方法
一般可以将当前连接的instance down下来,client端将不会断开,并自动切换到backup节点上。相反也会自动切换回来。
当 然也有人提出用post_transaction的方式来测试TAF,其实这样有时是得不到预期结果的,原因在于Oracle连接到一个instance 上后,此后它会优先尝试对该instance的连接,当你disconnect后,client端一有新的请求就会自动尝试对最近连接的instance 进行连接,如果不成功才会尝试对backup instance进行连接。
今天记录下来,以备参考。
如果使用Toad或客户端的UI设置taf将很容易实现,前提是你的数据库使用的是RAC模式,配置完后具体的内容将写入tnsname.ora文件中
TAF設置只需在tnsnames.ora中添加failover=on即可,有两种不同的设置方法:
1、公用一个tns name方式:
==================================================
RACDB =
(description=
(load_balance=on)
(failover=on) ----设置TAF,开启故障切换功能
(address= (protocol=tcp)(host=192.168.1.10)(port=1522))
(address= (protocol=tcp)(host=192.168.1.12)(port=1522))
(connect_data= (service_name=racdb)
(failover_mode=(type=select)(method=basic)(retries=20)(delay=20))
-----设置failover模式
)
)
==========================================================================
2、指明instance backup方式:
===============================================
rac1 =
(description=
(load_balance=on)
(failover=on) ----设置TAF,开启故障切换功能
(address= (protocol=tcp)(host=192.168.1.10)(port=1522))
(connect_data= (service_name=racdb)
(failover_mode=(type=select)(method=basic)
(backup=rac2)(retries=20)(delay=20))
)
)
rac2 =
(description=
(load_balance=on) -----开启负载均衡
(failover=on)
(address= (protocol=tcp)(host=192.168.1.12)(port=1522))
(connect_data= (service_name=racdb)
(failover_mode=(type=select)(method=basic)
(backup=rac1)(retries=20)(delay=20))
)
)
==============================================================
如下是我使用toad管理配置后的tnsname.ora文件内容:
RACDB=
(DESCRIPTION=
(ADDRESS_LIST=
(FAILOVER=on)
(LOAD_BALANCE=on)
(SOURCE_ROUTE=off)
(ADDRESS=
(PROTOCOL=TCP)
(HOST=192.168.1.201)
(PORT=1521)
)
(ADDRESS=
(PROTOCOL=TCP)
(HOST=192.168.1.202)
(PORT=1521)
)
)
(CONNECT_DATA=
(FAILOVER_MODE=
(TYPE=session)
(METHOD=basic)
(RETRIES=5)
(DELAY=5)
)
(SERVER=dedicated)
(SERVICE_NAME=RACDB)
)
)
===========================================================
TAF测试方法
一般可以将当前连接的instance down下来,client端将不会断开,并自动切换到backup节点上。相反也会自动切换回来。
当 然也有人提出用post_transaction的方式来测试TAF,其实这样有时是得不到预期结果的,原因在于Oracle连接到一个instance 上后,此后它会优先尝试对该instance的连接,当你disconnect后,client端一有新的请求就会自动尝试对最近连接的instance 进行连接,如果不成功才会尝试对backup instance进行连接。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23604335/viewspace-767149/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23604335/viewspace-767149/