Managing ClickHouse® hosts
You can do the following with ClickHouse® hosts:
- Get a list of cluster hosts.
- Create a host.
- Update ClickHouse® host settings.
- Restart a host.
- Delete a host.
For information about moving ClickHouse® hosts to a different availability zone, see this guide.
Warning
If you created your cluster without ClickHouse® Keeper support, you should add at least three ZooKeeper hosts before adding new hosts to any of the shards.
Getting a list of cluster hosts
- Navigate to the folder dashboard
and select Managed Service for ClickHouse. - Click the name of the cluster you need and select the Hosts tab.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To get a list of cluster hosts, run this command:
yc managed-clickhouse host list \
--cluster-name=<cluster_name>
+----------------------------+--------------+---------+--------+---------------+
| NAME | CLUSTER ID | ROLE | HEALTH | ZONE ID |
+----------------------------+--------------+---------+--------+---------------+
| rc1b...mdb.yandexcloud.net | c9qp71dk1... | MASTER | ALIVE | ru-central1-b |
| rc1a...mdb.yandexcloud.net | c9qp71dk1... | REPLICA | ALIVE | ru-central1-a |
+----------------------------+--------------+---------+--------+---------------+
You can get the cluster name with the list of clusters in the folder.
-
Get an IAM token for API authentication and put it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.ListHosts method, e.g., via the following cURL
request:curl \ --request GET \ --header "Authorization: Bearer $IAM_TOKEN" \ --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>/hosts'You can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Call the ClusterService.ListHosts method, e.g., via the following gRPCurl
request: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.ListHostsYou can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
Creating a host
The number of hosts in Managed Service for ClickHouse® clusters is limited by the CPU and RAM quotas allocated to database clusters in your cloud. To check the resources currently in use, open the Quotas
You can create several hosts in a cluster in one go.
-
Navigate to the folder dashboard
and select Managed Service for ClickHouse. -
Click the cluster name and navigate to the Hosts tab.
-
Click Create ClickHouse hosts.
-
Specify the following host settings:
- Availability zone.
- Subnet (if the required subnet is not on the list, create it).
- Shard name.
- Enable Public access to make the host accessible from outside Yandex Cloud, if required.
-
Optionally, click Create host to add more hosts and specify their parameters.
-
Under Additional settings:
- Copy data schema: If the data schema is the same on all replica hosts in the cluster, enable this option to copy the schema from a random replica to the new hosts.
-
Click Create hosts to create one or multiple hosts.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To create one or multiple hosts:
-
To choose a subnet for your new host, get the list of all cluster subnets:
yc vpc subnet listResult:
+-----------+-----------+------------+---------------+------------------+ | ID | NAME | NETWORK ID | ZONE | RANGE | +-----------+-----------+------------+---------------+------------------+ | b0cl69... | default-d | enp6rq7... | ru-central1-d | [172.16.0.0/20] | | e2lkj9... | default-b | enp6rq7... | ru-central1-b | [10.10.0.0/16] | | e9b0ph... | a-2 | enp6rq7... | ru-central1-a | [172.16.32.0/20] | | e9b9v2... | default-a | enp6rq7... | ru-central1-a | [172.16.16.0/20] | +-----------+-----------+------------+---------------+------------------+If the required subnet is not on the list, create it.
-
View the description of the CLI command for creating hosts:
yc managed-clickhouse hosts add --help -
Run the command to create hosts.
Specify one or multiple
--hostparameters in the command, one for each new host.The command for creating a single host is as follows:
yc managed-clickhouse hosts add \ --cluster-name=<cluster_name> \ --host zone-id=<availability_zone>,` `subnet-id=<subnet_ID>,` `assign-public-ip=<public_access_to_host>,` `shard-name=<shard_name>,` `type=clickhouseWhere
assign-public-ipis internet access to the host via a public IP address,trueorfalse.To copy the data schema from a random replica to the new host, set the optional
--copy-schemaparameter.Managed Service for ClickHouse® will start creating hosts.
If your availability zone contains multiple subnets, make sure to specify the subnet ID; otherwise, Managed Service for ClickHouse® will automatically select the single subnet available. You can get the cluster name with the list of clusters in the folder.
-
Open the current Terraform configuration file describing your infrastructure.
Learn how to create this file in Creating a cluster.
-
Add one or multiple
hostsections to the Managed Service for ClickHouse® cluster description, one for each new host.A single
hostsection is as follows:resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" { ... host { type = "CLICKHOUSE" zone = "<availability_zone>" subnet_id = "<subnet_ID>" assign_public_ip = <public_access_to_host> } }Where
assign_public_ipis internet access to the host via a public IP address,trueorfalse. -
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
For more information, see this Terraform provider guide.
Timeouts
The Terraform provider sets the following timeouts for Managed Service for ClickHouse® cluster operations:
- Creating a cluster, including by restoring from a backup: 60 minutes.
- Updating a cluster: 90 minutes.
- Deleting a cluster: 30 minutes.
Operations exceeding the timeout are aborted.
How do I change these limits?
Add a timeouts section to the cluster description, e.g.:
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 in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.AddHosts method, e.g., via the following cURL
request: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>/hosts:batchCreate' \ --data '{ "hostSpecs": [ { "type": "CLICKHOUSE", "zoneId": "<availability_zone>", "subnetId": "<subnet_ID>", "shardName": "<shard_name>", "assignPublicIp": <public_access_to_host> }, { <similar_settings_for_new_host_2> }, { ... }, { <similar_settings_for_new_host_N> } ], "copySchema": <copying_data_schema> }'Where:
-
hostSpecs: Array of settings for the new hosts. Each array element contains the configuration for a single host and has the following structure:type: Host type, which is alwaysCLICKHOUSEfor ClickHouse® hosts.zoneId: Availability zone.subnetId: Subnet ID.shardName: Shard name.assignPublicIp: Internet access to the host via a public IP address,trueorfalse.
-
copySchema: Enables or disables copying the data schema from a random replica to the new hosts,trueorfalse.
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Call the ClusterService.AddHosts method, e.g., via the following gRPCurl
request: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>", "host_specs": [ { "type": "CLICKHOUSE", "zone_id": "<availability_zone>", "subnet_id": "<subnet_ID>", "shard_name": "<shard_name>", "assign_public_ip": <public_access_to_host> }, { <similar_settings_for_new_host_2> }, { ... }, { <similar_settings_for_new_host_N> } ], "copy_schema": <enabling_or_disabling_data_schema_copying> }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.AddHostsWhere:
-
host_specs: Array of settings for the new hosts. Each array element contains the configuration for a single host and has the following structure:type: Host type, which is alwaysCLICKHOUSEfor ClickHouse® hosts.zone_id: Availability zone.subnet_id: Subnet ID.shard_name: Shard name.assign_public_ip: Internet access to the host via a public IP address,trueorfalse.
-
copy_schema: Enables or disables copying the data schema from a random replica to the new hosts,trueorfalse.
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your request was successful.
Warning
If you cannot connect to the host you created, check that the cluster security group is configured correctly for the host subnet.
Use the copy schema option only if the schema is the same across all replica hosts of the cluster.
Updating a host
You can change public access settings for any host in a Managed Service for ClickHouse® cluster.
Warning
For a more secure cluster with public host access enabled, use only trusted IP addresses or subnets in the cluster's security group rules. Learn more in Configuring security groups.
To change the cluster host settings:
- Navigate to the folder dashboard
and select Managed Service for ClickHouse. - Click the cluster name and navigate to the Hosts tab.
- Click
in the host row and select Edit. - In the window that opens, enable Public access to make the host accessible from outside Yandex Cloud, if required.
- Click Save.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To change the host parameters, run this command:
yc managed-clickhouse host update <host_name> \
--cluster-name=<cluster_name> \
--assign-public-ip=<public_access_to_host>
Where assign-public-ip is internet access to the host via a public IP address, true or false.
You can get the host name with the list of cluster hosts, and the cluster name, with the list of clusters in the folder.
-
Open the current Terraform configuration file describing your infrastructure.
Learn how to create this file in Creating a cluster.
-
Add or edit the
assign_public_ipparameter in the relevanthostsection.resource "yandex_mdb_clickhouse_cluster" "<cluster_name>" { ... host { ... assign_public_ip = <public_access_to_host> } ... }Where
assign_public_ipis internet access to the host via a public IP address,trueorfalse. -
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Confirm updating the resources.
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
For more information, see this Terraform provider guide.
-
Get an IAM token for API authentication and put it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.UpdateHosts method, e.g., via the following cURL
request: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
updateMaskparameter as a single comma-separated string.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>/hosts:batchUpdate' \ --data '{ "updateHostSpecs": [ { "hostName": "<host_name>", "updateMask": "assignPublicIp", "assignPublicIp": <public_access_to_host> } ] }'Where
updateHostSpecs[]is the list of hosts and their parameters to update. Below is the structure of an individual element:-
hostName: Host name which you can get with the list of hosts in the cluster. -
updateMask: Comma-separated string of settings you want to update.Here, we only specified a single setting,
assignPublicIp. -
assignPublicIp: Internet access to the host via a public IP address,trueorfalse.
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Call the ClusterService.UpdateHosts method, e.g., via the following gRPCurl
request: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_maskparameter 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>", "update_host_specs": [ { "host_name": "<host_name>", "update_mask": { "paths": [ "assign_public_ip" ] }, "assign_public_ip": <public_access_to_host> }] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.UpdateHostsWhere
update_host_specs[]is the list of hosts and their parameters to update. Below is the structure of an individual element:-
host_name: Host name which you can get with the list of hosts in the cluster. -
update_mask: List of settings to update as an array of strings (paths[]).Here, we only specified a single setting,
assign_public_ip. -
assign_public_ip: Internet access to the host via a public IP address,trueorfalse.
You can get the cluster ID with the list of clusters in the folder.
-
-
View the server response to make sure your request was successful.
Warning
If you cannot connect to the host after the update, check that the cluster security group is properly configured for the subnet containing your host.
Restarting a host
You may need to restart hosts to promptly address such issues as:
- Resource overutilization
- Memory leak
- Request deadlock
- Unresponsive ClickHouse® operations and internal processes
To restart a single host:
- Navigate to the folder dashboard
and select Managed Service for ClickHouse. - Click the cluster name and navigate to the Hosts tab.
- In the host row, click
and select Restart. - In the window that opens, enable I am restarting host and click Confirm.
To restart multiple hosts in one go:
- Navigate to the folder dashboard
and select Managed Service for ClickHouse. - Click the cluster name and navigate to the Hosts tab.
- Select the hosts you want to restart and click Restart at the bottom of the screen.
- In the window that opens, click Confirm.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To restart one or multiple hosts, run the command below providing their names. Use the space character as a separator.
Here is the command to restart a single host:
yc managed-clickhouse host restart <host_name> \
--cluster-name=<cluster_name>
You can get the host name with the list of cluster hosts, and the cluster name, with the list of clusters in the folder.
-
Get an IAM token for API authentication and put it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.RestartHosts method, e.g., via the following cURL
request: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>/hosts:restartHosts' \ --data '{ "hostNames": [ <list_of_host_names> ] }'Where
hostNamesis an array of strings. Each string is the name of the host to restart. You can get the host names with the list of hosts in the cluster.You can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Call the ClusterService.RestartHosts method, e.g., via the following gRPCurl
request: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>", "host_names": [ <list_of_host_names> ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.RestartHostsWhere
host_namesis an array of strings. Each string is the name of the host to restart. You can get the host names with the list of hosts in the cluster.You can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
Deleting a host
Warning
You cannot delete a host from a cluster or shard if the relevant limit for the minimum number of hosts was reached.
You cannot delete hosts running ClickHouse® Keeper if you enabled this replication option when creating the cluster.
You cannot delete hosts of different types (ClickHouse® and ZooKeeper) at the same time.
To delete a single host:
- Navigate to the folder dashboard
and select Managed Service for ClickHouse. - Click the cluster name and navigate to the Hosts tab.
- Click
in the host row and select Delete. - In the window that opens, enable Delete host and click Confirm.
To delete multiple hosts in one go:
- Navigate to the folder dashboard
and select Managed Service for ClickHouse. - Click the cluster name and navigate to the Hosts tab.
- Select the hosts you want to delete and click Delete at the bottom of the screen.
- In the window that opens, click Delete.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.
To delete one or multiple hosts from a cluster, run the command below, providing the names of the hosts you want to delete. Use the space character as a separator.
The command for deleting a single host is as follows:
yc managed-clickhouse hosts delete --cluster-name=<cluster_name> \
<host_name>
You can get the host names with the list of cluster hosts, and the cluster name, with the list of clusters in the folder.
-
Open the current Terraform configuration file describing your infrastructure.
Learn how to create this file in Creating a cluster.
-
In the Managed Service for ClickHouse® cluster description, delete one or multiple
CLICKHOUSEhostsections. -
Make sure the settings are correct.
-
In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
-
Run this command:
terraform validateTerraform will show any errors found in your configuration files.
-
-
Type
yesand press Enter.-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
For more information, see this Terraform provider guide.
Timeouts
The Terraform provider sets the following timeouts for Managed Service for ClickHouse® cluster operations:
- Creating a cluster, including by restoring from a backup: 60 minutes.
- Updating a cluster: 90 minutes.
- Deleting a cluster: 30 minutes.
Operations exceeding the timeout are aborted.
How do I change these limits?
Add a timeouts section to the cluster description, e.g.:
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 in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Call the Cluster.DeleteHosts method, e.g., via the following cURL
request: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>/hosts:batchDelete' \ --data '{ "hostNames": [ <list_of_host_names> ] }'Where
hostNamesis an array of strings. Each string is the name of a host to delete. You can get the host names with the list of hosts in the cluster.You can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
-
Get an IAM token for API authentication and put it in an environment variable:
export IAM_TOKEN="<IAM_token>" -
Clone the cloudapi
repository:cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapiBelow, we assume the repository contents are stored in the
~/cloudapi/directory. -
Call the ClusterService.DeleteHosts method, e.g., via the following gRPCurl
request: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>", "host_names": [ <list_of_host_names> ] }' \ mdb.api.cloud.yandex.net:443 \ yandex.cloud.mdb.clickhouse.v1.ClusterService.DeleteHostsWhere
host_namesis an array of strings. Each string is the name of a host to delete. You can get the host names with the list of hosts in the cluster.You can get the cluster ID with the list of clusters in the folder.
-
View the server response to make sure your request was successful.
ClickHouse® is a registered trademark of ClickHouse, Inc