Migrating data to Yandex Managed Service for ClickHouse
With Data Transfer, you can transfer your database from a third-party ClickHouse source cluster to a Managed Service for ClickHouse target cluster.
This method allows you to:
- Copy the database without interrupting user service.
- Go without creating an intermediate VM or granting online access to your Managed Service for ClickHouse target cluster.
For more information, see What tasks is Yandex Data Transfer used for?.
Getting started
-
Create a Managed Service for ClickHouse target cluster with the computing capacity and storage size appropriate for the environment where the copied database is deployed.
The database name in the target cluster must be the same as the source database name.
Transferring data
-
Prepare the infrastructure:
ManuallyUsing Terraform-
-
Database type:
ClickHouse
. -
Endpoint parameters → Connection settings:
Custom installation
.Specify the parameters for connecting to the source cluster.
-
-
-
Database type:
ClickHouse
. -
Endpoint parameters → Connection settings:
MDB cluster
.Select a target cluster from the list and specify the cluster connection settings.
-
-
Create a transfer of the Snapshot type that will use the created endpoints.
-
Activate it.
-
If you don't have Terraform, install and configure it.
-
Download the file with provider settings. Place it in a separate working directory and specify the parameter values.
-
Download the configuration file data-transfer-ch-mch.tf to the same working directory.
This file describes:
- Network.
- Subnet.
- Security groups and the rule required to connect to a cluster.
- ClickHouse source.
- Managed Service for ClickHouse target cluster.
- Source endpoint.
- Target endpoint.
- Transfer.
-
In the
data-transfer-ch-mch.tf
file, specify:-
source_user
andsource_pwd
: The username and password to access the source.source_db_name
: Database name.source_host
: The FQDN or IP address of the ClickHouse server.source_http_port
andsource_native_port
: The HTTP and ClickHouse native interface connection ports.
-
Target cluster parameters also used as target endpoint parameters:
target_clickhouse_version
: ClickHouse version.target_user
andtarget_password
: Username and password of the database owner.
-
-
Run the command
terraform init
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 the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
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.
Once created, a transfer is activated automatically.
-
-
Wait for the transfer status to change to Completed.
For more information about transfer statuses, see Transfer lifecycle.
-
Delete the resources you created:
Manually created resourcesResources created using Terraform- Delete the Managed Service for ClickHouse cluster.
- Delete the completed transfer.
- Delete endpoints for the source and target.
-
In the terminal window, change to the directory containing the infrastructure plan.
-
Delete the
data-transfer-ch-mch.tf
configuration file. -
Make sure the Terraform configuration files are correct using the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
Confirm the update of 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-ch-mch.tf
configuration file will be deleted. -