Debug School

Cover image for Red Hat Data Grid
Suyash Sambhare
Suyash Sambhare

Posted on

Red Hat Data Grid

Data Grid is a high-performance, distributed in-memory data store.
Features of Data Grid

  • Schemaless data structure. Flexibility to store different objects as key-value pairs.
  • Grid-based data storage. Designed to distribute and replicate data across clusters.
  • Elastic scaling. Dynamically adjust the number of nodes to meet demand without service disruption.
  • Data interoperability. Store, retrieve, and query data in the grid from different endpoints.

Data Grid Operator

Data Grid Operator lets you create, configure, and manage Data Grid clusters.
Data Grid Operator provides the following capabilities:

  • Built-in intelligence to automate Data Grid cluster deployment.
  • Infinispan CR for service configuration.
  • Cross-site configuration and management.
  • Deployment of Grafana and Prometheus resources.
  • Cache CR for fully configurable caches.
  • Batch CR for scripting bulk resource creation.
  • REST and Hot Rod endpoints are available at port 11222.

Prerequisites

  • Data Grid pods request 1Gi of memory and 1Gi of ReadWriteOnce persistent storage.
  • Data Grid Operator lets you adjust resource allocation to suit your requirements.
  • Create a Data Grid Operator subscription.
  • Have an OC client.

Custom Resource (CR)

Data Grid Operator adds a new Custom Resource (CR) of type Infinispan that lets you handle Data Grid clusters as complex units on OpenShift.
You configure Data Grid clusters running on OpenShift by modifying the Infinispan CR.
The minimal Infinispan CR for Data Grid clusters is as follows:

apiVersion: infinispan.org/v1
kind: Infinispan
metadata:
  name: data-grid-demo
spec:
  replicas: 3
Enter fullscreen mode Exit fullscreen mode

DataGrid

Creating Data Grid Clusters

Use Data Grid Operator to create clusters of two or more Data Grid nodes.
Specify the number of Data Grid nodes in the cluster with spec.replicas in your Infinispan CR.
For example, create a cr_minimal.yaml file as follows:

$ cat > cr_minimal.yaml<<EOF
apiVersion: infinispan.org/v1
kind: Infinispan
metadata:
  name: example-rhdatagrid
spec:
  replicas: 2
EOF
Enter fullscreen mode Exit fullscreen mode

Apply your Infinispan CR.
$ oc apply -f cr_minimal.yaml

Watch the Data Grid Operator create the Data Grid nodes.

$ oc get pods -w

NAME                        READY  STATUS              RESTARTS   AGE
example-rhdatagrid-1        0/1    ContainerCreating   0          4s
example-rhdatagrid-2        0/1    ContainerCreating   0          4s
example-rhdatagrid-3        0/1    ContainerCreating   0          5s
infinispan-operator-0       1/1    Running             0          3m
example-rhdatagrid-3        1/1    Running             0          8s
example-rhdatagrid-2        1/1    Running             0          8s
example-rhdatagrid-1        1/1    Running             0          8s
Enter fullscreen mode Exit fullscreen mode

Verifying Data Grid Clusters

Review log messages to ensure that Data Grid nodes receive clustered views.
Retrieve the cluster view from logs.

$ oc logs example-rhdatagrid-0 | grep ISPN000094

INFO  [org.infinispan.CLUSTER] (MSC service thread 1-2) \
ISPN000094: Received new cluster view for channel infinispan: \
[example-rhdatagrid-0|0] (1) [example-rhdatagrid-0]

INFO  [org.infinispan.CLUSTER] (jgroups-3,{example_crd_name-0) \
ISPN000094: Received new cluster view for channel infinispan: \
[example-rhdatagrid-0|1] (2) [example-rhdatagrid-0, example-rhdatagrid-1]
Enter fullscreen mode Exit fullscreen mode

Retrieve the Infinispan CR for the Data Grid Operator.
$ oc get infinispan -o yaml
The response indicates that Data Grid pods have received clustered views:

conditions:
    - message: 'View: [example-rhdatagrid-0, example-rhdatagrid-1]'
      status: "True"
      type: wellFormed
Enter fullscreen mode Exit fullscreen mode

Use oc wait with the wellFormed condition for automated scripts.

$ oc wait --for condition=wellFormed --timeout=240s infinispan/example-rh

Gracefully Shutting Down Data Grid Clusters

Set the value of replicas to 0 and apply the changes.

spec:
  replicas: 0
Enter fullscreen mode Exit fullscreen mode

Restarting Data Grid Clusters

Set the value of spec.replicas to the same number of nodes that were in the cluster before you shut it down.
For example, you shut down a cluster of 6 nodes. When you restart the cluster, you must set:

spec:
  replicas: 6
Enter fullscreen mode Exit fullscreen mode

This allows the Data Grid to restore the distribution of data across the cluster. When all nodes in the cluster are running, you can then add or remove nodes.

Ref: https://access.redhat.com/documentation/en-us/red_hat_data_grid/8.0/html-single/running_data_grid_on_openshift/

Top comments (0)