Migrating data from Elasticsearch to Yandex Managed Service for OpenSearch
You can set up data transfer from Elasticsearch to Managed Service for OpenSearch indexes using Data Transfer. 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
-
Prepare the infrastructure:
-
Create a Managed Service for OpenSearch target cluster in any suitable configuration with publicly available hosts.
-
Install the utilities:
Set up the source cluster
-
(Optional) Create a user to execute the transfer.
You can provide data from the Elasticsearch cluster as the
admin
user with thesuperuser
role; however, it is more secure to create separate users with limited privileges for each task.-
In the source cluster, create a role
with thecreate_index
andwrite
privileges for all indexes (*
). -
In the source cluster, create a user to execute 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> \ --cacert ~/.elasticsearch/root.crt \ --header 'Content-Type: application/json' \ --request PUT 'https://<address_of_Elasticsearch_host_with_Data_Node_role>:9200/people' && \ curl --user <username_in_source_cluster>:<user_password_in_source_cluster> \ --cacert ~/.elasticsearch/root.crt \ --header 'Content-Type: application/json' \ --request PUT 'https://<address_of_Elasticsearch_host_with_Data_Node_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> \ --cacert ~/.elasticsearch/root.crt \ --header 'Content-Type: application/json' \ --request POST 'https://<address_of_Elasticsearch_host_with_Data_Node_role>:9200/people/_doc/?pretty' \ --data' { "name" : "Alice", "age" : "30" } ' && \ curl --user <username_in_source_cluster>:<user_password_in_source_cluster> \ --cacert ~/.elasticsearch/root.crt \ --header 'Content-Type: application/json' \ --request POST 'https://<address_of_Elasticsearch_host_with_Data_Node_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> \ --cacert ~/.elasticsearch/root.crt \ --header 'Content-Type: application/json' \ --request GET 'https://<address_of_Elasticsearch_host_with_Data_Node_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 Elasticsearch source.
-
Create an endpoint for the OpenSearch target.
-
Create a transfer:
ManuallyTerraform- Create a transfer of the Snapshot type that will use the created endpoints.
- Activate the transfer and wait for its status to change to Completed.
-
In the
data-transfer-mes-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.
-
-
-
Activate the transfer and wait for its status to change to Completed.
Test the transfer
Check that the people
index in the Managed Service for OpenSearch cluster contains the data you sent:
Run 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://<address_of_OpenSearch_host_with_Data_Node_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 subnet and network.