Migrating ClickHouse® cluster hosts to a different availability zone
ClickHouse® and ZooKeeper hosts of the Managed Service for ClickHouse® cluster are located in Yandex Cloud availability zones. Follow this guide to migrate ClickHouse® and ZooKeeper hosts to a different availability zone. If you want to migrate ClickHouse® Keeper hosts, contact support
Note
Not available for clusters with hosts residing in the ru-central1-d
availability zone:
- Intel Broadwell platform
- Local SSD storage if using Intel Cascade Lake
Migrating ClickHouse® hosts
-
Make sure the migration will only include replicated tables on the
ReplicatedMergeTree
family engine.Non-replicated tables will be lost during migration.
-
If you have created a cluster without ClickHouse® Keeper support, enable fault tolerance using ZooKeeper hosts. Otherwise, you will not be able to add new hosts to shards and perform migration.
-
Create a subnet in the availability zone you want to move your hosts to.
-
Add a host to your cluster:
Management consoleCLITerraformAPI-
Go to the folder page
and select Managed Service for ClickHouse. -
Click the cluster name and go to the Hosts tab.
-
Click Create host.
-
Specify the host parameters:
- Availability zone to which you want to move the hosts.
- New subnet.
- Select Public access if the host must be accessible from outside Yandex Cloud.
-
Click Save.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the
--folder-name
or--folder-id
parameter.Run this command:
yc managed-clickhouse host add \ --cluster-name <cluster_name> \ --host type=clickhouse,` `zone-id=<availability_zone>,` `subnet-id=<new_subnet_ID>,` `assign-public-ip=<public_access_to_host:_true_or_false>
You can retrieve the cluster name with a list of clusters in the folder. In the
zone-id
parameter, specify the availability zone you are moving the hosts to.-
Add a host manifest to the Terraform configuration file with the infrastructure plan:
resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" { ... host { type = "CLICKHOUSE" zone = "<availability_zone>" subnet_id = "<new_subnet_ID>" assign_public_ip = <public_access_to_host:_true_or_false> } }
In the
zone
parameter, specify the availability zone you are moving the hosts to. -
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
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.
-
-
To add a host to a cluster, use the addHosts REST API method for the Cluster resource or the ClusterService/AddHosts gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. You can get the ID with a list of clusters in the folder. - New host settings in the
hostSpecs
parameters.
-
-
To successfully connect to the database after the migration is complete, specify the new host's FQDN in your backend or client (for example, in the code or graphical IDE). Delete the original host's FQDN in the source availability zone.
To find out the FQDN, get a list of hosts in the cluster:
yc managed-clickhouse host list --cluster-name <cluster_name>
The FQDN is specified in the command output under
NAME
. You can also use a special FQDN for a connection. -
Delete the hosts in the source availability zone:
Management consoleCLITerraformAPI- Go to the folder page
and select Managed Service for ClickHouse. - Click the cluster name and open the Hosts tab.
- Click
in the host's row, select Delete, and confirm the deletion.
Run the following command for each host:
yc managed-clickhouse host delete <host_FQDN> --cluster-name <cluster_name>
-
In the Terraform configuration file with the infrastructure plan, remove the
host
sections with the source availability zone from the cluster description. -
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Type
yes
and press Enter.-
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.
-
-
To delete a host, use the deleteHosts REST API method for the Cluster resource or the ClusterService/DeleteHosts gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - FQDN or an array of names of the hosts you want to delete, in the
hostNames
parameter. You can get FQDN names in the management console , on the Hosts tab of the cluster page.
- Go to the folder page
-
Wait until the cluster status changes to Alive. In the management console, go to the folder page and select Managed Service for ClickHouse. You can see the cluster status in the Availability column.
Migrating ZooKeeper hosts
-
Create a subnet in the availability zone you want to move your hosts to.
-
Add a host to your cluster:
Management consoleCLITerraformAPI- Go to the folder page
and select Managed Service for ClickHouse. - Click the cluster name and go to the Hosts tab.
- Click Add ZooKeeper hosts.
- Specify the new subnet and the availability zone to move the hosts to.
- Click Save.
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the
--folder-name
or--folder-id
parameter.Run this command:
yc managed-clickhouse host add \ --cluster-name <cluster_name> \ --host type=zookeeper,` `zone-id=<availability_zone>,` `subnet-id=<new_subnet_ID>,` `assign-public-ip=<public_access_to_host:_true_or_false>
You can retrieve the cluster name with a list of clusters in the folder. In the
zone-id
parameter, specify the availability zone you are moving the hosts to.-
Add a host manifest to the Terraform configuration file with the infrastructure plan:
resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" { ... host { type = "ZOOKEEPER" zone = "<availability_zone>" subnet_id = "<new_subnet_ID>" assign_public_ip = <public_access_to_host:_true_or_false> } }
In the
zone
parameter, specify the availability zone you are moving the hosts to. -
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
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.
-
-
To add a host to a cluster, use the addZookeeper REST API method for the Cluster resource or the ClusterService/AddZookeeper gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. You can get the ID with a list of clusters in the folder. - New host settings in the
resources
andhostSpecs
parameters.
- Go to the folder page
-
Delete the hosts in the source availability zone:
Management consoleCLITerraformAPI- Go to the folder page
and select Managed Service for ClickHouse. - Click the cluster name and open the Hosts tab.
- Click
in the host's row, select Delete, and confirm the deletion.
Run the following command for each host:
yc managed-clickhouse host delete <host_FQDN> --cluster-name <cluster_name>
-
In the Terraform configuration file with the infrastructure plan, remove the
host
sections with the source availability zone from the cluster description. -
Make sure the settings are correct.
-
Using the command line, navigate to the folder that contains the up-to-date Terraform configuration files with an infrastructure plan.
-
Run the command:
terraform validate
If there are errors in the configuration files, Terraform will point to them.
-
-
Type
yes
and press Enter.-
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.
-
-
To delete a host, use the deleteHosts REST API method for the Cluster resource or the ClusterService/DeleteHosts gRPC API call and provide the following in the request:
- Cluster ID in the
clusterId
parameter. To find out the cluster ID, get a list of clusters in the folder. - FQDN or an array of names of the hosts you want to delete, in the
hostNames
parameter. You can get FQDN names in the management console , on the Hosts tab of the cluster page.
- Go to the folder page
-
Wait until the cluster status changes to Alive. In the management console, go to the folder page and select Managed Service for ClickHouse. You can see the cluster status in the Availability column.
Specifics of migration in Yandex Data Transfer
If your cluster is used as an endpoint when transferring data with Data Transfer, and the transfer type is Replication or Snapshot and increment, restart the transfer after migrating the cluster. This way, the transfer will get data about the cluster's new topology.
You do not need to restart Snapshot transfers, as information about the new topology is provided automatically while activating them.
To restart a transfer, choose one of the two methods:
- Deactivate the transfer and wait for its status to change to Stopped. Next, reactivate the transfer and wait for its status to change to Replicating.
- Update any setting for the transfer or endpoint.
For more information, see Migrating a Data Transfer transfer and endpoints to a different availability zone.
ClickHouse® is a registered trademark of ClickHouse, Inc