Migrating data from a third-party OpenSearch cluster to Yandex Managed Service for OpenSearch 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.
- Prepare and activate the transfer.
- Test the transfer.
If you no longer need the resources you created, delete them.
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 don't have Terraform, 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.tf
file, specify these variables:-
os_admin_password
: Managed Service for OpenSearch admin user password. -
transfer_enabled
: Set to0
to ensure that no transfer is created until you create endpoints manually. -
profile_name
: Your YC CLI profile name.If you do not have the Yandex Cloud command line interface yet, install and initialize it.
-
-
Run the
terraform init
command in the directory with the configuration file. This command initializes the provider specified in the configuration files and enables you to use the provider resources and data sources. -
Make sure the Terraform configuration files are correct using this command:
terraform validate
If there are any errors in the configuration files, Terraform will point them out.
-
Create the required infrastructure:
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of 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 utilities:
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.
-
(Optional) In the source cluster, create a role
with thecreate_index
andwrite
privileges for all indexes (*
). -
(Optional) In the source cluster, create a user
to run the transfer and assign the user the role you created.
Prepare the test data
-
In the source cluster, create a test index named
people
and set its schema: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 <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/_mapping?pretty' \ --data' { "properties": { "name": {"type": "text"}, "age": {"type": "integer"} } } '
-
Populate the test index with data:
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": "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" } '
-
(Optional) 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
-
Get an SSL certificate to connect 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
admin
user with thesuperuser
role; however, it is more secure to create separate users with limited privileges for each task.-
Create a role
with thecreate_index
andwrite
privileges for all indexes (*
). -
Create a user and assign this role to them.
-
Prepare 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 created endpoints.
- Activate the transfer.
-
In the
data-transfer-os-mos.tf
file, specify these variables:source_endpoint_id
: ID of the source endpoint.target_endpoint_id
: Target endpoint ID.transfer_enabled
:1
to create a transfer.
-
Make sure the Terraform configuration files are correct using this command:
terraform validate
If there are any errors in the configuration files, Terraform will point them out.
-
Create the required infrastructure:
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
Once created, your transfer will be activated automatically.
-
Test the transfer
-
Wait for the transfer status to change to Completed.
-
Check that the
people
index in the Managed Service for OpenSearch cluster contains the data you sent: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
Global
tenant. - Open the control panel by clicking
. - Under OpenSearch Dashboards, select Discover.
- In the CHANGE INDEX PATTERN field, select the
people
index.
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 endpoints for both the source and target.
-
Delete the other resources depending on how they were created:
ManuallyTerraform-
In the terminal window, go to the directory containing the infrastructure plan.
-
Delete the
data-transfer-os-mos.tf
configuration file. -
Make sure the Terraform configuration files are correct using this command:
terraform validate
If there are any errors in the configuration files, Terraform will point them out.
-
Confirm updating the resources.
-
Run the command to view planned changes:
terraform plan
If the resource configuration descriptions are correct, the terminal will display a list of the resources to modify and their parameters. This is a test step. No resources are updated.
-
If you are happy with the planned changes, apply them:
-
Run the command:
terraform apply
-
Confirm the update of resources.
-
Wait for the operation to complete.
-
All the resources described in the
data-transfer-os-mos.tf
configuration file will be deleted. -
-