在oracle 11g中,SCAN IP還用的很少。到oracle 12.2或者19c,用戶已經基本上清一色的切換到了SCAN IP。所以很有必要理解oracle的SCAN IP運行機制和配置。
先回顧下VIP。
RAC的每個節點都需要有一個虛擬IP,這就是VIP。VIP需要和PUBLIC IP同一個子網,它們是由GI的Clusterware來管理的。VIP在其節點服務器發生故障的時候會自動漂移到另外正常的節點服務器上,如果RAC是多個節點運行的,那具體漂移到哪個活動的節點將由Clusterware決定。VIP發生漂移現象之後,其當前的節點服務器LOCAL LISTENER是不會監聽它的請求的,所以有客戶端向這個VIP發送請求時,Clusterware的FAN會通知客戶端向別的VIP發送請求,客戶端收到通知後通過Failover機制把請求重新發送到ADDRESS列表中的其他VIP上,如下所示:
Oracle Clusterware manages VIPs as a node application. When Oracle Clusterware discovers that a node has failed, it will relocate the VIP to one of the remaining nodes. A promiscuous ARP packet is broadcast to inform clients that the MAC address for the VIP has changed.
The relocated VIP does not forward incoming connections to the listener; instead it immediately sends back a failure message to the client. The client can then immediately failover to an alternate address. In the above slide, node 1 has crashed. Oracle Clusterware relocates VIP1 to node2. When the client attempts to connect using VIP1 it receives an error message; when it attempts to connect using VIP2 the connection is forwarded to the listener
Applications that connect to Oracle database in Oracle Clusterware should connect using the VIP address and not the public IP address
The VIP address maps to the MAC address of the adapter. It is possible to use Oracle VIPs with bonded/teamed NICs.
雖然有這種較複雜的過程,但始終對客戶端是透明進行的,而且這個過程完成時間非常短暫,客戶端也就幾乎感受不到有節點宕機。等故障節點恢復正常,漂移的VIP也回到此節點上,繼續提供服務。
VIP的優點在於相比TCP,客戶端感知失敗的時間更短、不需要等待TCP超時。
SCAN IP
總結起來(推薦):
- 配置SCAN域名(負載均衡不需要,沒意義)
- 配置多個SCAN IP(負載均衡最好配置,不推薦使用SCAN IP)
oracle初始化參數LOCAL_LISTENER
該參數指定了數據庫PMON進程需要將數據庫實例註冊到哪個端口,如果沒有設置這個參數,PMON進程默認將數據庫的服務註冊到本地節點的1521端口。
SQL> show parameter local_listener; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ local_listener string (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.199.157)(PORT=1521))
oracle初始化參數REMOTE_LISTENER
該參數指定了除了本地監聽程序以外,PMON需要把本地實例的服務註冊到何位置
例如:在RAC系統中這個參數,意爲將本地實例的數據庫服務註冊到集羣其他節點的監聽程序或SCAN監聽程序上。
SQL> show parameter remote_listener; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ remote_listener string rac-scan:1521 根據以上的設置,PMON會將本地實例的服務註冊到SCAN-rac的1521端口。 其中SCAN-rac是一個可以通過DNS或/etc/hosts文件解析的名稱。
oracle各種IP https://www.modb.pro/db/13380
https://www.cnblogs.com/wlzjdm/p/6700678.html
https://blog.csdn.net/jim_cainiaoxiaolang/article/details/77153296
Client Failover Best Practices for Highly Available Oracle Databases Oracle Database 12c