Migrating data from a third-party OpenSearch cluster using Yandex Data Transfer
With Data Transfer, you can transfer data from a third-party OpenSearch source cluster's indexes to Managed Service for OpenSearch indexes. To do this:
- Set up the source cluster.
- Prepare the test data.
- Configure the target cluster.
- Set up and activate the transfer.
- Test the transfer.
If you no longer need the resources you created, delete them.
Required paid resources
The support cost includes:
- Managed Service for OpenSearch cluster fee: Using computing resources allocated to hosts (including hosts with the
MANAGERrole) and disk space (see Managed Service for OpenSearch pricing). - Fee for public IP address assignment on cluster hosts (see Virtual Private Cloud pricing).
- Per-transfer fee: Using computing resources and the number of transferred data rows (see Data Transfer pricing).
Getting started
-
Enable access to the source OpenSearch cluster from Yandex Cloud.
-
Create a Managed Service for OpenSearch target cluster:
ManuallyTerraformCreate a Managed Service for OpenSearch target cluster in any suitable configuration with publicly available hosts.
-
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Download the file with provider settings
. Place it in a separate working directory and specify the parameter values. -
Download the data-transfer-os-mos.tf
configuration file to the same working directory.This file describes:
- Network.
- Subnet.
- Security group and rules required to connect to a Managed Service for OpenSearch cluster.
- Managed Service for OpenSearch target cluster.
- Transfer.
-
In the
data-transfer-os-mos.tffile, specify the following variables:-
mos_version: OpenSearch version. -
mos_admin_password: Managed Service for OpenSearch admin user password. -
transfer_enabled: Set to0to ensure that no transfer is created until you create endpoints manually. -
profile_name: Name of your CLI profile.If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
-
-
Run the
terraform initcommand in the directory with the configuration file. This command initializes the provider specified in the configuration files and enables you to use its resources and data sources. -
Make sure the Terraform configuration files are correct using this command:
terraform validateTerraform will display any configuration errors detected in your files.
-
Create the required infrastructure:
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
All the required resources will be created in the specified folder. You can check resource availability and their settings in the management console
. -
-
-
Install the following tools:
Set up the source cluster
Create a user to execute the transfer.
You can provide data from the OpenSearch cluster as the admin user with the superuser role; however, it is more secure to create separate users with limited privileges for each task.
-
Optionally, in the source cluster, create a role
with thecreate_indexandwriteprivileges for all indexes (*). -
Optionally, in the source cluster, create a user
to run the transfer and assign them the role you created.
Prepare the test data
-
In the source cluster, create a test index named
peopleand define its mapping:curl --user <username_in_source_cluster>:<user_password_in_source_cluster> \ --header 'Content-Type: application/json' \ --request PUT 'https://<address_of_OpenSearch_host_with_DATA_role>:9200/people' && \ curl --user <source_cluster_username>:<user_password_in_source_cluster> \ --header 'Content-Type: application/json' \ --request PUT 'https://<address_of_OpenSearch_host_with_DATA_role>:9200/people/_mapping?pretty' \ --data' { "properties": { "name": {"type": "text"}, "age": {"type": "integer"} } } ' -
Populate the test index with data:
curl --user <source_cluster_username>:<user_password_in_source_cluster> \ --header 'Content-Type: application/json' \ --request POST 'https://<address_of_OpenSearch_host_with_DATA_role>:9200/people/_doc/?pretty' \ --data' { "name": "Alice", "age": "30" } ' && \ curl --user <username_in_source_cluster>:<user_password_in_source_cluster> \ --header 'Content-Type: application/json' \ --request POST 'https://<address_of_OpenSearch_host_with_DATA_role>:9200/people/_doc/?pretty' \ --data' { "name": "Robert", "age": "32" } ' -
Optionally, check the data in the test index:
curl --user <username_in_target_cluster>:<user_password_in_target_cluster> \ --header 'Content-Type: application/json' \ --request GET 'https://<address_of_OpenSearch_host_with_DATA_role>:9200/people/_search?pretty'
Configure the target cluster
-
Obtain an SSL certificate for secure access to the Managed Service for OpenSearch cluster.
-
(Optional) Create a user to execute the transfer.
You can provide data to the Managed Service for OpenSearch cluster as the
adminuser with thesuperuserrole; however, it is more secure to create separate users with limited privileges for each task.-
Create a role
with thecreate_indexandwriteprivileges for all indexes (*). -
Create a user and assign this role to them.
-
Set up and activate the transfer
-
Create an endpoint for the target Managed Service for OpenSearch cluster.
-
Create a transfer:
ManuallyTerraform- Create a transfer of the Snapshot type that will use the endpoints you created.
- Activate the transfer.
-
In the
data-transfer-os-mos.tffile, specify the following variables:source_endpoint_id: Source endpoint ID.target_endpoint_id: ID of the target endpoint.transfer_enabled:1(create a transfer).
-
Make sure the Terraform configuration files are correct using this command:
terraform validateTerraform will display any configuration errors detected in your files.
-
Create the required infrastructure:
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
The transfer will activate automatically upon creation.
-
Test the transfer
-
Wait for the transfer status to change to Completed.
-
Make sure the Managed Service for OpenSearch cluster's
peopleindex contains the sent data:BashOpenSearch DashboardsRun this command:
curl --user <username_in_target_cluster>:<user_password_in_target_cluster> \ --cacert ~/.opensearch/root.crt \ --header 'Content-Type: application/json' \ --request GET 'https://<FQDN_of_OpenSearch_host_with_DATA_role>:9200/people/_search?pretty'- Connect to the target cluster using OpenSearch Dashboards.
- Select the
Globaltenant. - Open the control panel by clicking
. - Under OpenSearch Dashboards, select Discover.
- In the CHANGE INDEX PATTERN field, select the
peopleindex.
Delete the resources you created
Some resources are not free of charge. To avoid paying for them, delete the resources you no longer need:
-
Delete other resources using the same method used for their creation:
ManuallyTerraform-
In the terminal window, go to the directory containing the infrastructure plan.
Warning
Make sure the directory has no Terraform manifests with the resources you want to keep. Terraform deletes all resources that were created using the manifests in the current directory.
-
Delete resources:
-
Run this command:
terraform destroy -
Confirm deleting the resources and wait for the operation to complete.
All the resources described in the Terraform manifests will be deleted.
-
-