 Apache Geode
  
    CHANGELOG
  Apache Geode
  
    CHANGELOG
  
        
  Tutorial—Creating and Using a Cluster Configuration
A short walk-through that uses a single computer to demonstrate how to use gfsh to create a cluster configuration for a Geode cluster.
The gfsh command-line tool allows you to configure and start a Geode cluster. The cluster configuration service uses Apache Geode locators to store the configuration at the group and cluster levels and serves these configurations to new members as they are started. The locators store the configurations in a hidden region that is available to all locators and also write the configuration data to disk as XML files. Configuration data is updated as gfsh commands are executed.
This section provides a walk-through example of configuring a simple Apache Geode cluster and then re-using that configuration in a new context.
- Create a working directory (For example: - /home/username/my_geode) and switch to the new directory. This directory will contain the configurations for your cluster.
- Start the - gfshcommand-line tool. For example:- $ gfsh- The - gfshcommand prompt displays.- _________________________ __ / _____/ ______/ ______/ /____/ / / / __/ /___ /_____ / _____ / / /__/ / ____/ _____/ / / / / /______/_/ /______/_/ /_/ 1.13 Monitor and Manage Apache Geode gfsh>
- Start a locator using the command in the following example: - gfsh>start locator --name=locator1 Starting a Geode Locator in /Users/username/my_geode/locator1... ............................. Locator in /Users/username/my_geode/locator1 on 192.0.2.0[10334] as locator1 is currently online. Process ID: 5203 Uptime: 15 seconds Geode Version: 1.13 Java Version: 1.8.0_121 Log File: /Users/username/my_geode/locator1/locator1.log JVM Arguments: -Dgemfire.enable-cluster-configuration=true -Dgemfire.load-cluster-configuration-from-dir=false -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806 Class-Path: /Users/username/Apache_Geode_1.0.0_Linux/lib/geode-dependencies.jar Successfully connected to: [host=192.0.2.0, port=1099] Cluster configuration service is up and running.- Note that - gfshresponds with a message indicating that the cluster configuration service is up and running. If you see a message indicating a problem, review the locator log file for possible errors. The path to the log file is displayed in the output from- gfsh.
- Start Apache Geode servers using the commands in the following example: - gfsh>start server --name=server1 --groups=group1 Starting a Geode Server in /Users/username/my_geode/server1... ..... Server in /Users/username/my_geode/server1 on 192.0.2.0[40404] as server1 is currently online. Process ID: 5627 Uptime: 2 seconds Geode Version: 1.13 Java Version: 1.8.0_121 Log File: /Users/username/my_geode/server1/server1.log JVM Arguments: -Dgemfire.default.locators=192.0.2.0[10334] -Dgemfire.groups=group1 -Dgemfire.use-cluster-configuration=true -XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806 Class-Path: /Users/username/Apache_Geode_1.0.0_Linux/lib/geode-dependencies.jar gfsh>start server --name=server2 --groups=group1 --server-port=40405 Starting a Geode Server in /Users/username/my_geode/server2... ..... Server in /Users/username/my_geode/server2 on 192.0.2.0[40405] as server2 is currently online. Process ID: 5634 Uptime: 2 seconds Geode Version: 1.13 Java Version: 1.8.0_121 Log File: /Users/username/my_geode/server2/server2.log JVM Arguments: -Dgemfire.default.locators=192.0.2.0[10334] -Dgemfire.groups=group1 -Dgemfire.use-cluster-configuration=true -XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806 Class-Path: /Users/username/Apache_Geode_1.0.0_Linux/lib/geode-dependencies.jar gfsh>start server --name=server3 --server-port=40406 Starting a Geode Server in /Users/username/my_geode/server3... ..... Server in /Users/username/my_geode/server3 on 192.0.2.0[40406] as server3 is currently online. Process ID: 5637 Uptime: 2 seconds Geode Version: 1.13 Java Version: 1.8.0_121 Log File: /Users/username/my_geode/server3/server3.log JVM Arguments: -Dgemfire.default.locators=192.0.2.0[10334] -Dgemfire.use-cluster-configuration=true -XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806 Class-Path: /Users/username/Apache_Geode_1.0.0_Linux/lib/geode-dependencies.jar- Note that the - gfshcommands you used to start- server1and- server2specify a group named- group1while the command for- server3did not specify a group name.
- Create some regions using the commands in the following example: - gfsh>create region --name=region1 --groups=group1 --type=REPLICATE Member | Status ------- | -------------------------------------- server2 | Region "/region1" created on "server2" server1 | Region "/region1" created on "server1" gfsh>create region --name=region2 --type=REPLICATE Member | Status ------- | -------------------------------------- server1 | Region "/region2" created on "server1" server2 | Region "/region2" created on "server2" server3 | Region "/region2" created on "server3"- Note that - region1is created on all cache servers that specified the group named- group1when starting the cache server (- server1and- server2, in this example).- region2is created on all members because no group was specified.
- Deploy jar files. Use the - gfsh deploycommand to deploy application jar files to all members or to a specified group of members. The following example deploys the- mx4j-3.0.1.jarand- ra.jarfiles from the distribution. (Note: This is only an example, you do not need to deploy these files to use the Cluster Configuration Service. Alternately, you can use any two jar files for this demonstration.)- gfsh>deploy --groups=group1 --jars=/lib/mx4j-3.0.1.jar Post substitution: deploy --groups=group1 --jars=/Users/username/Apache_Geode_1.0.0_Linux/lib/mx4j-3.0.1.jar Member | Deployed JAR | Deployed JAR Location ------- | ------------------ | ------------------------------------------------------- server1 | mx4j-3.0.1.jar | /Users/username/my_geode/server1/vf.gf#mx4j-3.0.1.jar#1 server2 | mx4j-3.0.1.jar | /Users/username/my_geode/server2/vf.gf#mx4j-3.0.1.jar#1 gfsh>deploy --jars=/lib/ra.jar Post substitution: deploy --jar=/Users/username/Apache_Geode_1.0.0_Linux/lib/ra.jar Member | Deployed JAR | Deployed JAR Location ------- | ------------ | ----------------------------------------------- server1 | ra.jar | /Users/username/my_geode/server1/vf.gf#ra.jar#1 server2 | ra.jar | /Users/username/my_geode/server1/vf.gf#ra.jar#1 server3 | ra.jar | /Users/username/my_geode/server1/vf.gf#ra.jar#1- Note that the - mx4j-3.0.1.jarfile was deployed only to the members of- group1and the- ra.jarwas deployed to all members.
- Export the cluster configuration. You can use the - gfsh export cluster-configurationcommand to create a zip file that contains the cluster’s persisted configuration. The zip file contains a copy of the contents of the- cluster_configdirectory. For example:- gfsh>export cluster-configuration --zip-file-name=/Users/username/myClConfig.zip- Apache Geode writes the cluster configuration to the specified zip file. - Downloading cluster configuration : /Users/username/myClConfig.zip- The remaining steps demonstrate how to use the cluster configuration you just created. 
- Shut down the cluster using the following commands: - gfsh>shutdown --include-locators=true As a lot of data in memory will be lost, including possibly events in queues, do you really want to shutdown the entire distributed system? (Y/n): Y Shutdown is triggered gfsh> No longer connected to 192.0.2.0[1099]. gfsh>
- Exit the - gfshcommand shell:- gfsh>quit Exiting...
- Create a new working directory (for example: - new_geode) and switch to the new directory.
- Start the - gfshcommand shell:- $ gfsh
- Start a new locator. For example: - gfsh>start locator --name=locator2 --port=10335 Starting a Geode Locator in /Users/username/new_geode/locator2... ............................. Locator in /Users/username/new_geode/locator2 on 192.0.2.0[10335] as locator2 is currently online. Process ID: 5749 Uptime: 15 seconds Geode Version: 1.13 Java Version: 1.8.0_121 Log File: /Users/username/new_geode/locator2/locator2.log JVM Arguments: -Dgemfire.enable-cluster-configuration=true -Dgemfire.load-cluster-configuration-from-dir=false -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806 Class-Path: /Users/username/Apache_Geode_1.0.0_Linux/lib/geode-dependencies.jar Successfully connected to: [host=192.0.2.0, port=1099] Cluster configuration service is up and running.
- Import the cluster configuration using the - import cluster-configurationcommand. For example:- gfsh>import cluster-configuration --zip-file-name=/Users/username/myClConfig.zip Cluster configuration successfully imported- Note that the - locator2directory now contains a- cluster_configsubdirectory.
- Start a server that does not reference a group: - gfsh>start server --name=server4 --server-port=40414 Starting a Geode Server in /Users/username/new_geode/server4... ........ Server in /Users/username/new_geode/server4 on 192.0.2.0[40414] as server4 is currently online. Process ID: 5813 Uptime: 4 seconds Geode Version: 1.13 Java Version: 1.8.0_121 Log File: /Users/username/new_geode/server4/server4.log JVM Arguments: -Dgemfire.default.locators=192.0.2.0[10335] -Dgemfire.use-cluster-configuration=true -XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806 Class-Path: /Users/username/Apache_Geode_1.0.0_Linux/lib/geode-dependencies.jar
- Start another server that references - group1:- gfsh>start server --name=server5 --groups=group1 --server-port=40415 Starting a Geode Server in /Users/username/new_geode/server5... ..... Server in /Users/username/new_geode/server2 on 192.0.2.0[40415] as server5 is currently online. Process ID: 5954 Uptime: 2 seconds Geode Version: 1.13 Java Version: 1.8.0_121 Log File: /Users/username/new_geode/server5/server5.log JVM Arguments: -Dgemfire.default.locators=192.0.2.0[10335] -Dgemfire.groups=group1 -Dgemfire.use-cluster-configuration=true -XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806 Class-Path: /Users/username/Apache_Geode_1.0.0_Linux/lib/geode-dependencies.jar
- Use the - list regionscommand to display the configured regions. Note that region1 and region2, which were configured in the original cluster level are available.- gfsh>list regions List of regions --------------- region1 region2
- Use the - describe regioncommand to see which members host each region. Note that region1 is hosted only by server5 because server5 was started using the group1 configuration. region2 is hosted on both server4 and server5 because region2 was created without a group specified.- gfsh>describe region --name=region1 .......................................................... Name : region1 Data Policy : replicate Hosting Members : server5 Non-Default Attributes Shared By Hosting Members Type | Name | Value ------ | ----------- | --------------- Region | data-policy | REPLICATE | size | 0 | scope | distributed-ack gfsh>describe region --name=region2 .......................................................... Name : region2 Data Policy : replicate Hosting Members : server5 server4 Non-Default Attributes Shared By Hosting Members Type | Name | Value ------ | ----------- | --------------- Region | data-policy | REPLICATE | size | 0 | scope | distributed-ack- This new cluster uses the same configuration as the original system. You can start any number of servers using this cluster configuration. All servers will receive the cluster-level configuration. Servers that specify - group1also receive the- group1configuration.
- Shut down your cluster using the following commands: - gfsh>shutdown --include-locators=true As a lot of data in memory will be lost, including possibly events in queues, do you really want to shutdown the entire distributed system? (Y/n): Y Shutdown is triggered gfsh> No longer connected to 192.0.2.0[1099].