This topic explains how to create a VMware GemFire cluster or service instance with the VMware GemFire for Redis Apps add-on enabled.

VMware GemFire

Prerequisites

Start a VMware GemFire Cluster

  1. Open a terminal window.

  2. In the terminal window, confirm that you have installed VMware GemFire 9.15 or later by running:

    gfsh version
    

    The output text should read 9.15.0 or later. If it does not, download and install VMware GemFire 9.15 or later. For installation instructions, see Installing VMware GemFire in the VMware GemFire documentation.

  3. Start the GemFire CLI, gfsh, by running:

    gfsh
    
  4. At the gfsh prompt, start a locator for managing the VMware GemFire cluster:

    gfsh> start locator
    
  5. After the locator has started, start a server. Use the --classpath configuration option to specify the filepath to the folder where you unzipped the VMware GemFire for Redis Apps add-on files to enable the add-on:

    gfsh> start server --name=redisServer1 --locators=localhost[10334] --server-port=40404 --classpath=/path/to/gemfire-for-redis-apps/folder/lib/* --J=-Dgemfire-for-redis-enabled=true
    
  6. Start an additional server with the add-on enabled by running the same start server command with different values for the --name and --gemfire-for-redis-port parameters:

    gfsh> start server --name=redisServer2 --locators=localhost[10334] --server-port=40405 --classpath=/path/to/gemfire-for-redis-apps/folder/lib/* --J=-Dgemfire-for-redis-port=6380  --J=-Dgemfire-for-redis-enabled=true
    
  7. Your GemFire cluster should now be running with one locator and two servers, ready to connect with a Redis client.

  8. To confirm that your GemFire cluster is ready to accept Redis commands, run the list regions command

    gfsh list regions
    

The output should include the GEMFIRE_FOR_REDIS region in the list of regions:

 List of regions
 -----------------
 GEMFIRE_FOR_REDIS

At this point, the cluster is up and running and able to have Redis client applications connect and send commands.

Shut Down the VMware GemFire Cluster

To shut down the VMware GemFire cluster that you started, run the command below in the terminal window with gfsh running.

Warning: This command shuts down the entire VMware GemFire cluster. All data in the cluster will be lost.

gfsh> shutdown --include-locators=true

VMware GemFire for TAS

Prerequisites

Confirm that VMware GemFire Service Instance is Available in the Marketplace

The following instructions use the cf CLI; however, users can also confirm using the Apps Manager user interface if it is available to them.

  1. Log in to your Tanzu Application Service.

    cf login
    
  2. Once logged in, run the cf marketplace command to see available services in the marketplace and confirm that a service with the description VMware GemFire appears in the list.

    For example:

    $ cf marketplace
    Getting services from marketplace in org system / space system as admin...
    OK
    
    service       plans     description                                      broker
    nfs           Existing  Existing NFSv3 and v4 volumes                    nfsbroker
    p-cloudcache  dev-plan  VMware GemFire(version "1.13.0-build.24")  cloudcache-broker
    

Start a VMware GemFire Service Instance with GemFire For Redis Apps add-on Enabled

  1. Open a terminal window and log in to the space you would like to start the GemFire for TAS service instance.

  2. Enable APIs for Redis and add the “redis” tag to your VMware GemFire for TAS service.

    • When creating a new service, include -c '{"gemfire_for_redis_enabled":true, "gemfire_for_redis_redundant_copies":N} -t redis to the cf create-service command. N can be 0, 1, 2, or 3, and sets the number of redundant copies created. If not set, redundant copies will default to 1.

      For example:

      $ cf create-service p-cloudcache PLAN-NAME YOUR-SERVICE-INSTANCE-NAME -c '{"gemfire_for_redis_enabled":true,"gemfire_for_redis_redundant_copies":2}' -t redis
      
    • When updating an existing service, add -c '{"gemfire_for_redis_enabled":true, "gemfire_for_redis_redundant_copies":N} -t "redis to the cf update-service command. N can be 0, 1, 2, or 3, and sets the number of redundant copies created. If not set, redundant copies will default to 1.

      For example:

      $ cf update-service YOUR-SERVICE-NAME -c '{"gemfire_for_redis_enabled":true,"gemfire_for_redis_redundant_copies":2}' -t "redis"
      

      Note: Updating the service causes all members of the cluster to restart.

  3. (Optional) Transport Layer Security (TLS): VMware GemFire for TAS allows service instances to be created with Transport Layer Security (TLS) enabled. The behavior of TLS with GemFire for TAS and GemFire for Redis Apps differs from the Redis for TAS tile, which allows TLS and non-TLS ports to be active at the same time on a single service instance. GemFire for TAS only allows TLS to be on or off, not both/optional. TLS can only be enabled during service instance creation. If you enable TLS, all connections must be made using a TLS-capable client. The non-TLS port will be unavailable.

    To enable GemFire for Redis Apps and TLS on a VMware GemFire for TAS service instance, add tls:true to the parameters passed to the cf create-service command:

    For example:

    $ cf create-service p-cloudcache PLAN-NAME YOUR-SERVICE-INSTANCE-NAME -c '{"gemfire_for_redis_enabled":true,"tls":true}' -t redis
    

    Note: This enables TLS for the entire cluster.

Confirm that the add-on is enabled.

To confirm that the GemFire for Redis Apps add-on is enabled, when the cluster is up and running, confirm that the GEMFIRE_FOR_REDIS region is present in the cluster.

  1. Create a service key by running the following command:

    cf create-service-key MY-SERVICE-INSTANCE MY-KEY
    
  2. Inspect the service key:

    cf service-key MY-SERVICE-INSTANCE MY-KEY
    

    This returns a JSON response (VCAP_SERVICES) which includes a connection string to use with GemFire Shell (gfsh). For example:

    {...
     "gfsh_login_string": "connect
      --url=https://cloudcache-1.example.com/gemfire/v1
      --user=cluster_operator_XXX --password=cluster_operator-password --skip-ssl-validation"
    }
    
  3. Open a different terminal window.

  4. In the terminal window, confirm that you have installed VMware GemFire 9.15 or later by running:

    gfsh version
    

    The output text should read 9.15.0 or later. If it does not, download and install VMware GemFire 9.15 or later. For installation instructions, see Installing VMware GemFire in the VMware GemFire documentation.

  5. Start the GemFire CLI, gfsh, by running:

    gfsh
    
  6. Copy the content following the gfsh_login_string in the service instance key (step 2, above) and paste it into the gfsh terminal.

    gfsh connect --url=https://cloudcache-1.example.com/gemfire/v1 --user=cluster_operator_XXX --password=cluster_operator-password --skip-ssl-validation
    
  7. Once connected to the service instance run the list regions command

    gfsh list regions
    

    The output should include the following:

    List of regions
    -----------------
    GEMFIRE_FOR_REDIS
    

At this point the service instance is up and running and able to have Redis client applications bind to the GemFire service instance.

  • For information about how to bind a Spring Boot and Redis client application to the GemFire service instance, see Application Development
  • For more information about connecting to a GemFire service instance, see Accessing a Service Instance in the VMware GemFire for TAS documentation.

VMware GemFire for Kubernetes

Start a VMware GemFire Kubernetes Cluster

Follow the steps in this section to create a VMware GemFire for Kubernetes cluster with the VMware GemFire for Redis Apps add-on enabled.

Prerequisites

  • A Kubernetes Cluster with the VMware GemFire for Kubernetes v2.0+ Operator installed.
  • A VMware Tanzu Network account or the ability to access the VMware GemFire for Redis Apps image.

Start a VMware GemFire Kubernetes Cluster

  1. Follow the instructions in the GemFire for Kubernetes documentation to install the GemFire Operator.
  2. Once the operator is installed create a yaml file that will be used to start your GemFire cluster, note the name of the file as this will be used in the next step.

    For example, a simple yaml file may look like the following:

    apiVersion: gemfire.vmware.com/v1
    kind: GemFireCluster
    metadata:
      name: gemfirecluster-with-redis-sample
    spec:
      # Avoid using the "latest" tag in production as it is harder to track which
      # version of the image is running and may cause members to upgrade
      # unexpectedly.
      image: registry.tanzu.vmware.com/pivotal-gemfire/vmware-gemfire:9.15.1
      # Set antiAffinityPolicy to "Cluster" or "Full" in production to limit the
      # chance of data loss.
      antiAffinityPolicy: None
      security:
        tls: {}
      metrics:
        emission: Default
      locators:
        replicas: 2
        resources:
          requests:
            memory: 1Gi
      servers:
        replicas: 2
        resources:
          requests:
            memory: 1Gi
        libraries:
          - name: gemfire-for-redis-apps
            container:
              image: registry.tanzu.vmware.com/tanzu-gemfire-for-redis-apps/gemfire-for-redis-apps:1.0.1
              path: "/gemfire-for-redis-apps/*"
              imagePullSecretRef:
                name: image-pull-secret
        overrides:
          jvmOptions: ["-Dgemfire-for-redis-enabled=true"]
    
  3. Create a GemFire cluster with GemFire for Redis Apps by applying the file created above to your Kubernetes cluster.

    kubectl apply -f GEMFIRE-CLUSTER-YAML-FILE.yaml -n NAMESPACE-NAME
    
  4. Once the cluster has started running confirm that GemFire for Redis Apps has been deployed correctly. This can be accomplished by first connecting to the GemFire cluster’s server pod, and checking the version.

    • Start the GemFire CLI (gfsh) on a server pod by running the following command:

      kubectl -n NAMESPACE-NAME exec -it NAME-OF-GEMFIRE-SERVER-POD-0 -- gfsh
      
    • Once gfsh is running, run the version command

      gfsh> version --full
      
    • The output should look similar to the following:

      ...
      ----------------------------------------
      VMware GemFire for Redis Apps
      ----------------------------------------
      GemFire-For-Redis-Apps-Source-Repository: support/1.0
      GemFire-For-Redis-Apps-Source-Revision: 496078ba99319578aa235d084f46745d89cf2d5f
      GemFire-For-Redis-Apps-Version: 1.0.1
      GemFire-For-Redis-Apps-Source-Date: 2022-07-28 10:04:01 -0700
      ...
      
    • Exit the current gfsh connection

      gfsh> exit
      
  5. Now we will confirm that GemFire for Redis Apps has created the default region that will hold our Redis data.

    • Start gfsh on a locator pod:

      kubectl -n NAMESPACE-NAME exec -it NAME-OF-GEMFIRE-LOCATOR-POD-0 -- gfsh
      
    • Connect to the locator using the connect command:

      gfsh> connect --locator=NAME-OF-GEMFIRE-LOCATOR-POD-0[10334]
      
    • List the cluster regions

      gfsh> list regions
      
    • The output should be similar to the following:

      List of regions
      -----------------
      GEMFIRE_FOR_REDIS
      
    • Exit the current gfsh connection

      gfsh> exit
      

At this point the cluster is up and running and able to have Redis client applications connect and send commands.

Shut Down the VMware GemFire for Kubernetes Cluster

To shut down the GemFire for Kubernetes cluster, follow the steps in Create or Delete a VMware GemFire Cluster in the VMware GemFire for Kubernetes documentation.

check-circle-line exclamation-circle-line close-line
Scroll to top icon