Coherence Step by Step 第二篇 集群(二) 建立集群(翻譯)


原文鏈接http://docs.oracle.com/cd/E24290_01/coh.371/e22837/cluster_setup.htm#CHDFCBIG

1.建立集群概述

 
Coherence提供了一個默認的即用的集群配置用於demon的目的。允許集群快速的建立和要求最少或沒有配置變化。
 
然后,在demon以外,不應該使用默認的安裝。而是根據網絡環境來建立唯一的集群來運行和根據應用程序的需求來使用。一個集群被配置運行在一個服務器模式能夠進行單元測試和瑣碎的開發。
 
最少的,建立一個集群包含定義集群的名字和集群的多播地址。如果多播在環境中是不合理的或是不可用的,那么建議一個WKA(Well known Address) 特性是必須的。
 
用一個operational override file 建立一個集群(tangosol-coherence-override.xml)。每隔集群成員使用覆蓋文件制定唯一的值覆蓋默認的配置(被定義在operational deployment descriptor.
 
2.指定集群名字
集群的名字是一個用戶定義的名字,用於區分網絡上其它集群的唯一識別符。集群成員必須指定相同的集群名字用來加入一個集群。如果一個集群成員使用了錯誤的名字,當嘗試加入一個存在集群時不會啟動。一個唯一的集群名字常常使用一個唯一的多播端口用來創建在同一個網絡中的唯一的集群。
 
指定一個集群的名字,編輯 operational override file ,加入一個元素<cluster-name>,包含在 <member-identity>這個元素里,
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/
coherence-operational-config coherence-operational-config.xsd">
<cluster-config>
<member-identity>
<cluster-name system-property="tangosol.coherence.cluster">
     MyCluster
</cluster-name>
</member-identity>
</cluster-config>
</coherence>

 

也可以用tangosol.coherence.cluster  系統屬性用來指定一個集群的名字,而不是用 operational override file。例如:
-Dtangosol.coherence.cluster=name
 
3.指定集群成員的標示符
 
標示符集合被用來給集群成員在集群中一個標示符。標示信息用來區分集群成員和表示集群中成員的角色。一些標示符也被集群服務使用,當執行集群任務時。最后,當顯示管理信息和幫助解釋日志條目時,標示信息業很有價值。下面列出了標示信息的描述。
  • Site Name-網站的名字,用來宿主集群成員。如果沒有指定名字,那么服務器的域名會被用來作為名字。在WAN 集群中,這個值標示了成員所在的數據中心和能夠作為智能路由、負載均衡和災難恢復的的基本。
  • Machine Name-用來宿主集群成員的服務器名。如果沒有指定名字,默認使用服務器名。名字用來作為創建一個ID的基本。集群服務使用ID來確定數據備份在另一個計算機室,以防止單點故障。
  • Process Name-宿主集群成員的JVM進程名字。如果沒有指定進程名,就默認使用JVM進程號。進程名使得可以簡單的區分在一台計算機上的多個JVM。
  • Member Name-集群成員的唯一的名字。名字使得區分集群成員非常簡單,特別是有多個成員運行在一台計算機上或者同一個JVM。總是應該指定一個成員名字,即時不是必須這樣做。
  • Role Name-集群成員在集群中的的角色。角色名允許應用程序組織集群成員進入指定的角色,如cache server或者cache clients。默認的角色名(cache server使用CoherenceServer,cache client 使用application_class_name),如果沒有指定角色名。
要指定一個成員的標示信息,編輯operational override file ,增加成員標示元素在<member-identity>里,如下面示例:
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/
coherence-operational-config coherence-operational-config.xsd">
  <cluster-config>
    <member-identity>
      <site-name system-property="tangosol.coherence.site">pa-1</site-name>
      <rack-name system-property="tangosol.coherence.rack">100A</rack-name>
      <machine-name system-property="tangosol.coherence.machine">prod001
      </machine-name>
      <process-name system-property="tangosol.coherence.process">JVM1
      </process-name>
      <member-name system-property="tangosol.coherence.member">C1</member-name>
      <role-name system-property="tangosol.coherence.role">Server</role-name>
    </member-identity>
    </cluster-config>
</coherence>

 

下面的系統屬性頁可以 用來指定一個集群成員的標示信息,而不用operational override file.
-Dtangosol.coherence.site=pa-1 -Dtangosol.coherence.rack=100A
-Dtangosol.coherence.machine=prod001 -Dtangosol.coherence.process=JVM1
-Dtangosol.coherence.member=C1 -Dtangosol.coherence.role=Server

4.配置多播通訊
 
集群成員使用多播通訊來發現各個集群成員,當一個消息在集群中的多個成員之間通訊。集群協議
非常聰明的使用多播並且避免多播風暴。默認的,如果嘗試給超過25%的集群成員,那么數據只通過多播傳播。大量的多數流量通過單播傳輸,即使多播能夠使用。典型的基於集群的partitioned cache,大多數的傳輸是點對點的,只有集群會員和partition ownership 是廣播給所有的集群。
多播通訊在operational override file 中使用<multicast-listener>節點配置。許多的系統屬性也能夠使用來配置多播通訊,當啟動一個集群成員。
 
4.1指定集群的多播地址
集群成員能夠指定一個多播地址(IP地址和端口)。集群成員必須使用相同的多播地址和端口來加入一個集群。在同一個網絡里的不同集群必須使用不同的多播地址。
 
一個集群成員使用一個默認的多播地址如果沒有指定一個明確的地址。默認值更覺不同的release版本而不同。
 
指定一個多播地址,編輯operational override file 添加<address>和<port> 元素,指定集群成員使用的地址和端口。例如:
 
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/
coherence-operational-config coherence-operational-config.xsd">
<cluster-config>
  <multicast-listener>
  <address system-property="tangosol.coherence.clusteraddress">224.3.6.0
  </address>
  <port system-property="tangosol.coherence.clusterport">3059</port>
  </multicast-listener>
</cluster-config>
</coherence>

 

tangosol.coherence.clusteraddress和tangosol.coherence.clusterport系統屬性也能用來指定集群多播地址,而不用operational override file。例如:
-Dtangosol.coherence.clusteraddress=224.3.6.0
-Dtangosol.coherence.clusterport=3059

4.1.1修改多播的Socker接口
 
多播socket被綁定在同一個網絡的接口上,作為單播的監聽IP地址。不同的NIC也能夠被用來配置多播,但是會導致罕見的異常,強烈的不鼓勵,可能導致部分集群的失效。
如果有兩個NIC,使用多播傳輸的接口不同於使用單播和TCP-ring的傳輸。在一個接口上的通訊仍然會成功,即使另一個失效;這種情況延長了失效檢測和故常恢復。既然集群協議維護着成員的故障,它能夠更好的知道所有的通訊故障,以便快速的檢測到成員故障,並從集群中移除。
 
改變默認的多播網絡接口,編輯operational override file ,增加<interface>元素,指定IP地址綁定剝奪socket。例如:
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/
coherence-operational-config coherence-operational-config.xsd">
  <cluster-config>
    <multicast-listener>
    <interface>192.168.0.1</interface>
    </multicast-listener>
  </cluster-config>
</coherence>

 

4.2禁止多播通訊
可能在一些網絡環境中不允許多播傳輸或者不希望使用多播傳輸。這種情況下,使用Well Know Address特性來組織Coherence使用多播。這禁止了多播發現也禁止了數據傳輸的多播。用單播代替。Coherence被設計極可能使用點對點通訊,因此大部分的應用程序沒有見到實質的性能影響。

4.3指定多播的Time-to-Live
TTL的設置用來指定多播UDP/IP包能夠在網絡上傳輸多遠。TTL標示了一個數據包能夠村換多少跳。每個網絡接口,路由和轉換認為是一跳。
TTL值應該設置為能夠工作的最小是。值設置的太大可能導致使用其他LAN片段上的不必要的帶寬,也可能導致操作系統或網絡設置禁止多播傳輸。典型的,設置TTL值為1,工作在簡單的交換主干。值2或者更大可能需要在一個高級的主干網,它能夠智能交換。值0用在單服務器的集群上,用來開發和測試。
 
指定一個TTL值,編輯opertaional voerride file,添加一個包含TTL值得<time-to-live>元素,例如:
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/
coherence-operational-config coherence-operational-config.xsd">
  <cluster-config>
    <multicast-listener>
      <time-to-live system-property="tangosol.coherence.ttl">3</time-to-live>
    </multicast-listener>
    </cluster-config>
</coherence>

 

tangosol.coherence.ttl系統屬性也能用來指定TTL值,而不用operataional override file.例如:
-Dtangosol.coherence.ttl=3
 
4.4指定多播Join Timeout
多播加入超時,定義了一個集群成員等待加入一個集群的時間。如果超時到了,沒有檢測到存在的集群,那么集群成員就啟動自己的集群,將自己選舉為最上級的集群成員。開發的時候,可以指定一個短的超時時間。生產環境適合30秒。
指定一個加入超時時間,編輯operational overide file ,增加一個具有超時時間值得<join-timeout-milliseconds>元素,例如:
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/
coherence-operational-config coherence-operational-config.xsd">
  <cluster-config>
    <multicast-listener>
       <join-timeout-milliseconds>6000</join-timeout-milliseconds>
    </multicast-listener>
  </cluster-config>
</coherence>

 

4.5 修改多播的Threshold
集群成員使用多播和單播通訊,當發送集群數據包。多播如果值用來檢測是否是使用多播或單播來分發數據包。設置一個高一點或者低一點的值能夠強制一個集群相對於另一種,更偏愛一種通訊方式。如果禁用的多播,就不用設置Threshold。
多播的threshold是一個百分比值,范圍是1%~100%。在擁有N個成員的集群中,一個集群成員發送一個數據包給目的節點集合(不包含自己),數量為d(范圍是0~n-1),只有在下面保持為true的情況才會用多播發送數據包:
  • 數據包被發往網絡上的多個節點(d>1)
  • 節點的數量大於指定的threshold(d>(n-1)*(threshold/100))
例如,有25個成員的集群中,多播threshold是25%,如果數據包的目的節點超過6個成員,將會使用多播發送。
設置值為1,允許集群使用多播作為基本的多點傳輸。設置值為100,強制集群使用單播來傳輸多點的數據,除非指定了廣播傳輸。(例如,集群的心跳包和發現),因為100%的threshold從不超出。默認設置的是25,如果目的少於1/4的節點,那么集群成員使用單播發送數據包,如果目的節點超過1/4,就使用多播地址。
指定多播threshold,編輯operational override file,增加一個含有threshold值得元素<multicast-threshold-percent>。例如:
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/
coherence-operational-config coherence-operational-config.xsd">
<cluster-config>
<multicast-listener>
     <multicast-threshold-percent>40</multicast-threshold-percent>
</multicast-listener>
     </cluster-config>
</coherence>

 

 
5.指定集群的單播地址
集群成員使用單播來直接成員和成員之間的通訊,在集群上建立主要的通訊。默認使用了單播地址,也可以指定用<unicast-listener>元素指定一個。
unicast listener,即用的配置,根據下面選擇單播地址:
address-集群成員嘗試獲取綁定IP,使用java.net.inetAddress.getLocalHost()調用。明確的指定計算機上多個IP或者NIC的地址,如果需要。此外,如果定義個localhost為一個回環地址,localhost的設置將不會再系統上運行;這種情況,計算機名和指定的IP地址必須指定。多播socket綁定到相同的接口所定義的這個地址。
 ports-集群成員使用兩個單播UDP端口。默認的行為是嘗試先使用8088(端口1),如果端口8088不可用,那么自動端口調整將被使用來選擇下一個可用的端口。第二個端口是自動打開,默認的下一個可用的端口是端口1的下一個端口(port1+1)。自動端口調整可以禁用。這種情況下,端口1必須是可用的,第二個端口永遠是端口1+1。
 
使用兩個UDP端口,因為:
-減少了進來和出去的傳輸連接,避免了在一個端口上的發送和接收數據。
-允許coherence成員通訊於一個優化過的數據包大小,用系統最大的MTU值。一個UDP端口是用於大的數據包,另一個端口用於網絡MTU的數據包大小。分開允許單獨的數據包基本大小來緩存。
-允許大型集群運行,而不用手工增加socket緩存的大小。
指定集群成員使用單播地址,編輯operational voerride file和增加<address>和<port>元素,指定集群成員使用的地址和端口。例如:
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/
coherence-operational-config coherence-operational-config.xsd">
  <cluster-config>
    <unicast-listener>
      <address system-property="tangosol.coherence.localhost">192.168.0.1
      </address>
      <port system-property="tangosol.coherence.localport">8090</port>
      <port-auto-adjust system-property="tangosol.coherence.localport.adjust">
        true
      </port-auto-adjust>
    </unicast-listener>
  </cluster-config>
</coherence>

 

tangosol.conherence.localhost,tangosol.coherence.localport,和tangosol.coherence.localport.adjust系統屬性能夠指定顛簸地址,而不用operational override file.例如:
-Dtangosol.coherence.localhost=192.168.0.1 
-Dtangosol.coherence.localport=8090
-Dtangosol.coherence.localport.adjust=true

6 使用Well Know Address
Well Known Address(WKA) 特性是一種機制,它允許cluster成員使用單播發現和加入cluster,而不是使用多播。
 
WKA通過指定cluster成員的一個小子集啟用,能夠啟動cluster。基於Cluster的數量來優化WKA成員的數量。通常WKA成員應該在Cluster的10%左右。推薦位每個交換機設置一個或兩個WKA成員。
 
WKA成員期望是在Cluster的整個生命周期中是有效的,而不需要在任何時間點同事激活的。只有一個WKA成員必須被操作,讓cluster 成員發現和加入cluster.此外,在cluster成員加入cluster以后,它會收到所有cluster成員的地址,然后執行廣播,通過單獨發送消息給每個cluseter成員。這允許cluster來操作,即使所有的WKA成員停止了工作。然后,新的cluster成員不能加入cluster除非他們是WKA成員或者知道一個WKA成員啟動。這個例子中,cluster中的最高級的成員裁剪WKA成員裂變,並允許WKA成員重新加入已存在的cluster。
 
有兩個方式指定WKA成員。第一個方法是明確指定一個地址列表。第二個方法是使用地址提供者實現獲取一個WKA地址列表。兩個方法配置在operational override file的<well-know-address>的子元素<unicast-listener>。
 
6.1 指定WKA成員地址
 
WKA成員是明確指定在<socket-address>元素中。熱河數量的<socket-address>元素能夠被指定,每個都必須同時使用<address>個<port>元素定義WKA成員地址和端口號。如果cluster成員指定了自己的地址,那么它啟動時,cluster成員是一個WKA成員。WKA成員列表必須和每個cluster成員一樣,以確保不同的cluster成員不會在剩余的其他cluster中獨立操作。下面的例子指定了兩個WKA成員。
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
   xsi:schemaLocation="http://xmlns.oracle.com/coherence/
   coherence-operational-config coherence-operational-config.xsd">
   <cluster-config>
      <unicast-listener>
         <well-known-addresses>
            <socket-address id="1">
               <address>192.168.0.100</address>
               <port>8088</port>
            </socket-address>
            <socket-address id="2">
               <address>192.168.0.101</address>
               <port>8088</port>
            </socket-address>
         </well-known-addresses>
      </unicast-listener>
   </cluster-config>
</coherence>

 

使用WKA系統屬性
一個單一的WKA成員可以用tangosol.coherence.wka和tangosol.coherence.wka.port系統屬性指定,而不用在operational override file中指定地址。系統屬性是為了演示和測試場景,為了快速的指定一個單一的WKA成員。例如:
-Dtangosol.coherence.wka=192.168.0.100 -Dtangosol.coherence.wka.port=8088
為了創建一個額外的系統屬性來指定多個WKA成員地址,operational override file必須被用來定義多個WKA成員地址,必須給每個WKA成員地址元素定義一個system-property屬性。這個屬性必須包含系統屬性名稱用於覆蓋元素。下面的例子定義了包括系統屬性的兩個地址:
notice:在測試時候或者在管理生產環境時候可以定義額外的系統屬性來指定WKA成員地址的列表。然而,最佳的實踐是,在生產環境中僅使用operational override file來指定WKA成員。這確保了每個cluster成員是同一個WKA列表。
 
            
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
   xsi:schemaLocation="http://xmlns.oracle.com/coherence/
   coherence-operational-config coherence-operational-config.xsd">
   <cluster-config>
      <unicast-listener>
         <well-known-addresses>
            <socket-address id="1">
               <address system-property="tangosol.coherence.wka"></address>
               <port system-property="tangosol.coherence.wka.port"></port>
            </socket-address>
            <socket-address id="2">
               <address system-property="tangosol.coherence.wka2"></address>
               <port system-property="tangosol.coherence.wka2.port"></port>
            </socket-address>
         </well-known-addresses>
      </unicast-listener>
   </cluster-config>
</coherence>

上面的例子中,WKA成員地址是使用系統屬性來指定的:如下面所示:

-Dtangosol.coherence.wka=192.168.0.102 -Dtangosol.coherence.wka.port=8090 -Dtangosol.coherence.wka2=192.168.0.103 -Dtangosol.coherence.wka2.port=8094
6.2指定WKA地址提供者
 
WKA提示提供者提供了一種編程的方式定義WKA成員。WKA地址提供者必須實現com.tangosol.net.addressprovider接口。實現可以是簡單的靜態列表或復雜的使用動態發現協議。地址提供者必須返回一個結尾為null的地址,以表明所有的可用地址已經被返回。當cluster成員啟動后,地址提供者的實現會被調用。
為了使用WKA地址提供者的實現,增加一個<address-provider>元素,用<class-name>元素來指定完全限定名稱的實現類。例如:
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
   xsi:schemaLocation="http://xmlns.oracle.com/coherence/
   coherence-operational-config coherence-operational-config.xsd">
   <cluster-config>
      <unicast-listener>
         <well-known-addresses>
            <address-provider>
               <class-name>package.MyAddressProvider</class-name>
            </address-provider>
         </well-known-addresses>
      </unicast-listener>
   </cluster-config>
</coherence> 

 

作為一個解決方案, <address-provider>  元素支持使用 <class-factory-name>  元素用來指定一個工廠類來創建AddressProvider的實例,<method-name>元素指定了工廠類的靜態工廠方法,執行對象實例化。下面的例子是獲取一個地址提供者的實例,使用MyAddressProviderFactory類中的getAddressProvider方法。
 
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
   xsi:schemaLocation="http://xmlns.oracle.com/coherence/
   coherence-operational-config coherence-operational-config.xsd">
   <cluster-config>
      <unicast-listener>
         <well-known-addresses>
            <address-provider>
               <class-factory-name>package.MyAddressProviderFactory
               </class-factory-name>
               <method-name>getAddressProvider</method-name>
            </address-provider>
         </well-known-addresses>
      </unicast-listener>
   </cluster-config>
</coherence>

 

一個類或工廠實現所需的任何初始化參數能夠通過<init-params>元素指定。初始化參數能夠被支持   com.tangosol.run.xml.XmlConfigurable  接口的實現或者包含一個有匹配簽名的公共構造方法的實現來訪問。下面的例子設置iMaxTime參數為2000.
 
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
   xsi:schemaLocation="http://xmlns.oracle.com/coherence/
   coherence-operational-config coherence-operational-config.xsd">
   <cluster-config>
      <unicast-listener>
         <well-known-addresses>
            <address-provider>
               <class-name>package.MyAddressProvider</class-name>
               <init-params>
                  <init-param>
                     <param-name>iMaxTime</param-name>
                     <param-value>2000</param-value>
                  </init-param>
               </init-params>
            </address-provider>
         </well-known-addresses>
      </unicast-listener>
   </cluster-config>
</coherence>

 

7.啟動Single-Server模式
 
Single-Server模式輕質讓cluster運行在一台計算機上,不連接網絡。Single-Server模式提供了快速的方式來啟動和停止cluster,用來開發和單元測試。
 
為了開啟single-servier mode,編輯operational override file,並且增加一個<time-to-live>元素,設置為0,增加一個單播<address>元素,設置為可路由的回環地址。在大多數的計算機上,設置地址為127.0.0.1能夠工作。例如:
<?xml version='1.0'?>

<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
   xsi:schemaLocation="http://xmlns.oracle.com/coherence/
   coherence-operational-config coherence-operational-config.xsd">
   <cluster-config>
      <unicast-listener>
         <address system-property="tangosol.coherence.localhost">127.0.0.1
         </address>
      </unicast-listener>
      <multicast-listener>
         <time-to-live system-property="tangosol.coherence.ttl">0</time-to-live>
      </multicast-listener>
   </cluster-config>
</coherence>
tangosol.coherence.ttl和tangosol.coherence.localhost系統屬性被用來啟用single-server模式,而不用operational override file.例如:
-Dtangosol.coherence.ttl=0 -Dtangosol.coherence.localhost=127.0.0.1
在一些UNIX操作系統上,包括了一些Linux和Msc OS X,設置TTL為0,可能不足以隔離cluster到一個單獨的計算機。這種情況下,一個唯一的cluster 名,如email地址,必須配置。cluster成員如果使用一個不同的cluster名,可能不能加入一個已存在的cluster。
 
8.配置Death Detection
 
Death detection 是cluster的機制,用來快速檢測到當一個cluster成員失效。失效的cluster成員會被從cluster中移除,所有的其他cluster都會回被通知那個離開的成員。Death detection允許cluster區分actual member失效和unresponsive member,如當JVM進行一個完整的垃圾回收。
 
Death detection 通過在所有cluster成員中創建一個TCP環來工作。TCP通訊使用的端口和cluster的UDP通訊使用的端口是同一個。每個cluster成員發送一個單播的心跳包,最高級的cluster成員通過廣播發送心跳包。每個cluster成員用tcp鏈接通過心跳間隔檢測另一個節點的進程死亡(TCPring 組件)和硬件死亡(IPMonitor 組件)。Death detection默認開啟的。配置在<tcp-ring-listener>元素。
 
8.1更改TCP-Ring設置
 
有幾個設置用來改變TCP-ring監聽器的默認行為。這包括了更改在被宿主cluster成員的計算機變為不可達之前檢測到的嘗試和時間的數量。這些默認值從3~15秒鍾,分別的。TCP/IP服務器套接字緩沖隊列也能夠設置,默認值是使用操作系統提供的。
 
改變TCP-ring設置,編輯operational override file和增加下面的TCP-ring元素。
<?xml version='1.0'?>

<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
   xsi:schemaLocation="http://xmlns.oracle.com/coherence/
   coherence-operational-config coherence-operational-config.xsd">
   <cluster-config>
      <tcp-ring-listener>
         <ip-timeout system-property="tangosol.coherence.ipmonitor.pingtimeout">
         25s
         </ip-timeout>
         <ip-attempts>5</ip-attempts>
         <listen-backlog>10</listen-backlog>
      </tcp-ring-listener>
   </cluster-config>
</coherence>

 

tangosol.coherence.ipmonitor.pingtimeout系統屬性用來只用超時時間,而不用operational override file.例如:
-Dtangosol.coherence.ipmonitor.pingtimeout=20s
 
8.2 更改心跳間隔
death dection 的心跳間隔是能夠改變的。一個高的間隔可以減少最小的網絡流量,但是可能會增加檢測到失效成員的事件。默認的心跳值是1秒。
改變death detection 心跳間隔,編輯operational override file,並且增加一個含有值的<heartbeat-milliseconds>元素,例如:
<?xml version='1.0'?>

<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
   xsi:schemaLocation="http://xmlns.oracle.com/coherence/
   coherence-operational-config coherence-operational-config.xsd">
   <cluster-config>
      <packet-publisher>
         <packet-delivery>
            <heartbeat-milliseconds>5000</heartbeat-milliseconds>    
         </packet-delivery>
      </packet-publisher>
   </cluster-config>
</coherence>

 

8.3 禁用Death Detection
Death Detection 默認啟用,必須明確的禁用。禁用Death Detection減少的只是最小的網絡流量和延長檢測到失效成員。如果禁用了,cluster成員使用發送者重發數據包的超時時間來檢測另一個成員已經停止響應UDP數據包。默認的,超時時間間隔設置為5分鍾。
 
禁用Death Detection,編輯operational overrride file增加一個值為false的<enabled>元素。例如:
<?xml version='1.0'?>

<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
   xsi:schemaLocation="http://xmlns.oracle.com/coherence/
   coherence-operational-config coherence-operational-config.xsd">
   <cluster-config>
      <tcp-ring-listener>
         <enabled>false</enabled>
      </tcp-ring-listener>
   </cluster-config>
</coherence>
9.指定Cluster優先級
 
cluster優先級機制允許為cluster成員指定一個優先級的值和一個成員運行在不同的現成上。
 
9.1指定cluster 成員的優先級
 
cluster成員的優先級用來作為檢測成員時間tie-breakers的基本。如果發生這種情況,兩個成員從cluster中逐出,在極少的情況下,不可能客觀的決定兩個鍾的那個是錯誤的,應該被逐出,那么就將低優先級的成員逐出。
 
指定cluster成員優先級,編輯operational overrride file和增加<priority> 元素,在<member--identity>節點,包含了一個優先級的值,從1到10,1是優先級最高的。例如:
<?xml version='1.0'?>
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config"
   xsi:schemaLocation="http://xmlns.oracle.com/coherence/
   coherence-operational-config coherence-operational-config.xsd">
   <cluster-config>
      <member-identity>
         <priority system-property="tangosol.coherence.priority">1</priority>
      </member-identity>
   </cluster-config>
</coherence>

tangosol.coherence.priority系統熟悉能夠使用指定一個cluster成員的優先級,而不用operational overrride file.例如:

-Dtangosol.coherence.priority=1

9.2 指定進程優先級

多個cluster組件支持現成優先級。優先級用來作為檢測java 現成執行重要性的基本。組件包含:多播監聽器,單播監聽器,TCP ring監聽器,the packet speaker, the packet publisher,incoming message handler. 默認的優先級設置給了packet speaker最高優先級,接着是incoming message handler,接着是remaining components.

現成喲先機在每個組件的配置元素指定 (<unicast-listener>, <multicast-listener>, <packet-speaker>, <packet-publisher>, <tcp-ring-listener>, 和 <incoming-message-handler> 元素, 單獨的)。例如,指定單播監聽器的現成優先級,編輯operational override file和增加一個<priority>元素,在<unicast-listener>節點力,包含了從1到10的優先級的值,1的優先級最高。

<?xml version='1.0'?> 
<coherence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.oracle.com/coherence/coherence-operational-config" xsi:schemaLocation="http://xmlns.oracle.com/coherence/ coherence-operational-config coherence-operational-config.xsd"> 
    <cluster-config>
          <unicast-listener>
              <priority>5</priority> 
          </unicast-listener> 
    </cluster-config> 
</coherence>

 

 

 

 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM