Cross-site replication
Back up Data Grid caches from the DC cluster to the DR cluster with cross-site replication, and switch which site takes writes.
Two Data Grid clusters can forward cache writes to each other. Data Grid calls the remote cluster a site. A cache is configured with a backup to that site. The operator calls the connection a cross-site location on the Infinispan resource. This is how a cache at the DC has a warm copy at the DR, in memory, without waiting for a restore from a file.
It is a different mechanism from Ramen, which moves OpenShift workloads, and from Data Guard, which moves an Oracle database. The cache is one tier. The database behind it still needs its own standby, or the DR application will read a fresh cache and write to a database that is not there.
Two clusters, named as sites
Install the operator and a three-pod Infinispan on each cluster, as in the install lab. The site name is DC on the first and DR on the second. Names are case-sensitive and must match the backup configuration later.
Managed cross-site connections use a service account token so each operator can watch the other cluster. Create the token secret the operator guide describes for your version, on each side, named in secretName. The URL is the remote OpenShift API, not the Data Grid Service.
On the DC cluster:
apiVersion: infinispan.org/v1
kind: Infinispan
metadata:
name: example-infinispan
namespace: datagrid
spec:
replicas: 3
service:
type: DataGrid
sites:
local:
name: DC
expose:
type: Route
maxRelayNodes: 1
locations:
- name: DR
clusterName: example-infinispan
namespace: datagrid
url: https://api.dr.example.com:6443
secretName: dr-token
On the DR cluster the local.name is DR, the location name is DC, and the URL is the DC API. expose.type: Route publishes the relay so the other site can open it. NodePort or LoadBalancer is the alternative when a Route is not what the network team will allow. maxRelayNodes: 1 is enough for the lab. The relay is the Gossip Router. It is not the data path for every key. Pods forward to the remote site over the cross-site channel.
Wait for the condition CrossSiteViewFormed on both Infinispan objects.
oc get infinispan example-infinispan -n datagrid -o jsonpath='{.status.conditions}'
If the view never forms, the token, the API URL, or the exposed relay port is wrong. Do not add a backup location until the view exists. Writes will queue or fail against a site that is not there.
A note from the current operator line: with cross-site TLS, keep get pods in this namespace limited to people who operate the cluster. A published operator issue stored keystore passwords in the Gossip Router container arguments, which anyone who can read the pod spec can see.
A cache that backs up
The same cache name must exist on both sites. Data Grid matches on the name. Create accounts on both, with the same Protobuf schema registered on both, or the DR will accept bytes it cannot index.
On the DC cache:
distributedCache:
mode: "SYNC"
owners: "2"
statistics: "true"
encoding:
mediaType: "application/x-protostream"
backups:
DR:
backup:
strategy: "ASYNC"
timeout: "10000"
takeOffline:
afterFailures: "5"
minWait: "60000"
strategy: ASYNC means a local put returns without waiting for the DR. The DR is behind by whatever the link has not sent. That is the right default between two cities. SYNC waits for the remote site and will make every put as slow as the round trip. Use it only when that wait is the requirement.
takeOffline stops sending after repeated failures, so a dead DR does not stall the DC forever. minWait is milliseconds before it will try the site again. When the DR returns, bring the site online and push state. Leaving it offline "because the alarm stopped" means the DR is quietly stale.
The DR cache lists DC as its backup in the same way if you want writes during a DR period to flow back. A one-way backup is simpler to reason about until the first failover, and then the writes on the new primary have nowhere to go. Configure both directions before the drill, not during it.
Prove the copy, then switch
Put an account on the DC through REST. Read it on the DR. ASYNC means you may need to retry the read for a moment. If it never appears, oc logs on both clusters filtered for RELAY2 is the trail. The schema and the cache name are the two mismatches we see most often.
A planned switch:
- Stop the writers on the DC (scale the application down, or make it read-only).
- Confirm the DR has the last key you wrote. An ASYNC backup does not let you skip this.
- Point the application at the DR Service, by a DNS name you control or by the GitOps overlay for that site.
- Writers go to the DR. The backup to
DCcarries new writes home.
A DC that is simply gone skips step 1. You accept the lag takeOffline had not yet flushed. That lag is the RPO. Measure it in the drill, as the age of the last key that made it, and write the number in the runbook. Do not copy a number from this page.
Bringing the DC back is a state transfer from the site that has the new writes, not a restart that serves stale keys. Push state from the DR to the DC, then return the application when a key written on the DR is visible on the DC. Two sites taking writes at once, with no backup between them, is a split brain. The application has one primary site at a time.
What's next
Backup and restore is the file you still take, because a bug that deletes every key will happily replicate the deletion to the other site. Cross-site replication copies mistakes. A backup is what you restore when both sites have the mistake.