第2章 クロスサイトレプリケーションのための Data Grid の設定
サイト間でデータをレプリケートするように Data Grid を設定するには、最初にクラスタートランスポートをセットアップして、Data Grid クラスターが相互に検出し、サイトマスターが通信できるようにします。次に、バックアップの場所を Data Grid 設定のキャッシュ定義に追加します。
2.1. クロスサイトレプリケーションのためのクラスタートランスポートの設定
Data Grid クラスターがバックアップの場所と通信できるように、JGroups RELAY2 をトランスポート層に追加します。
手順
-
infinispan.xml
を開いて編集します。 - RELAY2 プロトコルを JGroups スタックに追加します。
スタックを使用するように Data Grid クラスタートランスポートを設定します。
<infinispan> <jgroups> <!-- Extends the default UDP stack. --> <stack name="xsite" extends="udp"> <!-- Adds RELAY2 for cross-site replication. --> <!-- Names the local site as LON. --> <!-- Specifies 1000 nodes as the maximum number of site masters. --> <relay.RELAY2 site="LON" xmlns="urn:org:jgroups" max_site_masters="1000"/> <!-- Uses the default TCP stack for inter-cluster communication. --> <!-- Names all sites that act as backup locations. --> <remote-sites default-stack="tcp"> <remote-site name="LON"/> <remote-site name="NYC"/> </remote-sites> </stack> </jgroups> <cache-container name="default" statistics="true"> <!-- Use the "xsite" stack for cluster transport. --> <transport cluster="${cluster.name}" stack="xsite"/> </cache-container> </infinispan>
<infinispan> <jgroups> <!-- Extends the default UDP stack. --> <stack name="xsite" extends="udp"> <!-- Adds RELAY2 for cross-site replication. --> <!-- Names the local site as LON. --> <!-- Specifies 1000 nodes as the maximum number of site masters. --> <relay.RELAY2 site="LON" xmlns="urn:org:jgroups" max_site_masters="1000"/> <!-- Uses the default TCP stack for inter-cluster communication. --> <!-- Names all sites that act as backup locations. --> <remote-sites default-stack="tcp"> <remote-site name="LON"/> <remote-site name="NYC"/> </remote-sites> </stack> </jgroups> <cache-container name="default" statistics="true"> <!-- Use the "xsite" stack for cluster transport. --> <transport cluster="${cluster.name}" stack="xsite"/> </cache-container> </infinispan>
Copy to Clipboard Copied! -
infinispan.xml
を保存して閉じます。
2.1.1. JGroups RELAY2 スタック
Data Grid クラスターは、クラスター間の検出および通信に JGroups RELAY2 を使用します。
<jgroups> <!-- Uses the default JGroups UDP stack for intra-cluster traffic. --> <stack name="xsite" extends="udp"> <!-- Adds RELAY2 to the stack for inter-cluster transport. --> <!-- Names the local site. Data in caches from the local site is replicated to backup locations. --> <!-- Configures a maximum of 1000 site masters for the local cluster. --> <relay.RELAY2 xmlns="urn:org:jgroups" site="LON" max_site_masters="1000"/> <!-- Specifies all site names and uses the default JGroups TCP stack for inter-cluster transport. --> <remote-sites default-stack="tcp"> <!-- Names all sites that participate in cross-site replication. --> <remote-site name="LON"/> <remote-site name="NYC"/> </remote-sites> </stack> </jgroups>
<jgroups>
<!-- Uses the default JGroups UDP stack for intra-cluster traffic. -->
<stack name="xsite" extends="udp">
<!-- Adds RELAY2 to the stack for inter-cluster transport. -->
<!-- Names the local site. Data in caches from the local site is replicated to backup locations. -->
<!-- Configures a maximum of 1000 site masters for the local cluster. -->
<relay.RELAY2 xmlns="urn:org:jgroups"
site="LON"
max_site_masters="1000"/>
<!-- Specifies all site names and uses the default JGroups TCP stack for inter-cluster transport. -->
<remote-sites default-stack="tcp">
<!-- Names all sites that participate in cross-site replication. -->
<remote-site name="LON"/>
<remote-site name="NYC"/>
</remote-sites>
</stack>
</jgroups>
バックアップ要求で最適なパフォーマンスを得るには、max_site_masters
に Data Grid クラスター内のノード数以上の値を設定します。
2.1.2. カスタム JGroups RELAY2 スタック
以下の設定は、デフォルトの TCP スタックを拡張するカスタムの RELAY2 スタックを追加します。
<jgroups> <!-- Uses TCPPING instead of MPING for discovery. --> <stack name="relay-global" extends="tcp"> <MPING stack.combine="REMOVE"/> <TCPPING initial_hosts="192.0.2.0[7800]" stack.combine="INSERT_AFTER" stack.position="TCP"/> </stack> <!-- Extends the default UDP stack with RELAY2. --> <!-- Specifies RELAY2 properties. --> <stack name="xsite" extends="udp"> <relay.RELAY2 site="LON" xmlns="urn:org:jgroups" max_site_masters="10" can_become_site_master="true"/> <remote-sites default-stack="relay-global"> <remote-site name="LON"/> <remote-site name="NYC"/> </remote-sites> </stack> </jgroups>
<jgroups>
<!-- Uses TCPPING instead of MPING for discovery. -->
<stack name="relay-global" extends="tcp">
<MPING stack.combine="REMOVE"/>
<TCPPING initial_hosts="192.0.2.0[7800]"
stack.combine="INSERT_AFTER"
stack.position="TCP"/>
</stack>
<!-- Extends the default UDP stack with RELAY2. -->
<!-- Specifies RELAY2 properties. -->
<stack name="xsite" extends="udp">
<relay.RELAY2 site="LON" xmlns="urn:org:jgroups"
max_site_masters="10"
can_become_site_master="true"/>
<remote-sites default-stack="relay-global">
<remote-site name="LON"/>
<remote-site name="NYC"/>
</remote-sites>
</stack>
</jgroups>
また、外部で定義された JGroups スタックファイルを参照することもできます。以下に例を示します。
<infinispan> <jgroups> <stack-file name="relay-global" path="jgroups-relay.xml"/> </jgroups> <cache-container default-cache="replicatedCache"> <transport stack="relay-global" /> <replicated-cache name="replicatedCache"/> </cache-container> </infinispan>
<infinispan>
<jgroups>
<stack-file name="relay-global" path="jgroups-relay.xml"/>
</jgroups>
<cache-container default-cache="replicatedCache">
<transport stack="relay-global" />
<replicated-cache name="replicatedCache"/>
</cache-container>
</infinispan>
jgroups-relay.xml
は、以下のような JGroups スタックファイルを参照します。
<config xmlns="urn:org:jgroups" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.1.xsd"> <!-- Use TCP for inter-cluster transport. --> <TCP bind_addr="127.0.0.1" bind_port="7200" port_range="30" thread_pool.min_threads="0" thread_pool.max_threads="8" thread_pool.keep_alive_time="5000" /> <!-- Use TCPPING for inter-cluster discovery. --> <TCPPING timeout="3000" initial_hosts="127.0.0.1[7200]" port_range="3" ergonomics="false"/> <!-- Provide other JGroups stack configuration as required. --> </config>
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.1.xsd">
<!-- Use TCP for inter-cluster transport. -->
<TCP bind_addr="127.0.0.1"
bind_port="7200"
port_range="30"
thread_pool.min_threads="0"
thread_pool.max_threads="8"
thread_pool.keep_alive_time="5000"
/>
<!-- Use TCPPING for inter-cluster discovery. -->
<TCPPING timeout="3000"
initial_hosts="127.0.0.1[7200]"
port_range="3"
ergonomics="false"/>
<!-- Provide other JGroups stack configuration as required. -->
</config>