第 2 章 为跨站点复制配置数据网格


配置 Data Grid 以跨站点复制数据,首先设置集群传输,以便数据网格集群可以相互发现,站点 master 可以进行通信。然后,您将备份位置添加到 Data Grid 配置中的缓存定义中。

2.1. 为跨站点复制配置集群传输

将 JGroups RELAY2 添加到您的传输层,以便数据网格集群可以与备份位置通信。

流程

  1. 打开 infinispan.xml 进行编辑。
  2. 将 RELAY2 协议添加到 JGroups 堆栈。
  3. 配置 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>
    Copy to Clipboard Toggle word wrap
  4. 保存并关闭 infinispan.xml

2.1.1. JGroups RELAY2 Stacks

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>
Copy to Clipboard Toggle word wrap
提示

设置 max_site_masters >= Data Grid 集群中的节点数,以实现使用备份请求的最佳性能。

2.1.2. 自定义 JGroups RELAY2 Stacks

以下配置添加了扩展默认 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>
Copy to Clipboard Toggle word wrap

您还可以引用外部定义的 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>
Copy to Clipboard Toggle word wrap

其中 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>
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat