How to manage shards
You can enable sharding for a cluster as well as add and configure individual shards.
Enable sharding
Managed Service for ClickHouse clusters are created in a configuration with one shard. To start sharding data, follow the guidelines in Sharding ClickHouse tables.
Change a shard
You can change the shard weight as well as host class and storage size.
- Go to the folder page and select Managed Service for ClickHouse.
- Click the name of a cluster and open the Shards tab.
- Click and select Change.
If you don't 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 in the cluster:
-
View a description of the CLI's shard change command:
yc managed-clickhouse shards update --help
-
Start an operation, such as changing the shard weight:
yc managed-clickhouse shards update --cluster-name clickhouse12 \ --name shard1 \ --weight 80
When the operation is complete, the CLI displays information about the changed shard:
name: shard1
cluster_id: c9fmo2rf013t4q0ab8m1
config:
clickhouse:
config:
effective_config:
log_level: INFORMATION
...
weight: "80"
To change the shard settings, use the updateShard method.
List shards in a cluster
-
Go to the folder page and select Managed Service for ClickHouse.
-
Click the name of a cluster and open the Shards tab.
To list the shards in a cluster, use the listShards method.
Add a shard
The number of shards in Managed Service for ClickHouse clusters is limited by the CPU and RAM quotas available to DB clusters in your cloud. To check the resources in use, open the Quotas page and find the Yandex Managed Service for ClickHouse block.
- Go to the folder page and select Managed Service for ClickHouse.
- Click on the name of the cluster you need and go to the Hosts tab.
- Click Add shard.
- Enter a name for the shard and add the desired number of hosts.
- Click Create shard.
To add a host to the cluster, use the addHosts method.
Delete a shard
You can delete a shard from a ClickHouse cluster provided that it's not the only shard in it.
-
Go to the folder page and select Managed Service for ClickHouse.
-
Click on the name of a cluster and open the Shards tab.
-
Click in the line of the desired host and select Delete.
Use the deleteHosts method to delete a host.