Migrating Data from an On-premises Elasticsearch Cluster to Huawei Cloud Using the S3 Plugin
This topic describes how to use the S3 plugin to migrate data from an on-premises Elasticsearch cluster to a Huawei Cloud Elasticsearch cluster using the snapshot mechanism.
Scenario
The S3 plugin (repository-s3) is purpose-developed for Elasticsearch. It allows users to store Elasticsearch snapshots to a storage service compatible with S3 APIs, such as Huawei Cloud OBS. The S3 plugin provides an efficient, flexible, and secure way to back up the data of Elasticsearch clusters.
The S3 plugin can be used to migrate data from an on-premises Elasticsearch cluster to a Huawei Cloud Elasticsearch cluster. Typical scenarios include:
- Cloud migration: Migrate an on-premises Elasticsearch service to the cloud to enjoy the benefits of cloud services, such as scalability, ease-of-maintenance, and cost-effectiveness.
- Cross-version migration: Migrate data from an on-premises Elasticsearch cluster of an earlier version to a Huawei Cloud Elasticsearch cluster of a later version.
- Cluster merge: Migrate data from multiple on-premises Elasticsearch clusters to a single Huawei Cloud Elasticsearch cluster to form a unified data platform for simplified management and higher data consistency.
- Unified technology stack: For a simplified, unified technology stack, companies that are already using some services on Huawei Cloud may choose to migrate their on-premises Elasticsearch clusters to Huawei Cloud.
Overview
Figure 1 describes the procedure for migrating an on-premises Elasticsearch cluster (source cluster) to a Huawei Cloud Elasticsearch cluster (destination cluster) using the S3 plugin.
- Install the repository-s3 plugin in the on-premises Elasticsearch cluster.
- Back up the data of the on-premises Elasticsearch cluster to Huawei Cloud OBS.
- Restore data from Huawei OBS to an Elasticsearch cluster in CSS.
Advantages
- High cross-version compatibility: Data can be migrated between Elasticsearch clusters of different versions, including upgrade from an earlier version to a later version.
- High availability and durability: S3 protects the security of data backups and minimizes the risk of data loss.
- Flexible backup policies: You can choose between full backup or incremental backup based on service requirements to optimize storage utilization and migration time.
Constraints
- The version of the destination cluster must not be earlier than that of the source cluster. For details, see Snapshot version compatibility.
- This method does not support incremental data synchronization. You need to pause data update before starting to back up data.
- An on-premises Elasticsearch cluster needs public network access to back up snapshots to OBS.
Prerequisites
- The source and destination Elasticsearch clusters are available.
- The OBS bucket (backup-obs) for storing snapshots has been prepared. The OBS bucket and the destination Elasticsearch cluster of CSS are in the same region.
- You have obtained the AK/SK of your account. For details, see How Do I Obtain an Access Key (AK/SK)?.
Procedure
- Install the repository-s3 plugin in the on-premises Elasticsearch cluster.
- Check the version of the on-premises Elasticsearch cluster and determine the version of the repository-s3 plugin that you need to install.
Run the following command to obtain cluster information:
curl http://x.x.x.x:9200 # Enter the IP address of the Elasticsearch cluster.
Find version.number in the command output. In the example below, the cluster version is 7.10.2.
{ "name" : "es_cluster_migrate-ess-esn-1-1", "cluster_name" : "es_cluster_migrate", "cluster_uuid" : "1VbP7-39QNOx_R-llXKKtA", "version" : { "number" : "7.10.2", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "d2ef93d", "build_date" : "2018-12-17T21:17:40.758843Z", "build_snapshot" : false, "lucene_version" : "8.7.0", "minimum_wire_compatibility_version" : "6.7.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "Tagline" : "You Know, for Search" }
- Download the repository-s3 plugin installation package of the required version. 7.10.2 is used as an example here. Change the version number in the download address based on the actual cluster version.
Download address: https://artifacts.elastic.co/downloads/elasticsearch-plugins/repository-s3/repository-s3-7.10.2.zip
- Log in to an instance node of the on-premises Elasticsearch cluster, and run the cd command to go to the plugins directory.
- Run the following command to extract the repository-s3 plugin installation package to the plugins directory:
unzip repository-s3-7.10.2.zip -d plugins/repository-s3
- Add the AK/SK that enables access to Huawei Cloud to the repository-s3 plugin.
- Go to the installation path of the on-premises Elasticsearch cluster, and run the following command to create a keystore file:
bin/elasticsearch-keystore create s3.keystore
Use a common user account, rather than the root account, to create the keystore file. Otherwise, the configuration will not take effect.
- Add the AK/SK that enables access to Huawei Cloud to the keystore file.
bin/elasticsearch-keystore add s3.client.default.access_key bin/elasticsearch-keystore add s3.client.default.secret_key
access_key indicates the AK, and secret_key indicates the SK.
- Go to the installation path of the on-premises Elasticsearch cluster, and run the following command to create a keystore file:
- If the on-premises Elasticsearch cluster has multiple instance nodes, repeat 1.c to 1.e to install the S3 plugin and configure the AK/SK for all these nodes.
- After the AK/SK is added, restart the Elasticsearch cluster for the configuration to take effect.
- After the restart, run the following command to check whether the S3 plugin has been successfully installed.
curl http://x.x.x.x:9200/_cat/plugins # Enter the IP address of the Elasticsearch cluster.
If the correct version information of the repository-s3 plugin is returned, as shown below, the plugin has been successfully installed.
node-1 repository-s3 7.10.2
- Check the version of the on-premises Elasticsearch cluster and determine the version of the repository-s3 plugin that you need to install.
- Back up the data of the on-premises Elasticsearch cluster to Huawei Cloud OBS.
- Log in to the Kibana console of the on-premises Elasticsearch cluster, and choose Dev Tools to go to the CLI.
- Run the following command to create a snapshot repository my_backup, and connect it to OBS bucket backup-obs for storing snapshots in Huawei Cloud OBS.
PUT /_snapshot/my_backup { "type": "s3", "settings": { # OBS bucket name "bucket": "backup-obs", # Public network address for accessing OBS "endpoint": "obs.xxx.example.com", "base_path": "snapshot", "max_snapshot_bytes_per_sec": "1000mb" } }
- Run the following command. If correct information about the snapshot repository is returned, it has been successfully created.
GET /_snapshot/my_backup
- Run the following command to create a snapshot.
Exclude system indexes whose name starts with ., and create a full data snapshot for all other indexes. Setting wait_for_completion to true means asynchronous task execution.
PUT _snapshot/my_backup/snapshot_all?wait_for_completion=true { "indices": "*,-.*" }
- After the snapshot is created, run the following command to check the snapshot information:
# Display all existing snapshots. GET _cat/repositories # Display information about all snapshots. GET _snapshot/my_backup/_all # Check the information of a snapshot by specifying its name. snapshot_all indicates the snapshot name. GET _snapshot/my_backup/snapshot_all # Check the status of a snapshot by specifying its name. snapshot_all indicates the snapshot name. GET _snapshot/my_backup/snapshot_all/_status
- Restore data from OBS to an Elasticsearch cluster of CSS.
- Log in to the CSS management console.
- In the navigation pane on the left, choose Clusters > Elasticsearch to go to the Clusters page.
- Locate the destination cluster and click Access Kibana in the Operation column to log in to Kibana.
- Click Dev Tools in the navigation tree on the left.
- Run the following command to create a snapshot repository called my_backup_all.
PUT _snapshot/my_backup_all/ { "type" : "obs", "settings" : { # Private domain name of OBS. "endpoint" : "obs.xxx.example.com", "region" : "cn-south-1", # Username and password for accessing OBS. "access_key": "xxx", "secret_key": "xxx", # OBS bucket name, which must be the same as the destination OBS bucket name in the previous step. "bucket" : "backup-obs", "compress" : "false", "chunk_size" : "1g", "base_path" : "snapshot", "max_restore_bytes_per_sec": "1000mb", "max_snapshot_bytes_per_sec": "1000mb" } }
- Run the following command to restore data from the snapshot on OBS to the destination cluster.
- Check all existing snapshots. In the command below, my_backup_all indicates the repository name.
GET _snapshot/my_backup_all/_all
- Restore data from the snapshot_all snapshot in the my_backup_all snapshot repository to the destination Elasticsearch cluster.
POST _snapshot/my_backup_all/snapshot_all/_restore?wait_for_completion=true
- Restore specified indexes to the destination Elasticsearch cluster. In this example, my_index1 and my_index2 are the names of the indexes to be restored.
POST _snapshot/my_backup_all/snapshot_all/_restore?wait_for_completion=true { "indices": "my_index1,my_index2,-.*", "ignore_unavailable": "true" }
- Check all existing snapshots. In the command below, my_backup_all indicates the repository name.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot