原文鏈接http://docs.oracle.com/cd/E24290_01/coh.371/e22837/cluster_setup.htm#CHDFCBIG
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> <cluster-name system-property="tangosol.coherence.cluster"> MyCluster </cluster-name> </member-identity> </cluster-config> </coherence>
- 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),如果沒有指定角色名。
<?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>
<?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>
<?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>
<?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>
<?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>
- 數據包被發往網絡上的多個節點(d>1)
- 節點的數量大於指定的threshold(d>(n-1)*(threshold/100))
<?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>
<?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>
<?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>
-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
<?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>
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>
<?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
<?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>
-Dtangosol.coherence.ipmonitor.pingtimeout=20s
<?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>
<?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>
<?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>