oracle11g在沒DNS情況下failover的配置方法

sqysl發表於2016-06-22

1.Oracle 11g引入scan ip ,可在沒有DNS的情況下,客戶端連線RAC配置failover時,很多情況還是使用oracle10g方式。即在客戶端tnsname.ora中配置failover:
1)當客戶端配置如下時,連線的例項關閉後,會話必須重新連才可連線到其他活動的例項上,不會自動重連:
ora112 = 
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = yes)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.87.113)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.87.114)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ora112)
(FAILOVER = on)
)
)

ora112 = 
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = yes)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.87.113)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.87.114)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ora112)
(FAILOVER = on)
(TYPE = select)
(METHOD = basic)
(RETRIES = 180)
(DELAY = 5)
)
)
或(115為scan-ip)
ORA112 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.87.115)(PORT = 1521))
      (LOAD_BALANCE = yes)
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ora112)
      (FAILOVER = on)
    )
  )

ORA112 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.87.115)(PORT = 1521))
      (LOAD_BALANCE = yes)
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ora112)
      (FAILOVER = on)
      (failover_mode=(TYPE=SELECT)
      (METHOD=BASIC)
      (RETRIES=1)
      (DELAY=0)
    )
    )
  )

ORA112 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.87.115)(PORT = 1521))
      (LOAD_BALANCE = yes)
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ora112)
    )
  )
2)當客戶端配置如下時,連線的例項關閉後,會話會自動連線到其他活動的例項上:
ora112 = 
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE = yes)
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.87.113)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.87.114)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ora112)
(FAILOVER = on)
FAILOVER_MODE=(TYPE = select)
(METHOD = basic)
(RETRIES = 180)
(DELAY = 5)
)
)
)
2.如果不採用oracle10g的方法,能不能只在客戶端配置scan ip,而在伺服器端配置以實現failover,具體如下:
(How To Configure Server Side Transparent Application Failover [ID 460982.1])
1)建立TAFService
[oracle@db1 bin]$ ./srvctl add service -d ora112 -s ora112_rac -r "ora1121,ora1122" -P BASIC
--這裡的ora112是database name,ora1121和ora1122 是instance name。
2)啟動s_test服務
[oracle@db1 bin]$ ./srvctl start service -d ora112 -s s_test
3)檢查service執行情況
[oracle@db1 bin]$ ./srvctl config service -d ora112
Service name: s_test
Service is enabled
Server pool: ora112_s_test
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: ora1121,ora1122
Available instances:
4)確認serviceID
SQL> select name,service_id from dba_services where name = 's_test';
NAME SERVICE_ID
--------------------------------------------------------------------------
s_test 3
5)為service新增引數
SQL> execute dbms_service.modify_service (service_name => 's_test' - 
, 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); 
6)確認引數新增情況
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' 
SQL> select name, failover_method,failover_type, failover_retries,goal, clb_goal,aq_ha_notifications from dba_services where service_id = 3; 
NAME METHOD TYPE RETRIES GOAL CLB_GOAL AQNOT
--------------- ----------- ------------------ ---------- -------- -----
s_test BASIC SELECT 180 NONE LONG YES
SQL>
7)檢查service註冊情況
[oracle@db1 bin]$ lsnrctl services
LSNRCTL for Linux: Version 11.2.0.3.0 -Production on 15-JUL-2012 13:26:43
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=db1)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for thisservice...
Handler(s):
"DEDICATED" established:57 refused:0 state:ready
LOCAL SERVER
Service "ora112" has 1 instance(s).
Instance "ora1121", status READY, has 1 handler(s) for thisservice...
Handler(s):
"DEDICATED" established:11 refused:0 state:ready
LOCAL SERVER
Service "ora112XDB" has 1instance(s).
Instance "ora1121", status READY, has 1 handler(s) for thisservice...
Handler(s):
"D000" established:0 refused:0 current:0 max:1022 state:ready
DISPATCHER
(ADDRESS=(PROTOCOL=tcp)(HOST=db1.tianlesoftware.com)(PORT=38731))
Service "s_test" has 1instance(s).
Instance "ora1121", status READY, has 1 handler(s) for thisservice...
Handler(s):
"DEDICATED" established:11 refused:0 state:ready
LOCAL SERVER
The command completed successfully
8)配置tnsnames.ora,連線後,關閉連線例項後,會話會自動切換到其他活動例項上(115為scan ip):
ORA112 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.87.115)(PORT = 1521))
      (LOAD_BALANCE = yes)
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = s_test)
    )
  )

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8484829/viewspace-2120688/,如需轉載,請註明出處,否則將追究法律責任。

相關文章