이 콘텐츠는 선택한 언어로 제공되지 않습니다.
11.2. Run Red Hat JBoss Data Grid in a Cluster
11.2.1. Compile the Project 링크 복사링크가 클립보드에 복사되었습니다!
mvn clean compile dependency:copy-dependencies -DstripVersion
$ mvn clean compile dependency:copy-dependencies -DstripVersion
11.2.2. Run the Clustered Cache with Replication Mode 링크 복사링크가 클립보드에 복사되었습니다!
Procedure 11.1. Run the Clustered Cache with Replication Mode
- Use the following command to launch the first node:
java -cp target/classes/:target/dependency/* org.infinispan.quickstart.clusteredcache.replication.Node0
$ java -cp target/classes/:target/dependency/* org.infinispan.quickstart.clusteredcache.replication.Node0
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Use the following command to launch the second node:
java -cp target/classes/:target/dependency/* org.infinispan.quickstart.clusteredcache.replication.Node1
$ java -cp target/classes/:target/dependency/* org.infinispan.quickstart.clusteredcache.replication.Node1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
JGroups and JBoss Data Grid initialized on both nodes. After approximately fifteen seconds, the cache entry log message appears on the console of the first node.
11.2.3. Run the Clustered Cache with Distribution Mode 링크 복사링크가 클립보드에 복사되었습니다!
Procedure 11.2. Run the Clustered Cache with Distribution Mode
- Use the following command to launch the first node:
java -cp target/classes/:target/dependency/* org.infinispan.quickstart.clusteredcache.distribution.Node0
$ java -cp target/classes/:target/dependency/* org.infinispan.quickstart.clusteredcache.distribution.Node0
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Use the following command to launch the second node:
java -cp target/classes/:target/dependency/* org.infinispan.quickstart.clusteredcache.distribution.Node1
$ java -cp target/classes/:target/dependency/* org.infinispan.quickstart.clusteredcache.distribution.Node1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Use the following command to launch the third node:
java -cp target/classes/:target/dependency/* org.infinispan.quickstart.clusteredcache.distribution.Node2
$ java -cp target/classes/:target/dependency/* org.infinispan.quickstart.clusteredcache.distribution.Node2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
JGroups and JBoss Data Grid initialized on the three nodes. After approximately fifteen seconds, the ten entries added by the third node are visible as they are distributed to the first and second nodes.
11.2.4. Configure the Cluster 링크 복사링크가 클립보드에 복사되었습니다!
Procedure 11.3. Configure the Cluster
- Add the default configuration for a new cluster.
- Customize the default cluster configuration according to the requirements of your network. This is done declaratively (using XML) or programmatically.
- Configure the replicated or distributed data grid.
11.2.4.1. Add the Default Cluster Configuration 링크 복사링크가 클립보드에 복사되었습니다!
Example 11.2. Default Configuration
new ConfigurationBuilder() .clustering().cacheMode(CacheMode.REPL_SYNC) .build()
new ConfigurationBuilder()
.clustering().cacheMode(CacheMode.REPL_SYNC)
.build()
Note
GlobalConfigurationBuilder().clusteredDefault()
to quickly create a preconfigured and cluster-aware GlobalConfiguration
for clusters. This configuration can also be customized.
11.2.4.2. Customize the Default Cluster Configuration 링크 복사링크가 클립보드에 복사되었습니다!
Use the following GlobalConfiguration code to specify the name of the file to use for JGroups configuration:
new GlobalConfigurationBuilder().transport().addProperty("configurationFile", "jgroups.xml") .build()
new GlobalConfigurationBuilder().transport().addProperty("configurationFile", "jgroups.xml")
.build()
jgroups.xml
with the desired file name.
jgroups.xml
file is located at Infinispan-Quickstart/clustered-cache/src/main/resources/
.
Note
-Djgroups.bind_addr="127.0.0.1"
. This is particularly useful to test a cluster where all nodes are on a single machine.
Use the following XML snippet in the infinispan.xml
file to configure the JGroups properties to use Red Hat JBoss Data Grid's XML configuration:
11.2.4.3. Configure the Replicated Data Grid 링크 복사링크가 클립보드에 복사되었습니다!
Use the following code snippet to programmatically configure the cache for replication mode (either synchronous or asynchronous):
Edit the infinispan.xml
file to include the following XML code to declaratively configure the cache for replication mode (either synchronous or asynchronous):
private static EmbeddedCacheManager createCacheManagerFromXml() throws IOException { return new DefaultCacheManager("infinispan.xml");}
private static EmbeddedCacheManager createCacheManagerFromXml() throws IOException {
return new DefaultCacheManager("infinispan.xml");}
Note
org.infinispan.jmx.JmxDomainConflictException: Domain already registered org.infinispan
.
11.2.4.4. Configure the Distributed Data Grid 링크 복사링크가 클립보드에 복사되었습니다!
numOwners
parameter, which sets how many owners each entry has.
numOwners
value to set the desired trade off between space, durability and availability. Durability is further improved by JBoss Data Grid's topology aware consistent hash, which locates entry owners across a variety of data centers, racks and nodes.
Programmatically configure the cache for distributed mode (either synchronous or asynchronous) as follows:
new ConfigurationBuilder() .clustering() .cacheMode(CacheMode.DIST_SYNC) .hash().numOwners(2) .build()
new ConfigurationBuilder()
.clustering()
.cacheMode(CacheMode.DIST_SYNC)
.hash().numOwners(2)
.build()
Edit the infinispan.xml
file to include the following XML code to declaratively configure the cache for distributed mode (either synchronous or asynchronous):