靈活實現RAC三節點的負載均衡及TAF配置(五)
這兩天配置了一個三節點的RAC環境,想起前一段時間Thomas Zhang給我出的一個題目,配置一個三節點RAC環境的複雜負載均衡以及Transparent Application Failover的服務名。現在有環境了,可以將給出驗證後的結果了。
設定不同節點的SERVICE_NAMES,解決最終問題。
靈活實現RAC三節點的負載均衡及TAF配置(一):http://yangtingkun.itpub.net/post/468/482683
靈活實現RAC三節點的負載均衡及TAF配置(二):http://yangtingkun.itpub.net/post/468/482724
靈活實現RAC三節點的負載均衡及TAF配置(三):http://yangtingkun.itpub.net/post/468/487416
靈活實現RAC三節點的負載均衡及TAF配置(四):http://yangtingkun.itpub.net/post/468/487825
前面嘗試了很多的配置,基本上可以滿足絕大部分的要求,但是由於沒有辦法在DESCRIPTION中解決單獨指向例項1和例項2問題,因此只能使用DESCRIPTION_LIST解決,但是這也帶來了新的問題,使得LOAD_BANLANCE和TAF的設定異常的複雜,而且容易導致ORA-3113等錯誤。
因此首先修改例項1和例項2的SERVICE_NAMES,使這兩個功能相同的例項擁有相同的SERVICE_NAMES,且與例項3的SERVICE_NAMES相區別:
SQL> SELECT INSTANCE_NUMBER, INSTANCE_NAME
2 FROM GV$INSTANCE;
INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
1 testrac1
3 testrac3
2 testrac2
SQL> COL NAME FORMAT A30
SQL> COL VALUE FORMAT A30
SQL> SELECT INST_ID, NAME, VALUE
2 FROM GV$SYSTEM_PARAMETER
3 WHERE NAME = 'service_names';
INST_ID NAME VALUE
---------- ------------------------------ ------------------------------
1 service_names testrac,testrac1
3 service_names testrac,testrac3
2 service_names testrac,testrac2
SQL> ALTER SYSTEM SET SERVICE_NAMES = 'testrac,testrac12' SCOPE = BOTH SID = 'testrac1';
系統已更改。
SQL> ALTER SYSTEM SET SERVICE_NAMES = 'testrac,testrac12' SCOPE = BOTH SID = 'testrac2';
系統已更改。
SQL> ALTER SYSTEM SET SERVICE_NAMES = 'testrac,testrac3' SCOPE = BOTH SID = 'testrac3';
系統已更改。
SQL> SELECT INST_ID, NAME, VALUE
2 FROM GV$SYSTEM_PARAMETER
3 WHERE NAME = 'service_names';
INST_ID NAME VALUE
---------- ------------------------------ ------------------------------
3 service_names testrac,testrac3
2 service_names testrac,testrac12
1 service_names testrac,testrac12
下面重新配置服務名:
SERVICEA =
(DESCRIPTION_LIST =
(LOAD_BALANCE = no)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.225)(PORT = 1521))
)
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TESTRAC12)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(BACKUP = SERVICEA_BACKUP)
)
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.227)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TESTRAC3)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(BACKUP = SERVICEA_BACKUP)
)
)
)
)
SERVICEB =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.227)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TESTRAC3)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(BACKUP = SERVICEA)
)
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.225)(PORT = 1521))
)
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TESTRAC12)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(BACKUP = SERVICEA)
)
)
)
(LOAD_BALANCE = no)
)
SERVICEA_BACKUP =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.224)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.225)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TESTRAC12)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(BACKUP = SERVICEA_BACKUP)
)
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.25.198.227)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TESTRAC3)
(FAILOVER_MODE =
(TYPE = SELECT)
(METHOD = BASIC)
(BACKUP = SERVICEA)
)
)
)
(LOAD_BALANCE = no)
)
測試連線:
SQL> CONN TEST/TEST@SERVICEA
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac2
SQL> CONN TEST/TEST@SERVICEA
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> CONN TEST/TEST@SERVICEB
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac3
SQL> CONN TEST/TEST@SERVICEB
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac3
透過SERVICEA可以在節點1和節點2的例項上負載均衡的連線,而透過SERVICEB則連線節點3:
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac3
透過命令列方式關閉節點3:
bash-2.03$ srvctl stop inst -d testrac -i testrac3
檢查當前連線的例項:
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac2
啟動資料庫例項:
bash-2.03$ srvctl start inst -d testrac -i testrac3
重複一下同樣的操作:
SQL> CONN TEST/TEST@SERVICEB
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac3
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
需要注意在兩次執行當前例項的查詢之間,透過命令列的方式關閉了例項3。
可以看到,當透過SERVICEB連線到例項3後,如果例項3發生故障,TAF將會話負載均衡的切換到例項1和例項2上。
下面啟動一下例項2,檢查最後一種情況,透過SERVICEA連線資料庫,當節點1或節點2都失敗的情況:
SQL> CONN TEST/TEST@SERVICEA
已連線。
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac2
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac1
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac3
SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;
INSTANCE_NAME
----------------
testrac2
對應的後臺命令列啟動關閉例項的指令碼為:
bash-2.03$ srvctl stop inst -d testrac -i testrac1
bash-2.03$ srvctl start inst -d testrac -i testrac1
bash-2.03$ srvctl stop inst -d testrac -i testrac2
bash-2.03$ srvctl stop inst -d testrac -i testrac1
bash-2.03$ srvctl start inst -d testrac -i testrac1,testrac2
bash-2.03$ srvctl stop inst -d testrac -i testrac3
下面簡單描述一下上面的過程。
透過SERVICEA服務名登陸,檢查當前連線的例項,發現連線到例項1上,在後臺關閉例項1,檢查連線例項,發現TAF後連線到例項2上,後臺啟動例項1,然後關閉例項2,再次檢查連線,發現TAF操作後,連線又回到了例項1上。然後關閉例項1,檢查當前的連線,由於例項1和例項2都已經被關閉,因此連線到了例項3上。最後啟動例項1和例項2,關閉例項3,檢查連線,當前的連線又回到了例項2上。
終於透過SERVICEA、SERVICEB和SERVICEA_BACKUP三個服務名的配合,以及設定RAC不同節點上的SERVICE_NAMES引數,終於完美的解決了這個問題。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-626982/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 靈活實現RAC三節點的負載均衡及TAF配置(三)負載
- 靈活實現RAC三節點的負載均衡及TAF配置(二)負載
- 靈活實現RAC三節點的負載均衡及TAF配置(一)負載
- 靈活實現RAC三節點的負載均衡及TAF配置(四)負載
- 【RAC】RAC中的負載均衡和故障切換--TAF配置負載
- dubbo(三):負載均衡實現解析負載
- RAC負載均衡的簡單測試(三)負載
- orleans叢集及負載均衡實現負載
- 配置 RAC 負載均衡與故障轉移負載
- Oracle RAC 客戶端負載均衡配置Oracle客戶端負載
- [zt] RAC的負載均衡負載
- DNS負載均衡的配置與特點DNS負載
- Nginx 高階篇(三)負載均衡的實現Nginx負載
- RHEL 7配置HAProxy實現Web負載均衡Web負載
- 伺服器負載均衡原理及實現伺服器負載
- nginx實現負載均衡Nginx負載
- 配置IIS的負載均衡負載
- 使用LVS實現負載均衡原理及安裝配置詳解負載
- 使用 LVS 實現負載均衡原理及安裝配置詳解負載
- 負載均衡之Haproxy配置詳解(及httpd配置)負載httpd
- 淺談RAC中的負載均衡負載
- HAProxy負載均衡器的安裝及配置負載
- Flume負載均衡配置負載
- apache 負載均衡配置Apache負載
- GRPC 負載均衡實現RPC負載
- HaProxy 實現 MySQL 負載均衡MySql負載
- Ribbon實現負載均衡負載
- Oracle負載均衡實現方式Oracle負載
- Nginx + IIS 實現負載均衡Nginx負載
- 兩種負載均衡的配置。負載
- Nginx實現簡單的負載均衡Nginx負載
- Nginx實現叢集的負載均衡配置過程詳解Nginx負載
- 使用LVS實現負載均衡的原理及安裝配置例項詳解負載
- Linux下玩轉nginx系列(五)---nginx實現負載均衡LinuxNginx負載
- 雙活資料中心負載均衡理解負載
- 用Nginx實現Session共享的均衡負載NginxSession負載
- nginx配置+uwsgi+負載均衡配置Nginx負載
- RAC負載均衡的簡單測試(二)負載