大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
实验环境:Oracle 11.2.0.4 RAC
参考MOS文档:
How To Configure Server Side Transparent Application Failover (文档 ID 460982.1)
10多年的凌河网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整凌河建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联公司从事“凌河网站设计”,“凌河网站推广”以来,每个客户项目都认真落实执行。
1.为设置TAF在RAC集群上新建服务
2.启动server_taf服务
3.检查确认服务正在运行
4.找到刚创建服务的service_id
5.根据service_id审查服务的信息
6.给服务添加server side failover参数
7.再次审查服务可以看到Method, Type和Retries值
8.检查已注册的服务的监听信息
9.创建网络服务名
10.测试TAF功能
eg: srvctl add service -d rac -s server_taf -r "rac1,rac2" -P BASIC
使用oracle用户在RAC集群上新建服务server_taf:
[oracle@jyrac1 ~]$ srvctl add service -d jyzhao -s server_taf -r "jyzhao1,jyzhao2" -P BASIC [oracle@jyrac1 ~]$
注意不能使用grid用户操作,如果使用grid 用户执行的话,会报错:
[grid@jyrac1 ~]$ srvctl add service -d jyzhao -s server_taf -r "jyzhao1,jyzhao2" -P BASIC PRCD-1288 : User is not authorized to create service server_taf for database jyzhao PRKH-1014 : Current user "grid" is not the oracle owner user "oracle" of oracle home "/opt/app/oracle/product/11.2.0/dbhome_1"
eg: srvctl start service -d rac -s server_taf
启动server_taf服务
[oracle@jyrac1 ~]$ srvctl start service -d jyzhao -s server_taf
eg: srvctl config service -d rac
检查确认服务正在运行:
[oracle@jyrac1 ~]$ srvctl config service -d jyzhao Service name: server_taf Service is enabled Server pool: jyzhao_server_taf Cardinality: 2 Disconnect: false Service role: PRIMARY Management policy: AUTOMATIC DTP transaction: false AQ HA notifications: false Failover type: NONE Failover method: NONE TAF failover retries: 0 TAF failover delay: 0 Connection Load Balancing Goal: LONG Runtime Load Balancing Goal: NONE TAF policy specification: BASIC Edition: Preferred instances: jyzhao1,jyzhao2 Available instances:
eg: select name,service_id from dba_services where name = 'server_taf';
找到刚创建服务的service_id
SQL> select name,service_id from dba_services where name = 'server_taf'; NAME SERVICE_ID ---------------------------------------------------------------- ---------- server_taf 7
col name format a15
col failover_method format a11 heading 'METHOD'
col failover_type format a10 heading 'TYPE'
col failover_retries format 9999999 heading 'RETRIES'
col goal format a10
col clb_goal format a8
col AQ_HA_NOTIFICATIONS format a5 heading 'AQNOT'
select name, failover_method, failover_type, failover_retries,goal, clb_goal,aq_ha_notifications
from dba_services where service_id = 7;
根据service_id审查服务的信息:
SQL> col name format a15 SQL> col failover_method format a11 heading 'METHOD' SQL> col failover_type format a10 heading 'TYPE' SQL> col failover_retries format 9999999 heading 'RETRIES' SQL> col goal format a10 SQL> col clb_goal format a8 SQL> col AQ_HA_NOTIFICATIONS format a5 heading 'AQNOT' SQL> select name, failover_method, failover_type, failover_retries,goal, clb_goal,aq_ha_notifications 2 from dba_services where service_id = 7 3 ; NAME METHOD TYPE RETRIES GOAL CLB_GOAL AQNOT --------------- ----------- ---------- -------- ---------- -------- ----- server_taf NONE NONE 0 NONE LONG NO SQL>
execute dbms_service.modify_service (service_name => 'server_taf' -
, aq_ha_notifications => true -
, failover_method => dbms_service.failover_method_basic -
, failover_type => dbms_service.failover_type_select -
, failover_retries => 180 -
, failover_delay => 5 -
, clb_goal => dbms_service.clb_goal_long);
11.2版本可以使用srvctl 修改服务的信息:
srvctl modify service -d RAC -s server_taf -m BASIC -e SELECT -q TRUE -j LONG
给服务添加server side failover参数:
SQL> execute dbms_service.modify_service (service_name => 'server_taf' - > , aq_ha_notifications => true - > , failover_method => dbms_service.failover_method_basic - > , failover_type => dbms_service.failover_type_select - > , failover_retries => 180 - > , failover_delay => 5 - > , clb_goal => dbms_service.clb_goal_long); PL/SQL procedure successfully completed.
select name, failover_method, failover_type, failover_retries,goal, clb_goal,aq_ha_notifications
from dba_services where service_id = 7;
再次审查服务可以看到Method, Type和Retries值:
SQL> select name, failover_method, failover_type, failover_retries,goal, clb_goal,aq_ha_notifications 2 from dba_services where service_id = 7; NAME METHOD TYPE RETRIES GOAL CLB_GOAL AQNOT --------------- ----------- ---------- -------- ---------- -------- ----- server_taf BASIC SELECT 180 NONE LONG YES
lsnrctl services
Service "server_taf.za.oracle.com" has 2 instance(s).
Instance "rac1", status READY, has 2 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=dell01)(PORT=1521))
"DEDICATED" established:0 refused:0 state:ready
LOCAL SERVER
Instance "rac2", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
REMOTE SERVER
(ADDRESS=(PROTOCOL=TCP)(HOST=dell02)(PORT=1521))
我这里版本差异,显示有区别,分别在不同节点显示自己的实例:
--node1: Service "server_taf" has 1 instance(s). Instance "jyzhao1", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER The command completed successfully --node2: Service "server_taf" has 1 instance(s). Instance "jyzhao2", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready LOCAL SERVER The command completed successfully
SERVERTAF =
(DESCRIPTION =
(LOAD_BALANCE = yes)
(ADDRESS = (PROTOCOL = TCP)(HOST = dell01)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = dell02)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = server_taf.za.oracle.com)
)
)
服务端RAC所有节点配置tnsnames.ora,添加内容:
SERVERTAF = (DESCRIPTION = (LOAD_BALANCE = yes) (ADDRESS = (PROTOCOL = TCP)(HOST = jyrac1)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = jyrac2)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = server_taf) ) )
sqlplus system/oracle@192.168.56.160/server_taf
select host_name,instance_name from v$instance;
SQL> select instance_name from V$instance;
INSTANCE_NAME
----------------
rac2
SQL> shutdown abort;
ORACLE instance shut down.
select host_name,instance_name from v$instance;
10.1 模拟客户端使用scanVIP测试能否实现TAF
sqlplus system/oracle@192.168.56.160/server_taf
[grid@jyrac1 ~]$ sqlplus system/oracle@192.168.56.160/server_taf SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 10 02:59:53 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> select host_name,instance_name from v$instance; HOST_NAME ---------------------------------------------------------------- INSTANCE_NAME ---------------- jyrac1 jyzhao1 --这里强制关掉jyzhao1实例。 SQL> / HOST_NAME ---------------------------------------------------------------- INSTANCE_NAME ---------------- jyrac2 jyzhao2
10.1 结论: 可以实现TAF功能,相当于客户端不再需要配置,直接通过SCAN VIP连接。
10.2 模拟客户端使用Public IP测试能否实现TAF
sqlplus system/oracle@192.168.56.150/server_taf
SQL> select host_name,instance_name from v$instance; HOST_NAME ---------------------------------------------------------------- INSTANCE_NAME ---------------- jyrac1 jyzhao1 --这里强制关掉jyzhao1实例。 SQL> / select host_name,instance_name from v$instance * ERROR at line 1: ORA-12153: TNS:not connected Process ID: 20116 Session ID: 24 Serial number: 7
如果客户端配置tnsnames.ora,将publicIP配置
TAF = (DESCRIPTION = (LOAD_BALANCE = yes) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.150)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.152)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = server_taf) ) )
再次测试:
[oracle@jyrac2 admin]$ sqlplus system/oracle@taf SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 10 05:11:30 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> select host_name,instance_name from v$instance; HOST_NAME ---------------------------------------------------------------- INSTANCE_NAME ---------------- jyrac2 jyzhao2 --这里强制关掉jyzhao2实例。 SQL> / HOST_NAME ---------------------------------------------------------------- INSTANCE_NAME ---------------- jyrac1 jyzhao1
10.2 结论: 直接连接Public IP无法实现TAF功能。但客户端配置Public IP列表,可以实现。
10.3 模拟客户端使用VIP测试能否实现TAF
sqlplus system/oracle@192.168.56.151/server_taf
[grid@jyrac1 ~]$ sqlplus system/oracle@192.168.56.151/server_taf SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 10 04:32:20 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> select host_name,instance_name from v$instance; HOST_NAME ---------------------------------------------------------------- INSTANCE_NAME ---------------- jyrac1 jyzhao1 SQL> / select host_name,instance_name from v$instance * ERROR at line 1: ORA-03113: end-of-file on communication channel Process ID: 32459 Session ID: 159 Serial number: 3
如果客户端配置tnsnames.ora,可以通过sqlplus system/oracle@tafvip连接。
TAFVIP = (DESCRIPTION = (LOAD_BALANCE = yes) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.151)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.153)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = server_taf) ) )
再次测试:
[oracle@jyrac2 admin]$ sqlplus system/oracle@tafvip SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 10 05:15:32 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> select host_name,instance_name from v$instance; HOST_NAME ---------------------------------------------------------------- INSTANCE_NAME ---------------- jyrac2 jyzhao2 --这里强制关掉jyzhao2实例。 SQL> / HOST_NAME ---------------------------------------------------------------- INSTANCE_NAME ---------------- jyrac1 jyzhao1
10.3 结论: 直接连接VIP无法实现TAF功能。但客户端配置VIP列表,可以实现。