服务器端配置rac taf (rac应用分离)

数据库版本: 10.2.0.1
操作系统版本: CentOS-5.6

1) 创建service

[oracle@rac1 ~]$ srvctl add service -d jscn -s taf_dianping -r jscn1 -a jscn2 -P basic
[oracle@rac1 ~]$ srvctl start service -d jscn -s taf_dianping
[oracle@rac1 ~]$ srvctl enable service -d jscn -s taf_dianping
用service TAF 修改配置,需要用dbms_service.modify_service包。
SQL> begin
dbms_service.modify_service(
service_name=>'taf_dianping',
failover_method=>dbms_service.failover_method_basic,
failover_type=>dbms_service.failover_type_select,
failover_retries=>180,
failover_delay=>5);
end;
/

[oracle@rac1 ~]$ srvctl config service -d jscn -s taf_dianping -a
taf_dianping PREF: jscn1 AVAIL: jscn2 TAF: basic

2)启动监控
[oracle@rac1 ~]$ crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora.jscn.db    application    ONLINE    ONLINE    rac1
ora....n1.inst application    ONLINE    ONLINE    rac1
ora....n2.inst application    ONLINE    ONLINE    rac2
ora....ping.cs application    ONLINE    ONLINE    rac1   --服务
ora....cn1.srv application    ONLINE    ONLINE    rac1
ora....SM1.asm application    ONLINE    ONLINE    rac1
ora....C1.lsnr application    ONLINE    ONLINE    rac1
ora.rac1.gsd   application    ONLINE    ONLINE    rac1
ora.rac1.ons   application    ONLINE    ONLINE    rac1
ora.rac1.vip   application    ONLINE    ONLINE    rac1
ora....SM2.asm application    ONLINE    ONLINE    rac2
ora....C2.lsnr application    ONLINE    ONLINE    rac2
ora.rac2.gsd   application    ONLINE    ONLINE    rac2
ora.rac2.ons   application    ONLINE    ONLINE    rac2
ora.rac2.vip   application    ONLINE    ONLINE    rac2

3)配置tns
192.168.8.206_two =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.206)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.207)(PORT = 1521))
    (LOAD_BALANCE = yes)
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = taf_dianping)
    )
  )  
 
4)测试
window 连接 rac
C:\Windows\system32>sqlplus system/[email protected]_two

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
jscn1

停止节点1
[oracle@rac1 ~]$ sqlplus / as sysdba

SQL> shutdown immediate

[oracle@rac1 ~]$ crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora.jscn.db    application    ONLINE    ONLINE    rac1
ora....n1.inst application    OFFLINE   OFFLINE
ora....n2.inst application    ONLINE    ONLINE    rac2
ora....ping.cs application    ONLINE    ONLINE    rac1  --服务
ora....cn1.srv application    ONLINE    ONLINE    rac2
ora....SM1.asm application    ONLINE    ONLINE    rac1
ora....C1.lsnr application    ONLINE    ONLINE    rac1
ora.rac1.gsd   application    ONLINE    ONLINE    rac1
ora.rac1.ons   application    ONLINE    ONLINE    rac1
ora.rac1.vip   application    ONLINE    ONLINE    rac1
ora....SM2.asm application    ONLINE    ONLINE    rac2
ora....C2.lsnr application    ONLINE    ONLINE    rac2
ora.rac2.gsd   application    ONLINE    ONLINE    rac2
ora.rac2.ons   application    ONLINE    ONLINE    rac2
ora.rac2.vip   application    ONLINE    ONLINE    rac2


再看,
SQL> select instance_name from v$instance;
现在连接到rac2了

INSTANCE_NAME
----------------
jscn2

现在在重新启动节点1
SQL> startup

再看
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------

jscn2


发现无论怎么连接现在都落到rac2上面了,现在我想让他再回到节点1上面应该怎么做

重新注册就可以了

[oracle@rac1 ~]$ srvctl relocate service -d jscn -s taf_dianping -i jscn2 -t jscn1


如果要删除,可以按照如下所示做:

删除service
[oracle@rac1 ~]$ srvctl stop service -d jscn -s taf_dianping
[oracle@rac1 ~]$ srvctl remove service -d jscn -s taf_dianping
SQL> begin
 dbms_service.delete_service(service_name=>'taf_dianping');
end;

你可能感兴趣的:(服务器端配置rac taf (rac应用分离))