이 콘텐츠는 선택한 언어로 제공되지 않습니다.

29.2. Configure Cross-Datacenter Replication


29.2.1. Configure Cross-Datacenter Replication (Remote Client-Server Mode)

In Red Hat JBoss Data Grid's Remote Client-Server mode, cross-datacenter replication is set up as follows:

Procedure 29.1. Set Up Cross-Datacenter Replication

  1. Set Up RELAY

    Add the following configuration to the standalone.xml file to set up RELAY:
    <subsystem xmlns="urn:jboss:domain:jgroups:1.2" 
    	   default-stack="udp">
    	<stack name="udp">
    		<transport type="UDP" 
    			   socket-binding="jgroups-udp"/>
    		...
    		
    		<relay site="LON">
    		   <remote-site name="NYC" stack="tcp" cluster="global"/>
    		   <remote-site name="SFO" stack="tcp" cluster="global"/>
    		   <property name="relay_multicasts">false</property>
    		</relay>
    	</stack>
    </subsystem>
    Copy to Clipboard Toggle word wrap
    The RELAY protocol creates an additional stack (running parallel to the existing TCP stack) to communicate with the remote site. If a TCP based stack is used for the local cluster, two TCP based stack configurations are required: one for local communication and one to connect to the remote site. For an illustration, see Section 29.1, “Cross-Datacenter Replication Operations”
  2. Set Up Sites

    Use the following configuration in the standalone.xml file to set up sites for each distributed cache in the cluster:
    <distributed-cache>
         ...
         <backups>
            <backup site="{FIRSTSITENAME}" strategy="{SYNC/ASYNC}" />
            <backup site="{SECONDSITENAME}" strategy="{SYNC/ASYNC}" />
         </backups>
    </distributed-cache>
    Copy to Clipboard Toggle word wrap
  3. Configure Local Site Transport

    Add the name of the local site in the transport element to configure transport:
    <transport executor="infinispan-transport" 
               lock-timeout="60000" 
               cluster="LON" 
               stack="udp"/>
    Copy to Clipboard Toggle word wrap

29.2.2. Configure Cross-Data Replication (Library Mode)

29.2.2.1. Configure Cross-Datacenter Replication Declaratively

When configuring Cross-Datacenter Replication, the relay.RELAY2 protocol creates an additional stack (running parallel to the existing TCP stack) to communicate with the remote site. If a TCP-based stack is used for the local cluster, two TCP based stack configurations are required: one for local communication and one to connect to the remote site.
In JBoss Data Grid's Library mode, cross-datacenter replication is set up as follows:

Procedure 29.2. Setting Up Cross-Datacenter Replication

  1. Configure the Local Site

    Add the site element to the global element to add the local site (in this example, the local site is named LON).
    <infinispan>
       <global>
          ...
          <site local="LON" />
          ...   
       </global>
    </infinispan>
    Copy to Clipboard Toggle word wrap
  2. Configure JGroups for the Local Site

    Cross-site replication requires a non-default JGroups configuration. Add the transport element and set up the path to the configuration file as the configurationFile property. In this example, the JGroups configuration file is named jgroups-with-relay.xml.
    <infinispan>
       <global>
          ...
          <site local="LON" />
          <transport clusterName="default"> 
             <properties> 
                 <property name="configurationFile" value="jgroups-with-relay.xml" />     
              </properties> 
          </transport> 
          ...   
       </global>
    </infinispan>
    Copy to Clipboard Toggle word wrap
  3. Configure the LON Cache

    Configure the cache in site LON to back up to the sites NYC and SFO:
    <infinispan>
       <global>      
          <site local="LON" />
          <transport clusterName="default"> 
             <properties> 
                 <property name="configurationFile" value="jgroups-with-relay.xml" />     
              </properties> 
          </transport> 
          ...   
       </global>
       ...
       <namedCache name="lon">
          <sites>
             <backups>
                <backup site="NYC" 
    		    strategy="SYNC" 
    		    backupFailurePolicy="WARN" />
                <backup site="SFO" 
    		    strategy="ASYNC" 
    		    backupFailurePolicy="IGNORE"/>
             </backups>
          </sites>
       </namedCache>
    </infinispan>
    Copy to Clipboard Toggle word wrap
  4. Configure the Back Up Caches

    1. Configure the cache in site NYC to receive back up data from LON:
      <infinispan>
         <global>      
            <site local="NYC" />
            <transport clusterName="default"> 
               <properties> 
                   <property name="configurationFile" value="jgroups-with-relay.xml"/>     
                </properties> 
            </transport>
            ...   
         </global>
         ...
         <namedCache name="lonBackup">
            <sites>
               <backupFor remoteSite="LON" 
      		    remoteCache="lon" />
            </sites>
         </namedCache>
      </infinispan>
      Copy to Clipboard Toggle word wrap
    2. Configure the cache in site SFO to receive back up data from LON:
      <infinispan>
         <global>      
            <site local="SFO" />
            <transport clusterName="default"> 
               <properties> 
                   <property name="configurationFile" value="jgroups-with-relay.xml"/>     
                </properties> 
            </transport>
            ...   
         </global>
         ...
         <namedCache name="lonBackup">
            <sites>
               <backupFor remoteSite="LON" 
      		    remoteCache="lon" />
            </sites>
         </namedCache>
      </infinispan>
      Copy to Clipboard Toggle word wrap
  5. Add the Contents of the Configuration File

    As a default, Red Hat JBoss Data Grid includes JGroups configuration files such as jgroups-tcp.xml and jgroups-udp.xml in the infinispan-core-{VERSION}.jar package.
    Copy the JGroups configuration to a new file (in this example, it is named jgroups-with-relay.xml) and add the provided configuration information to this file. Note that the relay.RELAY2 protocol configuration must be the last protocol in the configuration stack.
    <config> 
        ... 
        <relay.RELAY2 site="LON" 
                  config="relay.xml"
                  relay_multicasts="false" />
    </config>
    Copy to Clipboard Toggle word wrap
  6. Configure the relay.xml File

    Set up the relay.RELAY2 configuration in the relay.xml file. This file describes the global cluster configuration.
    <RelayConfiguration> 
        <sites> 
            <site name="LON" 
                  id="0"> 
                <bridges> 
                    <bridge config="jgroups-global.xml" 
                            name="global"/> 
                    </bridges> 
            </site>  
            <site name="NYC" 
                  id="1"> 
                <bridges> 
                    <bridge config="jgroups-global.xml" 
                            name="global"/> 
                    </bridges> 
            </site>  
            <site name="SFO" 
                  id="2"> 
                <bridges> 
                    <bridge config="jgroups-global.xml" 
                            name="global"/> 
                </bridges> 
            </site> 
        </sites> 
    </RelayConfiguration>
    Copy to Clipboard Toggle word wrap
  7. Configure the Global Cluster

    The file jgroups-global.xml referenced in relay.xml contains another JGroups configuration which is used for the global cluster: communication between sites.
    The global cluster configuration is usually TCP-based and uses the TCPPING protocol (instead of PING or MPING) to discover members. Copy the contents of jgroups-tcp.xml into jgroups-global.xml and add the following configuration in order to configure TCPPING:
    <config> 
        <TCP bind_port="7800" ... /> 
        <TCPPING initial_hosts="lon.hostname[7800],nyc.hostname[7800],sfo.hostname[7800]"     
                 num_initial_members="3" 
                 ergonomics="false" /> 
              <!-- Rest of the protocols --> 
    </config>
    Copy to Clipboard Toggle word wrap
    Replace the hostnames (or IP addresses) in TCPPING.initial_hosts with those used for your site masters. The ports (7800 in this example) must match the TCP.bind_port.
    For more information about the TCPPING protocol, see Section 26.2.1.3, “Using the TCPPing Protocol”

29.2.2.2. Configure Cross-Datacenter Replication Programmatically

The programmatic method to configure cross-datacenter replication in Red Hat JBoss Data Grid is as follows:

Procedure 29.3. Configure Cross-Datacenter Replication Programmatically

  1. Identify the Node Location

    Declare the site the node resides in:
    globalConfiguration.site().localSite("LON");
    Copy to Clipboard Toggle word wrap
  2. Configure JGroups

    Configure JGroups to use the RELAY protocol:
    globalConfiguration.transport().addProperty("configurationFile", jgroups-with-relay.xml);
    Copy to Clipboard Toggle word wrap
  3. Set Up the Remote Site

    Set up JBoss Data Grid caches to replicate to the remote site:
    ConfigurationBuilder lon = new ConfigurationBuilder();
    lon.sites().addBackup()
          .site("NYC")
          .backupFailurePolicy(BackupFailurePolicy.WARN)
          .strategy(BackupConfiguration.BackupStrategy.SYNC)
          .replicationTimeout(12000)
          .sites().addInUseBackupSite("NYC")
        .sites().addBackup()
          .site("SFO")
          .backupFailurePolicy(BackupFailurePolicy.IGNORE)
          .strategy(BackupConfiguration.BackupStrategy.ASYNC)
          .sites().addInUseBackupSite("SFO")
    Copy to Clipboard Toggle word wrap
  4. Optional: Configure the Backup Caches

    JBoss Data Grid implicitly replicates data to a cache with same name as the remote site. If a backup cache on the remote site has a different name, users must specify a backupFor cache to ensure data is replicated to the correct cache.

    Note

    This step is optional and only required if the remote site's caches are named differently from the original caches.
    1. Configure the cache in site NYC to receive backup data from LON:
      ConfigurationBuilder NYCbackupOfLon = new ConfigurationBuilder();
      lonBackup.sites().backupFor().remoteCache("lon").remoteSite("LON");
      Copy to Clipboard Toggle word wrap
    2. Configure the cache in site SFO to receive backup data from LON:
      ConfigurationBuilder SFObackupOfLon = new ConfigurationBuilder();
      lonBackup.sites().backupFor().remoteCache("lon").remoteSite("LON");
      Copy to Clipboard Toggle word wrap
  5. Add the Contents of the Configuration File

    As a default, Red Hat JBoss Data Grid includes JGroups configuration files such as jgroups-tcp.xml and jgroups-udp.xml in the infinispan-core-{VERSION}.jar package.
    Copy the JGroups configuration to a new file (in this example, it is named jgroups-with-relay.xml) and add the provided configuration information to this file. Note that the relay.RELAY2 protocol configuration must be the last protocol in the configuration stack.
    <config> 
        ... 
        <relay.RELAY2 site="LON" 
                  config="relay.xml"
                  relay_multicasts="false" /> 
    </config>
    Copy to Clipboard Toggle word wrap
  6. Configure the relay.xml File

    Set up the relay.RELAY2 configuration in the relay.xml file. This file describes the global cluster configuration.
    <RelayConfiguration> 
        <sites> 
            <site name="LON" 
                  id="0"> 
                <bridges> 
                    <bridge config="jgroups-global.xml" 
                            name="global"/> 
                    </bridges> 
            </site>  
            <site name="NYC" 
                  id="1"> 
                <bridges> 
                    <bridge config="jgroups-global.xml" 
                            name="global"/> 
                    </bridges> 
            </site>  
            <site name="SFO" 
                  id="2"> 
                <bridges> 
                    <bridge config="jgroups-global.xml" 
                            name="global"/> 
                </bridges> 
            </site> 
        </sites> 
    </RelayConfiguration>
    Copy to Clipboard Toggle word wrap
  7. Configure the Global Cluster

    The file jgroups-global.xml referenced in relay.xml contains another JGroups configuration which is used for the global cluster: communication between sites.
    The global cluster configuration is usually TCP-based and uses the TCPPING protocol (instead of PING or MPING) to discover members. Copy the contents of jgroups-tcp.xml into jgroups-global.xml and add the following configuration in order to configure TCPPING:
    <config> 
        <TCP bind_port="7800" ... /> 
        <TCPPING initial_hosts="lon.hostname[7800],nyc.hostname[7800],sfo.hostname[7800]"     
                 num_initial_members="3" 
                 ergonomics="false" /> 
              <!-- Rest of the protocols --> 
    </config>
    Copy to Clipboard Toggle word wrap
    Replace the hostnames (or IP addresses) in TCPPING.initial_hosts with those used for your site masters. The ports (7800 in this example) must match the TCP.bind_port.
    For more information about the TCPPING protocol, see Section 26.2.1.3, “Using the TCPPing Protocol”
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat