This website/page will be End-of-life (EOL) after 31 August 2024. We recommend you to visit OpenEBS Documentation for the latest Mayastor documentation (v2.6 and above).
Mayastor is now also referred to as OpenEBS Replicated PV Mayastor.
Before you begin, make sure you have the following:
Access to a Kubernetes cluster with Velero installed.
A backup of your Mongo database created using Velero.
Mayastor configured in your Kubernetes environment.
Install Velero with the GCP provider, ensuring you use the same values for the BUCKET-NAME
and SECRET-FILENAME
placeholders that you used originally. These placeholders should be replaced with your specific values:
Check the availability of your previously-saved backups. If the credentials or bucket information doesn't match, you won't be able to see the backups:
Initiate the restore process using Velero CLI with the following command:
You can check the status of the restore process by using the velero get restore
command.
When Velero performs a restore, it deploys an init container within the application pod, responsible for restoring the volume. Initially, the restore status will be InProgress
.
Your storage class was originally set to cstor-csi-disk
because you imported this PVC from a cStor volume, the status might temporarily stay as In Progress and your PVC will be in Pending status.
Retrieve the current configuration of the PVC which is in Pending
status using the following command:
Confirm that the PVC configuration has been saved by checking its existence with this command:
Edit the pvc-mongo.yaml
file to update its storage class. Below is the modified PVC configuration with mayastor-single-replica
set as the new storage class:
The statefulset for Mongo will still have the cstor-csi-disk
storage class at this point. This will be addressed in the further steps.
Begin by deleting the problematic PVC with the following command:
Once the PVC has been successfully deleted, you can recreate it using the updated configuration from the pvc-mongo.yaml
file. Apply the new configuration with the following command:
After recreating the PVC with Mayastor storageClass, you will observe the presence of a Velero initialization container within the application pod. This container is responsible for restoring the required volumes.
You can check the status of the restore operation by running the following command:
The output will display the pods' status, including the Velero initialization container. Initially, the status might show as "Init:0/1," indicating that the restore process is in progress.
You can track the progress of the restore by running:
You can then verify the data restoration by accessing your MongoDB instance. In the provided example, we used the "mongosh" shell to connect to the MongoDB instance and check the databases and their content. The data should reflect what was previously backed up from the cStor storage.
Due to the statefulset's configuration with three replicas, you will notice that the mongo-1
pod is created but remains in a Pending
status. This behavior is expected as we have the storage class set to cStor in statefulset configuration.
Capture the current configuration of the StatefulSet for MongoDB by running the following command:
This command will save the existing StatefulSet configuration to a file named sts-mongo-original.yaml
. Next, edit this YAML file to change the storage class to mayastor-single-replica
.
Delete the StatefulSet while preserving the pods with the following command:
You can run the following commands to verify the status:
Delete the MongoDB Pod mongod-1
.
Delete the Persistent Volume Claim (PVC) for mongod-1
.
Recreate the StatefulSet with the Yaml file.
Verify data replication on the secondary database to ensure synchronization.
This website/page will be End-of-life (EOL) after 31 August 2024. We recommend you to visit OpenEBS Documentation for the latest Mayastor documentation (v2.6 and above).
Mayastor is now also referred to as OpenEBS Replicated PV Mayastor.
This documentation provides a comprehensive guide on migrating CStor application volumes to Mayastor. We utilize Velero for the backup and restoration process, enabling a seamless transition from a CStor cluster to Mayastor. This example specifically focuses on a GKE cluster.
Velero offers support for the backup and restoration of Kubernetes volumes attached to pods directly from the volume's file system. This is known as File System Backup (FSB) or Pod Volume Backup. The data movement is facilitated through the use of modules from free, open-source backup tools such as Restic (which is the tool of choice in this guide).
For cloud providers, you can find the necessary plugins here.
For detailed Velero GKE configuration prerequisites, refer to this resource.
It's essential to note that Velero requires an object storage bucket for storing backups, and in our case, we use a Google Cloud Storage (GCS) bucket.
For detailed instructions on Velero basic installation, visit https://velero.io/docs/v1.11/basic-install/.
This website/page will be End-of-life (EOL) after 31 August 2024. We recommend you to visit OpenEBS Documentation for the latest Mayastor documentation (v2.6 and above).
Mayastor is now also referred to as OpenEBS Replicated PV Mayastor.
If you are deploying databases using operators, you need to find a way to actively modify the entire deployment through the operator. This ensures that you control and manage changes effectively within the operator-driven database deployment.
Currently, we have a cStor cluster as the source, with a clustered MongoDB running as a StatefulSet using cStor volumes.
For the prerequisites, refer to the overview section.
Run the following command to install Velero:
Verify the Velero namespace for Node Agent and Velero pods:
On the Primary Database (mongo-0) you can see some sample data.
You can also see the data available on the replicated secondary databases.
MongoDB uses replication, and data partitioning (sharding) for high availability and scalability. Taking a backup of the primary database is enough as the data gets replicated to the secondary databases. Restoring both primary and secondary at the same time can cause data corruption.
For reference: MongoDB Backup and Restore Error Using Velero
Velero supports two approaches for discovering pod volumes to be backed up using FSB:
Opt-in approach: Annotate pods containing volumes to be backed up.
Opt-out approach: Backup all pod volumes with the ability to opt-out specific volumes.
To ensure that our primary MongoDB pod, which receives writes and replicates data to secondary pods, is included in the backup, we need to annotate it as follows:
To exclude secondary MongoDB pods and their associated Persistent Volume Claims (PVCs) from the backup, we can label them as follows:
Create a backup of the entire namespace. If any other applications run in the same namespace as MongoDB, we can exclude them from the backup using labels or flags from the Velero CLI:
To check the status of the backup using the Velero CLI, you can use the following command. If the backup fails for any reason, you can inspect the logs with the velero backup logs command: