このコンテンツは選択した言語では利用できません。
34.2. Configure Cross-Datacenter Replication Programmatically
The programmatic method to configure cross-datacenter replication in Red Hat JBoss Data Grid is as follows:
Procedure 34.1. Configure Cross-Datacenter Replication Programmatically
Identify the Node Location
Declare the site the node resides in:globalConfiguration.site().localSite("LON");globalConfiguration.site().localSite("LON");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure JGroups
Configure JGroups to use theRELAYprotocol:globalConfiguration.transport().addProperty("configurationFile", jgroups-with-relay.xml);globalConfiguration.transport().addProperty("configurationFile", jgroups-with-relay.xml);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up the Remote Site
Set up JBoss Data Grid caches to replicate to the remote site:Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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 abackupForcache 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.- Configure the cache in site
NYCto receive backup data fromLON:ConfigurationBuilder NYCbackupOfLon = new ConfigurationBuilder(); NYCbackupOfLon.sites().backupFor().remoteCache("lon").remoteSite("LON");ConfigurationBuilder NYCbackupOfLon = new ConfigurationBuilder(); NYCbackupOfLon.sites().backupFor().remoteCache("lon").remoteSite("LON");Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Configure the cache in site
SFOto receive backup data fromLON:ConfigurationBuilder SFObackupOfLon = new ConfigurationBuilder(); SFObackupOfLon.sites().backupFor().remoteCache("lon").remoteSite("LON");ConfigurationBuilder SFObackupOfLon = new ConfigurationBuilder(); SFObackupOfLon.sites().backupFor().remoteCache("lon").remoteSite("LON");Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Add the Contents of the Configuration File
As a default, Red Hat JBoss Data Grid includes JGroups configuration files such asdefault-configs/default-jgroups-tcp.xmlanddefault-configs/default-jgroups-udp.xmlin theinfinispan-embedded-{VERSION}.jarpackage.Copy the JGroups configuration to a new file (in this example, it is namedjgroups-with-relay.xml) and add the provided configuration information to this file. Note that therelay.RELAY2protocol configuration must be the last protocol in the configuration stack.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the relay.xml File
Set up therelay.RELAY2configuration in therelay.xmlfile. This file describes the global cluster configuration.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Global Cluster
The filejgroups-global.xmlreferenced inrelay.xmlcontains another JGroups configuration which is used for the global cluster: communication between sites.The global cluster configuration is usuallyTCP-based and uses theTCPPINGprotocol (instead ofPINGorMPING) to discover members. Copy the contents ofdefault-configs/default-jgroups-tcp.xmlintojgroups-global.xmland add the following configuration in order to configureTCPPING:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the hostnames (or IP addresses) inTCPPING.initial_hostswith those used for your site masters. The ports (7800in this example) must match theTCP.bind_port.For more information about theTCPPINGprotocol, refer to the JBoss Data Grid Administration and Configuration Guide.