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>
 
 
 

原文地址:https://www.cnblogs.com/danye/p/CoherenceCluster.html