Managing shards in a ClickHouse® cluster
You can group several shards of a ClickHouse® cluster in a shard group and save tables in this group.
Listing shard groups in a cluster
- In the management console
, go to the folder page and select Managed Service for ClickHouse. - Click the cluster name and open the Shard groups tab.
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.
To get a list of shard groups in a cluster, run the command:
yc managed-clickhouse shard-groups list \
--cluster-name=<cluster_name>
You can request the cluster name with a list of clusters in the folder.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.ListShardGroups method and send the following request, e.g., via cURL
:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>/shardGroups'
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.ListShardGroups call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.ListShardGroups
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
Viewing detailed information about a shard group
- In the management console
, go to the folder page and select Managed Service for ClickHouse. - Click the cluster name and open the Shard groups tab.
- Select a shard group to view detailed information.
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.
To view detailed information about a shard group in a cluster, run the command:
yc managed-clickhouse shard-groups get \
--cluster-name=<cluster_name> \
--name=<shard_group_name>
You can request the cluster name with a list of clusters in the folder.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.GetShardGroup method and send the following request, e.g., via cURL
:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>/shardGroups/<shard_group_name>'
You can request the cluster ID with a list of clusters in the folder and the shard group name with a list of groups in the cluster.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.GetShardGroup call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "shard_group_name": "<shard_group_name>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.GetShardGroup
You can request the cluster ID with a list of clusters in the folder and the shard group name with a list of groups in the cluster.
-
View the server response to make sure the request was successful.
Creating a shard group
- In the management console
, go to the folder page and select Managed Service for ClickHouse. - Click the cluster name and open the Shard groups tab.
- Click Create shard group.
- Fill in the form fields and click Apply.
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.
To create a shard group in a cluster, run the command:
yc managed-clickhouse shard-groups create \
--cluster-name=<cluster_name> \
--name=<shard_group_name> \
--description=<shard_group_description> \
--shards=<list_of_shard_names>
Where --shards
is the list of list of shard names to include in the group.
You can request the cluster name with a list of clusters in the folder.
You can request a shard name with a list of shards in the cluster.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
Add the
shard_group
description section to the Managed Service for ClickHouse® cluster description.resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" { ... shard_group { name = "<shard_group_name>" description = "<optional_shard_group_description>" shard_names = [ # List of shards in the group "<shard_1_name>", ... "<shard_N_name>" ] } }
-
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.
-
-
For more information, see the Terraform provider documentation
Time limits
A Terraform provider sets the timeout for Managed Service for ClickHouse® cluster operations:
- Creating a cluster, including by restoring one from a backup: 60 minutes.
- Editing a cluster: 90 minutes.
- Deleting a cluster: 30 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts
block to the cluster description, for example:
resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # 1 hour 30 minutes
update = "2h" # 2 hours
delete = "30m" # 30 minutes
}
}
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.CreateShardGroup method and send the following request, e.g., via cURL
:curl \ --request POST \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>/shardGroups' \ --data '{ "shardGroupName": "<shard_group_name>", "description": "<shard_group_description>", "shardNames": [ "<shard_1>", "<shard_2>", ... "<shard_N>" ] }'
Where:
shardGroupName
: Shard group name.description
: Shard group description.shardNames
: List of shards to include into the new group.
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.CreateShardGroup call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "shard_group_name": "<shard_group_name>", "description": "<shard_group_description>", "shard_names": [ "<shard_1>", "<shard_2>", ... "<shard_N>" ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.CreateShardGroup
Where:
shard_group_name
: Shard group name.description
: Shard group description.shard_names
: List of shards to include into the new group.
You can get the cluster ID with a list of clusters in the folder.
-
View the server response to make sure the request was successful.
Changing a shard group
- In the management console
, go to the folder page and select Managed Service for ClickHouse. - Click the cluster name and open the Shard groups tab.
- Click
for the shard group you need and select Edit.
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.
To change a shard group in a cluster, run the command:
yc managed-clickhouse shard-groups update \
--cluster-name=<cluster_name> \
--name=<shard_group_name> \
--description=<new_description_for_shard_group> \
--shards=<new_list_of_shard_names>
Where --shards
is the new list of shard names to include in the group.
This command replaces the existing list of shards in the group with the new one provided in the --shards
parameter. Before running the command, make sure that you have added all the required shards to the new list.
You can request the cluster name with a list of clusters in the folder.
You can request the name of the shard group with a list of shard groups in the cluster.
You can request a shard name with a list of shards in the cluster.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
In the Managed Service for ClickHouse® cluster description, change the
shard_group
section to include the required shard group:resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" { ... shard_group { name = "<new_name_for_shard_group>" description = "<new_description_for_shard_group>" shard_names = [ # New list of shards in the group "<shard_1_name>", ... "<shard_N_name>" ] } }
-
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.
-
-
For more information, see the Terraform provider documentation
Time limits
A Terraform provider sets the timeout for Managed Service for ClickHouse® cluster operations:
- Creating a cluster, including by restoring one from a backup: 60 minutes.
- Editing a cluster: 90 minutes.
- Deleting a cluster: 30 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts
block to the cluster description, for example:
resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # 1 hour 30 minutes
update = "2h" # 2 hours
delete = "30m" # 30 minutes
}
}
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.updateShardGroup method and send the following request, e.g., via cURL
:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
updateMask
parameter as a single comma-separated string.curl \ --request PATCH \ --header "Authorization: Bearer $IAM_TOKEN" \ --header "Content-Type: application/json" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>/shardGroups/<shard_group_name>' \ --data '{ "updateMask": "description,shardNames", "description": "<shard_group_description>", "shardNames": [ "<shard_1>", "<shard_2>", ... "<shard_N>" ] }'
Where:
updateMask
: List of parameters to update as a single string, separated by commas.description
: New description of the shard group.shardNames
: New list of shards to include in the group. To learn shard names, get a list of shards in the cluster. This list will replace the current one, so make sure you have added all the required shards to the new list.
You can request the cluster ID with a list of clusters in the folder and the shard group name with a list of groups in the cluster.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.UpdateShardGroup call and send the following request, e.g., via gRPCurl
:Warning
The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the
update_mask
parameter as an array ofpaths[]
strings.Format for listing settings
"update_mask": { "paths": [ "<setting_1>", "<setting_2>", ... "<setting_N>" ] }
grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "shard_group_name": "<shard_group_name>", "update_mask": { "paths": [ "description", "shard_names" ] }, "description": "<shard_group_description>", "shard_names": [ "<shard_1>", "<shard_2>", ... "<shard_N>" ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.UpdateShardGroup
Where:
update_mask
: List of parameters to update as an array ofpaths[]
strings.description
: New description of the shard group.shard_names
: New list of shards to include in the group. To learn shard names, get a list of shards in the cluster. This list will replace the current one, so make sure you have added all the required shards to the new list.
You can request the cluster ID with a list of clusters in the folder and the shard group name with a list of groups in the cluster.
-
View the server response to make sure the request was successful.
Deleting a group of shards
Deleting a group of shards doesn't affect the shards in the group: they are kept in the cluster.
Tables created on the deleted group are kept, but they are disabled and attempts to query them result in errors. However, you can delete these tables before or after you delete the shard group.
- In the management console
, go to the folder page and select Managed Service for ClickHouse. - Click the cluster name and open the Shard groups tab.
- Click
for the shard group you need and select Delete.
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.
To delete a shard group in a cluster, run the command:
yc managed-clickhouse shard-groups delete \
--cluster-name=<cluster_name> \
--name=<shard_group_name>
You can request the cluster name with a list of clusters in the folder.
You can request the name of the shard group with a list of shard groups in the cluster.
-
Open the current Terraform configuration file with an infrastructure plan.
For more information about creating this file, see Creating clusters.
-
Delete the
shard_group
description section for the appropriate group from the Managed Service for ClickHouse® 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.
-
-
For more information, see the Terraform provider documentation
Time limits
A Terraform provider sets the timeout for Managed Service for ClickHouse® cluster operations:
- Creating a cluster, including by restoring one from a backup: 60 minutes.
- Editing a cluster: 90 minutes.
- Deleting a cluster: 30 minutes.
Operations exceeding the set timeout are interrupted.
How do I change these limits?
Add the timeouts
block to the cluster description, for example:
resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" {
...
timeouts {
create = "1h30m" # 1 hour 30 minutes
update = "2h" # 2 hours
delete = "30m" # 30 minutes
}
}
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Use the Cluster.DeleteShardGroup method and send the following request, e.g., via cURL
:curl \ --request DELETE \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>/shardGroups/<shard_group_name>'
You can request the cluster ID with a list of clusters in the folder and the shard group name with a list of groups in the cluster.
-
View the server response to make sure the request was successful.
-
Get an IAM token for API authentication and put it into the environment variable:
export IAM_TOKEN="<IAM_token>"
-
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
Below, we assume the repository contents are stored in the
~/cloudapi/
directory. -
Use the ClusterService.DeleteShardGroup call and send the following request, e.g., via gRPCurl
:grpcurl \ -format json \ -import-path ~/cloudapi/ \ -import-path ~/cloudapi/third_party/googleapis/ \ -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/cluster_service.proto \ -rpc-header "Authorization: Bearer $IAM_TOKEN" \ -d '{ "cluster_id": "<cluster_ID>", "shard_group_name": "<shard_group_name>" }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.DeleteShardGroup
You can request the cluster ID with a list of clusters in the folder and the shard group name with a list of groups in the cluster.
-
View the server response to make sure the request was successful.
ClickHouse® is a registered trademark of ClickHouse, Inc