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 job.-
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 <source_cluster_username>:<source_cluster_user_password> \ --cacert ~/.elasticsearch/root.crt \ --header 'Content-Type: application/json' \ --request PUT 'https://<Elasticsearch_Data_Node_host_address>:9200/people' && \ curl --user <source_cluster_username>:<source_cluster_user_password> \ --cacert ~/.elasticsearch/root.crt \ --header 'Content-Type: application/json' \ --request PUT 'https://<Elasticsearch_Data_Node_host_address>:9200/people/_mapping?pretty' -d' { "properties": { "name": {"type": "text"}, "age": {"type": "integer"} } } '
-
Populate the test index with data:
curl --user <source_cluster_username>:<source_cluster_user_password> \ --cacert ~/.elasticsearch/root.crt \ --header 'Content-Type: application/json' \ --request POST 'https://<Elasticsearch_Data_Node_host_address>:9200/people/_doc/?pretty' -d' { "name" : "Alice", "age" : "30" } ' && \ curl --user <source_cluster_username>:<source_cluster_user_password> \ --cacert ~/.elasticsearch/root.crt \ --header 'Content-Type: application/json' \ --request POST 'https://<Elasticsearch_Data_Node_host_address>:9200/people/_doc/?pretty' -d' { "name" : "Robert", "age" : "32" } '
-
(Optional) Check the data in the test index:
curl --user <target_cluster_username>:<target_cluster_user_password> \ --cacert ~/.elasticsearch/root.crt \ --header 'Content-Type: application/json' \ --request GET 'https://<Elasticsearch_Data_Node_host_address>: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 job.-
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 the variables:source_endpoint_id
: ID of the source endpoint.target_endpoint_id
: ID of the target endpoint.transfer_enabled
: Set to1
to enable transfer creation.
-
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 transferred data:
Run this command:
curl --user <target_cluster_username>:<target_cluster_user_password> \
--cacert ~/.opensearch/root.crt \
--header 'Content-Type: application/json' \
--request GET 'https://<OpenSearch_Data_Node_host_address>: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.