Loading data from Yandex Managed Service for OpenSearch to Yandex Object Storage using Yandex Data Transfer
With Data Transfer, you can transfer data from a Managed Service for OpenSearch cluster to Object Storage.
To transfer data:
If you no longer need the resources you created, delete them.
Getting started
Prepare the infrastructure:
-
Create a Managed Service for OpenSearch cluster in any suitable configuration with publicly available hosts.
-
If using security groups in your cluster, make sure they are configured correctly and allow connecting to the Managed Service for OpenSearch cluster.
-
Get an SSL certificate to connect to the Managed Service for OpenSearch cluster.
-
Create a service account with the
storage.editor
role. The transfer will use it to access the bucket.
-
If you do not have Terraform yet, install it.
-
Get the authentication credentials. You can add them to environment variables or specify them later in the provider configuration file.
-
Configure and initialize a provider. There is no need to create a provider configuration file manually, you can download it
. -
Place the configuration file in a separate working directory and specify the parameter values. If you did not add the authentication credentials to environment variables, specify them in the configuration file.
-
Download the opensearch-to-object-storage.tf
configuration file to the same working directory.This file describes:
- Network.
- Subnet.
- Security group for connecting to a Managed Service for OpenSearch cluster.
- Service account with the
storage.editor
role. - Managed Service for OpenSearch cluster.
- Object Storage target bucket.
- Endpoints.
- Transfer.
-
In the
opensearch-to-object-storage.tf
file, specify the following parameters:-
folder_id
: Folder ID. -
mos_version
: OpenSearch version. -
mos_password
: User password of the OpenSearch cluster owner. -
bucket_name
: Bucket name consistent with the naming conventions. -
profile_name
: Your YC CLI profile name.If you do not have the Yandex Cloud command line interface yet, install and initialize it.
-
-
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
. -
Prepare the test data
-
Connect to the Managed Service for OpenSearch source cluster.
-
Create a test index named
people
and set its schema:curl --user admin:<password> \ --cacert ~/.opensearch/root.crt \ --header 'Content-Type: application/json' \ --request PUT 'https://<address_of_OpenSearch_host_with_DATA_role>:9200/people' && \ curl --user admin:<password> \ --cacert ~/.opensearch/root.crt \ --header 'Content-Type: application/json' \ --request PUT 'https://<address_of_OpenSearch_host_with_DATA_role>:9200/people/_mapping?pretty' -d' { "properties": { "name": {"type": "text"}, "age": {"type": "integer"} } } '
-
Populate the test index with data:
curl --user admin:<password> \ --cacert ~/.opensearch/root.crt \ --header 'Content-Type: application/json' \ --request POST 'https://<address_of_OpenSearch_host_with_DATA_role>:9200/people/_doc/?pretty' -d' { "name" : "Alice", "age" : "30" } ' && \ curl --user admin:<password> \ --cacert ~/.opensearch/root.crt \ --header 'Content-Type: application/json' \ --request POST 'https://<address_of_OpenSearch_host_with_DATA_role>:9200/people/_doc/?pretty' -d' { "name" : "Robert", "age" : "32" } '
-
(Optional) Check the data in the test index:
curl --user admin:<password> \ --cacert ~/.opensearch/root.crt \ --header 'Content-Type: application/json' \ --request GET 'https://<address_of_OpenSearch_host_with_DATA_role>:9200/people/_search?pretty'
Prepare and activate the transfer
-
Create a target endpoint of the
Object Storage
type with the following settings:- Bucket:
<name_of_previously_created_bucket>
. - Service account:
<name_of_previously_created_service_account>
. - Serialization format:
JSON
. - Encoding format:
[object Object]
. - Folder name:
from_MOS
.
- Bucket:
-
Create a source endpoint of the
OpenSearch
type with the following settings:- Connection type:
Managed Service for OpenSearch cluster
. - Managed Service for OpenSearch cluster: Select the Managed Service for OpenSearch cluster from the list.
- User:
admin
. - Password:
<user_password>
.
- Connection type:
-
Create a transfer:
ManuallyTerraform-
Create a transfer of the Snapshot type that will use the created endpoints.
-
In the
opensearch-to-object-storage.tf
file, specify the values of the following variables:target_endpoint_id
: ID of the target endpoint.source_endpoint_id
: ID of the source endpoint.transfer_enabled
: Put1
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
Make sure the data has been transferred from the Managed Service for OpenSearch cluster to the Object Storage bucket:
- Wait for the transfer status to change to Completed.
- In the management console
, select the folder where the bucket is located. - In the list of services, select Object Storage.
- Select the bucket from the list.
- Go to the Objects tab.
- Check that the Object Storage bucket contains the
from_MOS
folder with the JSON file with the test data.
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 the other resources depending on how they were created:
-
In the management console
, delete thefrom_MOS
folder from the created bucket. -
In the terminal window, go to the directory containing the infrastructure plan.
-
Delete the
opensearch-to-object-storage.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
opensearch-to-object-storage.tf
configuration file will be deleted. -