Once a Tanzu GemFire cluster has been created, gfsh commands aid the administration and maintenance of the cluster.

Many gfsh commands require that a session be connected to the Tanzu GemFire cluster before the operation can be completed.

Connect to the Tanzu GemFire Cluster

Use one of three ways to connect to a locator in order to issue gfsh commands to the Kubernetes-deployed Tanzu GemFire cluster.

The three ways to connect:

  • Use an interactive gfsh session. Requires Kubernetes cluster exec privilege.
  • Use kubectl to invoke a gfsh command. Requires Kubernetes cluster exec privilege.
  • Use a Kubernetes LoadBalancer service to permit gfsh Tanzu GemFire cluster access via the Management API. The exposed endpoint enables an interactive gfsh session.

Interactive gfsh session

With a Kubernetes cluster for which you have exec privilege, use kubectl to start an interactive gfsh session with the pod running the locator. Use a command of the form:

kubectl -n NAMESPACE-NAME exec -it NAME-locator-0 -- gfsh

where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace, and the cluster NAME is the metadata: name field from the deployment YAML.

For example, if the Tanzu GemFire cluster namespace is gemfire-cluster and the cluster NAME is gemfire1:

$ kubectl -n gemfire-cluster exec -it gemfire1-locator-0 -- gfsh
    _________________________     __
   / _____/ ______/ ______/ /____/ /
  / /  __/ /___  /_____  / _____  / 
 / /__/ / ____/  _____/ / /    / /  
/______/_/      /______/_/    /_/ 

Monitor and Manage Apache Geode
gfsh>

Connect with the Tanzu GemFire cluster:

gfsh>connect

Once connected, issue gfsh commands as desired.

Exit the interactive gfsh session with exit:

gfsh>exit
Exiting...

Use kubectl to Invoke a gfsh Command

With a Kubernetes cluster for which you have exec privilege, use kubectl to invoke a single gfsh command on the Tanzu GemFire cluster. This method of executing gfsh commands can be useful for scripting cluster operations. The form of the kubectl command is:

kubectl -n NAMESPACE-NAME exec -it NAME-locator-0 -- gfsh -e "connect" -e "GFSH-COMMAND"

where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace, and the cluster NAME is the metadata: name field from the deployment YAML.

For example, if the Tanzu GemFire cluster namespace is gemfire-cluster and the cluster NAME is gemfire1, and the desired gfsh command is list members, the kubectl command to list the members of the Tanzu GemFire cluster is:

$ kubectl -n gemfire-cluster exec -it gemfire1-locator-0 -- gfsh -e "connect" -e "list members"

Use a LoadBalancer and Target the Management API

The Tanzu GemFire Management API can be used to issue gfsh commands to the Tanzu GemFire cluster. Follow these steps to connect to the Tanzu GemFire cluster:

  1. Create a LoadBalancer service as directed in Create a LoadBalancer Service for the Management API.

  2. Acquire and install gfsh for the machine that will issue the gfsh commands. gfsh will be in the bin directory of the Apache Geode binary that has been expanded, once downloaded from VMware Tanzu Network. If more than one version of Apache Geode is available, the correct version of Apache Geode to acquire is listed in the Release Notes.

  3. Acquire the EXTERNAL-IP value to use in the gfsh connect command in step 5. Run the command:

    kubectl get service LB-SVC-MGMT-API
    

    where LB-SVC-MGMT-API is the metadata: name field from the LoadBalancer service's configuration YAML. The value is the EXTERNAL-IP field from the command's output.

  4. Run gfsh.

  5. At the gfsh prompt, connect to the Tanzu GemFire cluster. Include a -use-http option in the connect command:

    gfsh>connect --locator --use-http=true --url=http://EXTERNAL-IP:7070/gemfire/v1
    

    where EXTERNAL-IP is the acquired value from step 3.

Create a Region

Create regions once connected via gfsh. Specify the name of the region and the type of the region in the command. For example,

gfsh>create region --name=customers --type=PARTITION_REDUNDANT

or

$ kubectl -n NAMESPACE-NAME exec -it gemfire1-locator-0 -- gfsh -e "connect" \
  -e "create region --name=products --type=REPLICATE"

where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace.

See the gfsh create region documentation for details.

Obtain Logs and Tanzu GemFire Cluster State

Kubernetes Pod Logs

Kubernetes pod logs include the logged events from the Tanzu GemFire cluster and the startup of the pod. To print a Kubernetes pod log to standard output, use a command of the form:

$ kubectl -n NAMESPACE-NAME logs POD-NAME

where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace, and POD-NAME is composed as pod/NAME-locator-N or pod/NAME-server-N. The NAME is the metadata: name field, and N identifies which locator or server is desired.

Tanzu GemFire Cluster Logs

The gfsh export logs command places the Tanzu GemFire cluster logs on the locator-0 pod. The created ZIP file should be copied to the local machine for viewing the artifacts. The locator-0 pod must have sufficent disk space to capture the logs and statistics files from all the Tanzu GemFire locators and servers.

  1. Use gfsh to Connect to the Instance with an interactive gfsh session.

  2. Run the export logs command:

    gfsh>export logs
    Logs exported to the connected member's file system: /data/exportedLogs_XXX.zip
    gfsh>exit
    

    The logs will be in a file named similar to exportedLogs_XXX.zip. Output from the command will provide the exact name of the file; use the exact name in the following commands.

  3. Copy the logs from the locator-0 pod to the local machine:

    $ kubectl -n NAMESPACE-NAME cp NAME-locator-0:exportedLogs_XXX.zip exportedLogs_XXX.zip
    

    where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace, and NAME is the metadata: name field from the deployment YAML.

  4. Unzip the logs:

    $ unzip exportedLogs_XXX.zip
    

Collect and View Metrics

Use VMware Tanzu Observability by Wavefront

The VMware Tanzu Observability by Wavefront product integrates seamlessly with Tanzu GemFire clusters to both collect Tanzu GemFire cluster metrics and view those metrics via a dashboard.

There are three parts to the integration. The installation of the Wavefront Collector and Proxy may be done before or after the creation of a Tanzu GemFire cluster.

  • Install the Wavefront Collector and Proxy by following the instructions at Kubernetes Setup. The installation will be either with Tanzu Mission Control or with Helm.

    • For a Tanzu Mission Control installation:
      1. Enable the use of Tanzu Observability for your organization by following the directions at Enable Observability for Your Organization.
      2. Install a configured Wavefront Collector and a Proxy on your Kubernetes cluster by following the directions at Add a Cluster to Observability.
    • For a Helm installation:
      1. Acquire an API token that will allow Tanzu Observability to authenticate communication from the Wavefront Proxy. Follow the directions at Generating an API Token.
      2. Use the API token as you install the Wavefront Collector and Proxy via Helm following the directions at Kubernetes Quick Install Using Helm.
  • When you create the Tanzu GemFire cluster, it emits metrics by default. If desired, you can specify a much higher quantity of metrics to be emitted at a higher frequency by setting spec.metrics within the CRD.

  • Create or integrate a Wavefront dashboard. There are sample dashboards available in the https://github.com/vmware-samples/tanzu-gemfire-observability-sample repository.

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