此内容没有您所选择的语言版本。
Chapter 12. Configuring Cross-Site Replication
Set up cross-site replication to back up data between Data Grid clusters running in different locations.
For example, you use Data Grid Operator to manage a Data Grid cluster at a data center in London, LON. At another data center in New York City, NYC, you also use Data Grid Operator to manage a Data Grid cluster. In this case, you can add LON and NYC as backup locations for each other.
Cross-site replication functionality is currently Technology Preview. Contact Red Hat support for more information.
Prerequisites
- Ensure that a load balancer service is available for OpenShift. This service allows external access to OpenShift Container Platform clusters. See Configuring ingress cluster traffic using a load balancer.
12.1. Data Grid Cluster and Project Naming 复制链接链接已复制到粘贴板!
Data Grid Operator expects Data Grid clusters in each site to have the same cluster names and be running in matching namespaces.
For example, in the LON site you create a Data Grid cluster with metadata.name: mydatagrid in a OpenShift project named "my-xsite". In this case you must create Data Grid clusters in other backup locations, such as NYC, with identical names in matching namespaces.
In effect, you must create Data Grid cluster names and OpenShift namespaces at each backup location that mirror one another.
12.2. Creating Service Account Tokens 复制链接链接已复制到粘贴板!
Traffic between independent OpenShift installations occurs through a Kubernetes API. OpenShift Container Platform clusters use tokens to authenticate with and access the API.
To enable cross-site replication between Data Grid clusters you must add tokens to the namespace on each site. For example, LON needs a secret with the token for NYC. NYC also needs a secret with the token for LON.
Procedure
Create service accounts on each OpenShift instance.
For example, create a service account on LON as follows:
oc create sa lon serviceaccount/lon created
$ oc create sa lon serviceaccount/lon createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the view role to service accounts.
For example, if your Data Grid cluster runs in the "my-xsite" namespace, add the view role to the service account on LON as follows:
oc policy add-role-to-user view system:serviceaccount:my-xsite:lon
$ oc policy add-role-to-user view system:serviceaccount:my-xsite:lonCopy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve tokens from each service account.
The following example shows the service account token for LON:
oc sa get-token lon eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9...
$ oc sa get-token lon eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create secrets that contain service account tokens for the backup locations.
- Log in to OpenShift Container Platform at NYC.
Add the service account token to a
lon-tokensecret.oc create secret generic lon-token --from-literal=token=eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9...
oc create secret generic lon-token --from-literal=token=eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9...Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Repeat the preceding steps to create a
nyc-tokensecret on LON.
After you add service account tokens to each backup location, the OpenShift instances can authenticate with each other so that Data Grid clusters can form cross-site views.
Reference
12.3. Adding Backup Locations to Data Grid Clusters 复制链接链接已复制到粘贴板!
Configure Data Grid clusters as backup locations so that they can communicate over a dedicated JGroups transport channel for replicating data.
Procedure
Configure Data Grid clusters at each site with the Infinispan CR as necessary.
For example, create
lon.yamlto configure LON andnyc.yamlto configure NYC. Both configurations must include the following:-
.spec.service.sites.localnames the local site for Data Grid clusters. -
.spec.service.sites.locationsprovides the location of all site masters. Data Grid nodes use this information to connect with each other and form cross-site views.
-
Instantiate Data Grid clusters at each site, for example:
Apply the Infinispan CR for LON.
oc apply -f lon.yaml
$ oc apply -f lon.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Log in to OpenShift Container Platform at NYC.
Apply the Infinispan CR for NYC.
oc apply -f nyc.yaml
$ oc apply -f nyc.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verify that Data Grid clusters form a cross-site view.
For example, do the following on LON:
oc logs example-rhdatagrid-0 | grep x-site INFO [org.infinispan.XSITE] (jgroups-5,example-rhdatagrid-0-<id>) ISPN000439: Received new x-site view: [NYC] INFO [org.infinispan.XSITE] (jgroups-7,example-rhdatagrid-0-<id>) ISPN000439: Received new x-site view: [NYC, LON]
$ oc logs example-rhdatagrid-0 | grep x-site INFO [org.infinispan.XSITE] (jgroups-5,example-rhdatagrid-0-<id>) ISPN000439: Received new x-site view: [NYC] INFO [org.infinispan.XSITE] (jgroups-7,example-rhdatagrid-0-<id>) ISPN000439: Received new x-site view: [NYC, LON]Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Reference
12.3.1. Cross-Site Replication Resources 复制链接链接已复制到粘贴板!
- 1
- Specifies Data Grid service. Data Grid supports cross-site replication with Data Grid service clusters only.
- 2
- Names the local site for a Data Grid cluster.
- 3
- Specifies
LoadBalanceras the service that handles communication between backup locations. - 4
- Provides connection information for all backup locations.
- 5
- Specifies a backup location that matches
.spec.service.sites.local.name. - 6
- Specifies the URL of the Kubernetes API for the backup location.
- 7
- Specifies the secret that contains the service account token for the backup site.